.agents/references/sandbox-runtime-boundary.md
Use this reference for changes to sandbox session ownership, SandboxAgent preparation, manifests, capabilities, host-path materialization, snapshots, resume state, agent transitions, or cleanup.
The outer Runner owns agent turns, approvals, handoffs, tracing, session history, and RunState. A sandbox session owns the execution environment, workspace, processes, mounts, and provider-specific connection state. Do not move one layer's lifecycle into the other without defining resume and cleanup behavior for both.
SandboxRunConfig.session is caller-owned. The runner may configure and use it but must not delete or fully tear it down.SandboxRunConfig.client is runner-owned. Cleanup runs pre-stop hooks, persists snapshot-backed workspace state, stops and shuts down the session, deletes provider resources when required, and closes dependencies.SandboxAgent concurrency guards even when persistence or provider cleanup fails.SandboxAgent instance cannot be reused concurrently across runs because prepared capability tools and session state are bound to one live run. Clone or construct separate agents for concurrent work.Resolve the session source in this order: injected live session, resumable sandbox state carried by RunState, explicit SandboxRunConfig.session_state, then a newly created session. Manifest and snapshot inputs seed only a fresh session; they do not overwrite an injected or resumed workspace.
RunState sandbox data and explicit session_state represent provider connection or session state used to reconnect to existing work.SandboxAgent. Dynamic instructions and hooks should observe the public agent rather than an internal clone with implementation-only state.Agent.as_tool() run owns its own nested runner and sandbox lifecycle.LocalFile and LocalDir sources are host-side inputs. Resolve them against a trusted base directory, require explicit application-controlled extra_path_grants outside that base, and reject untrusted manifests that try to authorize their own host access.persist_workspace() include the workspace root, not arbitrary granted paths.Runner path so agent preparation, capability binding, persistence, and cleanup run together.docs/sandbox/guide.mddocs/sandbox/clients.mdsrc/agents/sandbox/runtime.pysrc/agents/sandbox/runtime_session_manager.pysrc/agents/sandbox/runtime_agent_preparation.pysrc/agents/sandbox/manifest.pysrc/agents/sandbox/materialization.pysrc/agents/sandbox/workspace_paths.pysrc/agents/sandbox/session/archive_extraction.pytests/sandbox/test_runtime.pytests/sandbox/test_runtime_agent_preparation.pytests/sandbox/test_session_state_roundtrip.pytests/sandbox/test_materialization.pytests/sandbox/test_extract.py