Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

feat: simplify DockerSandbox interface to take container ID - #1141

Closed
gautamsirdeshmukh wants to merge 1 commit into
strands-agents:mainfrom
gautamsirdeshmukh:feat/docker-sandbox-update
Closed

gautamsirdeshmukh wants to merge 1 commit into
strands-agents:mainfrom
gautamsirdeshmukh:feat/docker-sandbox-update

Conversation

@gautamsirdeshmukh

Copy link
Copy Markdown
Contributor

Description

Simplify DockerSandbox to "bring-your-own-container" (thin docker exec wrapper). The SDK no longer manages container lifecycle, security policies, volumes, or resource limits. Users create and configure their container externally.

Removed:

  • Lifecycle control: start()/stop() methods, AsyncDisposable usage
  • Low-level params: image, name, volumes, env, memory, cpus, pidsLimit, network options
  • Various now-obsolete internal helper methods and security checks

What remains:

  • containerId (required), workingDir (default /tmp), user (default 1000:1000)
  • Single executeStreaming method that shells out to docker exec

Related Issues

Updates #1110

Documentation PR

Not yet

Type of Change

(breaking) change

Testing

How have you tested the change?

  • I ran the relevant checks (hatch run prepare for Python, npm run check for TypeScript)

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions github-actions Bot added the strands-running <strands-managed> Whether or not an agent is currently running label Jun 2, 2026
@@ -62,169 +21,36 @@ export interface DockerSandboxOptions {
* If you specify a custom path, it must already exist in the image and be writable by `user`.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: The TSDoc for workingDir references --cap-drop ALL which is no longer managed by this class (it was part of the old lifecycle logic). This will confuse users who now create containers externally.

Suggestion: Simplify to focus on what the user needs to know:

/**
 * Working directory inside the container. Defaults to `"/tmp"`.
 *
 * `/tmp` is world-writable on standard base images, making it a safe default for
 * non-root users. If you specify a custom path, ensure it exists and is writable
 * by the configured `user`.
 */

yield OK
})
await sandbox.start()
const args = vi.mocked(streamProcess).mock.calls[0]![1]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: There's no unit test covering the custom user option, which is the only security-relevant configuration left in this class.

Suggestion: Add a test verifying custom user is passed through:

it('passes custom user to docker exec', async () => {
  const sandbox = new DockerSandbox({ containerId: 'c', user: 'root' })
  await sandbox.execute('x')

  const args = vi.mocked(streamProcess).mock.calls[0]![1]
  expect(args[args.indexOf('--user') + 1]).toBe('root')
})

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Assessment: Comment

This is a clean simplification that removes significant complexity. The "bring-your-own-container" approach is much easier to reason about.

Review Categories
  • Documentation: The workingDir TSDoc references --cap-drop ALL which is no longer managed by this class — will confuse users of the simplified API.
  • Testing: Unit tests use indexOf-based individual assertions instead of verifying the full streamProcess call args, and there's no coverage for the custom user option.
  • API Review: This is a breaking change to a public API export (strands-ts/sandbox/docker). Consider whether the needs-api-review label is appropriate.

The resulting implementation is refreshingly simple — 56 lines for a focused exec wrapper is the right level of abstraction.

@github-actions github-actions Bot removed the strands-running <strands-managed> Whether or not an agent is currently running label Jun 2, 2026
@gautamsirdeshmukh

Copy link
Copy Markdown
Contributor Author

Closing + will reopen against the monorepo (sdk-python)

This branch was previously deployed

1 inactive deployment
auto-approve — 90c22eae Deployed Jun 2, 2026 by gautamsirdeshmukh via Trigger Strands Review #1638
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants