[refactor] Make sandbox-agent orchestration readable#5264
Conversation
|
@mmabrouk is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🤖 The AI agent says: This draft is ready for structural review. Please focus on whether the new facade, setup, environment, turn, contract, policy, and event boundaries make the runtime easier to follow without changing lifecycle behavior. |
Context
The sandbox-agent engine had become difficult to change safely. Its 2,144-line entrypoint owned the public API, request policy, daemon setup, environment acquisition, session lifecycle, event routing, per-turn approval handling, tracing, usage, and teardown. A reviewer had to understand nearly the whole runtime to change one phase.
The surrounding modules also erased stable SDK and remote-sandbox contracts to
any, and the session pool mixed pure continuation identity policy with mutable lifecycle state.Changes
The entrypoint is now a 32-line public facade. Cold-run composition lives in a 59-line engine module, while environment setup, environment acquisition, per-turn execution, runtime contracts, connection policy, and session event routing have explicit owners.
Before:
After:
Continuation fingerprints and credential epochs now live in
session-identity.ts;session-pool.tsfocuses on mutable capacity, timers, checkout, parking, and teardown. Remote helpers use narrow filesystem and process ports. ACP compatibility payloads and usage JSON are narrowed at runtime instead of crossing the runner as unchecked values.No API, wire, or runtime behavior changes are intended. Production changes remain inside the runner.
How to review
sandbox_agent.tsandsandbox_agent/engine.tsto see the public surface and cold-run lifecycle.environment-setup.ts, thenenvironment.ts, to follow setup and session-scoped resource acquisition.run-turn.tsfor the per-turn prompt, approval, relay, tracing, usage, and continuity flow.runtime-contracts.ts,runtime-policy.ts, andsession-events.tsas the seams shared by those workflows.session-identity.ts, the smallersession-pool.ts, and the typed boundary changes in the helper modules.Tests / notes
pnpm run typecheckpnpm test(66 files, 1,015 tests)pnpm run build:extensiongit diff --check