feat: add share_sandbox option to delegate_task - #8136
Closed
malaiwah wants to merge 1 commit into
Closed
Conversation
Allow subagents to reuse the parent's sandbox container instead of getting an isolated one. When share_sandbox=True, the child's run_conversation receives the parent's effective_task_id, so Docker creates no new container — the child operates in the same filesystem. Use case: explorer subagents that need access to the parent's workspace (source code, installed packages, created files) without the overhead of spinning up a new sandbox. Also fixes a pre-existing bug where the direct delegate_task call sites in run_agent.py were missing acp_command and acp_args parameters. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
Related to #16177 (merged, auto-shares terminal sandbox). This adds explicit user-facing opt-in via share_sandbox parameter. |
Contributor
|
Thanks for the contribution. This is an automated hermes-sweeper review; the requested behavior is already implemented on current main.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
share_sandboxboolean parameter todelegate_taskthat lets subagents reuse the parent's sandbox container instead of getting an isolated oneshare_sandbox=True, the child'srun_conversationreceives the parent'seffective_task_id, so the Docker backend creates no new container — the child operates in the same filesystemdelegate_taskcall sites inrun_agent.pywere missingacp_commandandacp_argsparametersUse case
Explorer/research subagents that need access to the parent's already-prepared workspace (source code cloned, packages installed, files created) without the overhead and delay of spinning up a new sandbox container.
Changes
tools/delegate_tool.py: Addedshare_sandboxto function signature, schema (top-level + per-task), and registry handler. Child system prompt notes shared sandbox when enabled.run_agent.py: Store_effective_task_idon the agent instance. Added missingacp_command/acp_argsto both directdelegate_taskcall sites.tests/tools/test_delegate.py: 4 new unit tests inTestShareSandboxclass. Fixed existing test that broke from thetask_idkwarg change.Test plan
tests/tools/test_delegate.py)share_sandbox=true→ subagent reads same file🤖 Generated with Claude Code