Skip to content

feat: add share_sandbox option to delegate_task - #8136

Closed
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:feat/delegate-share-sandbox
Closed

feat: add share_sandbox option to delegate_task#8136
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:feat/delegate-share-sandbox

Conversation

@malaiwah

Copy link
Copy Markdown
Contributor

Summary

  • Adds share_sandbox boolean parameter to delegate_task that lets subagents 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 the Docker backend creates no new container — the child operates in the same filesystem
  • 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

Use 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: Added share_sandbox to function signature, schema (top-level + per-task), and registry handler. Child system prompt notes shared sandbox when enabled.
  • run_agent.py: Store _effective_task_id on the agent instance. Added missing acp_command/acp_args to both direct delegate_task call sites.
  • tests/tools/test_delegate.py: 4 new unit tests in TestShareSandbox class. Fixed existing test that broke from the task_id kwarg change.

Test plan

  • 71 unit tests pass (tests/tools/test_delegate.py)
  • New tests verify: parent task_id passed when shared, None when not shared, prompt note appended, schema includes share_sandbox
  • End-to-end: parent creates file → delegates with share_sandbox=true → subagent reads same file

🤖 Generated with Claude Code

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>
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/delegate Subagent delegation backend/docker Docker container execution labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #16177 (merged, auto-shares terminal sandbox). This adds explicit user-facing opt-in via share_sandbox parameter.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This is an automated hermes-sweeper review; the requested behavior is already implemented on current main.

  • Member discussion already identified merged feat(terminal): collapse subagent task_ids to shared container #16177. Its implementation commit is f65177639acaee952015617c7fffef4f1b35ba90.
  • tools/terminal_tool.py:1123-1155 maps normal subagent task IDs to the shared "default" container, so delegated children already share the parent's workspace, packages, and filesystem.
  • tools/file_tools.py:1030-1031 and tools/code_execution_tool.py:641 use the same resolver, covering file and code-execution paths as well as terminal execution.
  • tools/delegate_tool.py:1874-1924 intentionally keeps a distinct child task ID for file-state coordination and TUI/subagent tracking; using the parent task ID directly would lose that separation without adding sandbox sharing.
  • tests/tools/test_shared_container_task_id.py:45-103 covers shared subagent lookup and the retained per-task isolation override for RL/benchmark environments.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/docker Docker container execution comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data tool/delegate Subagent delegation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants