Repository navigation
Conversation
4 of 6 tasks
Open
5 tasks
A root sandbox can have depth-1 child sandboxes that share its policy and a subset of its providers. Users create them with sandbox create --parent; agents in a root manage them through MCP tools at openshell.local/mcp; host users reach the same tools through openshell mcp serve. Off by default (experimental_enable_child_sandboxes). Signed-off-by: patkraw <pkrawczuk@nvidia.com>
… exec Remove the wait tool, the background argument of exec, and the jobs module that ran them. The exec tool's description now tells the caller to start long work detached in the sandbox and check on it with later exec calls. The gateway keeps no job state and runs no job script in a child. The e2e test starts a detached command and collects its result. The docs page describes the steps in full. Signed-off-by: patkraw <pkrawczuk@nvidia.com>
patkraw
force-pushed
the
feat/4574-child-sandboxes/patkraw
branch
from
November 24, 2026 03:18
9b4334a to
5845890
Compare
This branch has not been deployed
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
Adds child sandboxes: a root sandbox can have depth-1 child sandboxes that use its policy and a subset of its providers, so an agent can run sub-agents in their own sandboxes. This is the implementation of RFC 0021 "Sandboxed Subagents", opened as a draft so the team can try the feature while the RFC is in review. It is off unless the operator sets
experimental_enable_child_sandboxes.Size note: GitHub overstates the removed lines.
crates/openshell-server/src/grpc/sandbox.rsreally has about 5,240 added and 98 removed (git diff --diff-algorithm=patience), and more than half of the added lines in this PR are tests.Related Issue
Closes #4574
The RFC pull request (#4721) also references #4574. If maintainers prefer a separate implementation issue, I will re-link this PR.
Changes
experimental_enable_child_sandboxes(defaultfalse) andmax_concurrent_children(default 10) ingateway.toml; read-onlySandbox.parentandSandbox.created_by;CreateSandboxRequest.parent. Records without a parent read as roots, so there is no migration.sandbox create --parent <root>andsandbox list --parent <root>;sandbox listshows aPARENTcolumn when a page holds a child.http://openshell.local/mcpinside each sandbox and forwards it to the gateway's new/mcpendpoint with the sandbox's session token; the agent holds no credential. Five tools (create_sandbox,list,exec,delete,logs) each run as the existing RPC through the normal gRPC stack, so authentication, authorization, rate limits and interceptors apply. A sandbox caller reaches only these methods, only through/mcp, and only for its own children.execruns in the foreground for at most 45 seconds. Its description tells the caller to start longer work detached in the sandbox and check on it with laterexeccalls. The gateway keeps no job state./mcpaccepts user callers, andopenshell mcp serveis a stdio bridge that reuses the CLI login and connection.openshell.ai/agent-usable=true; it cannot name an image.docs/how-it-works/sandboxes/child-sandboxes.mdx, the gateway configuration reference, the templates page and the CLI skill.OPENSHELL_EXPERIMENTAL_CHILD_SANDBOXES=1 mise run gateway:dockerturns the feature on in the dev gateway.How to try it
docs/4574-child-sandboxes-examples/patkrawfrompatkraw/OpenShell. It is this PR's first commit plus tutorials and runnable scenarios, which are not part of this PR.examples/child-sandboxes/tutorials, starting with00-setup.md. Seven short tutorials cover the CLI, MCP from inside a root, background jobs, templates, policy and provider sync, and MCP from the host. The tutorials branch still has the earlierwaittool; its background-jobs tutorial does not match this PR until it is updated.experimental_enable_child_sandboxes = trueunder[openshell.gateway]and restart it.openshell workspace member add --workspace <ws> --subject <user> --role user.Design notes: long-running work
This PR ships the "plain" approach: no
waittool and nobackgroundargument. The caller starts long work detached withsetsid, writes output and the exit code to files, and reads them with laterexeccalls. An earlier version of this PR had gateway-managed jobs ("managed"); the second commit removes them, about 900 lines, so the gateway keeps no job state and runs no job script in a child.Two experiments with lead agents driving child sandboxes compared the approaches. Both reports are on the tutorials branch.
The
execdescription is the short text from the experiments.docs/how-it-works/sandboxes/child-sandboxes.mdxhas the full steps, which weaker models may need in their instructions. A skill with those steps is a possible follow-up.To do before merge
mainfor development builds after this PR was opened. A child gets a copy of its parent's policy, and that path has not been run with a parent that uses a Cedar policy.Known limits
execthat reaches its timeout is reported as timed out but keeps running until the child is deleted (existingExecSandboxbehaviour, ExecSandbox processes keep running after execution_timeout and after the client disconnects #5042). Detached work depends on a process outliving its exec; a future cleanup of exec'd processes needs a detach option first.ps./mcp.Testing
Run on a macOS arm64 development machine, on both commits rebased onto
mainat152c59d31:cargo clippy --workspace --all-targets -- -D warningsand the same fore2e/rust: clean.cargo fmt --all -- --check: clean.mise run e2e:rust:child-sandboxes(Docker gateway): 6 of 6 passed. One test starts a detached command through MCP and collects its result.cargo testforopenshell-server,openshell-cli,openshell-sdk,openshell-supervisor-network,openshell-coreandopenshell-gateway-interceptors:openshell-serverpasses. The failures are tests that also fail onmainon this machine: 4 inopenshell-core(e2fsprogstool checks that time out), 8 inopenshell-supervisor-networkproxy tests, theopenshell-clisandbox-create tests that wait on helper processes, and threeprovider_readiness_update_polls_later_targets_*timing tests that are intermittent onmain.waittool was removed.Not run: Linux-only tests (Landlock, seccomp), the Podman, Kubernetes and VM lanes, and the PostgreSQL multi-replica tests. CI is expected to cover the first.
Checklist