Auto-start CPU sandboxes for sessions#200
Conversation
Co-authored-by: Codex <codex@openai.com>
|
Claude finished @lewtun's task in 5m 57s —— View job PR Review: Auto-start CPU sandboxes for sessions0 P0, 3 P1 No blocking issues. The core mechanics — preload lifecycle, cancel-on-GPU-upgrade, auth on the teardown route, and the What I checked
P1 — Fire-and-forget task can be silently GC'd
asyncio.create_task(session_manager.teardown_sandbox(session_id))Python's asyncio docs warn explicitly: "Save a reference to the result of this function to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks." If the GC runs before the teardown coroutine finishes, the task is collected and the sandbox is not deleted — exactly what the sweep script is designed to catch, but this makes every pagehide a potential orphan. Standard fix: task = asyncio.create_task(session_manager.teardown_sandbox(session_id))
task.add_done_callback(lambda _: None) # keep strong ref alive until doneOr keep a module-level P1 —
|
Co-authored-by: Codex <codex@openai.com>
|
Claude finished @lewtun's task in 1m 38s —— View job PR Review: Auto-start CPU sandboxes for sessions (re-review on e19c139)0 P0 This re-review covers only the new commit ( What I checked
Status of previously flagged P1sThe three P1s from the prior review were not addressed in this commit. They stand as informational items for a follow-up; they are not re-flagged here. |
Co-authored-by: OpenAI Codex <codex@openai.com>
|
Claude finished @lewtun's task in 3m 24s —— View job PR Review: Auto-start CPU sandboxes for sessions (re-review on 683102a)
0 P0 This re-review covers only the new commit ( What I checked
Status of previously flagged P1sThe three P1s from the prior review ( |
|
Claude finished @lewtun's task in 3m 46s —— View job PR Review: Auto-start CPU sandboxes for sessions (re-review on 5543a34)
0 P0 This re-review covers only the new commit ( What I checked
Status of previously flagged P1sThe three P1s from the prior reviews ( |
Co-authored-by: OpenAI Codex <codex@openai.com>
|
Claude finished @lewtun's task in 2m 12s —— View job PR Review: Auto-start CPU sandboxes for sessions (re-review on 06a4326)
0 P0 This re-review covers only the new commit ( What I checked
Status of previously flagged P1sAll three prior P1s are resolved. No outstanding informational items. |
|
|
||
| For non-trivial scripts, develop and test in a sandbox before launching via hf_jobs: | ||
| sandbox_create → install deps → write script → test with small run → fix errors → launch via hf_jobs at scale | ||
| A private cpu-basic sandbox is already available for normal code execution in each session. For non-trivial scripts, develop and test there before launching via hf_jobs: |
Summary
This PR starts a private
cpu-basicsandbox automatically for each agent session so normal CPU code execution can usebash,read,write, andeditwithout requiring a manual sandbox approval first.It keeps approval in place for GPU and other non-default sandbox hardware, and it adds best-effort sandbox teardown on browser/tab close without deleting durable chat history.
Changes
cpu-basicsandbox preload for newly created and restored sessions.sandbox_createapproval-free for the default CPU sandbox while preserving manual approval for GPU tiers andcpu-upgrade.POST /api/session/{session_id}/sandbox/teardownand a frontendpagehidehook for best-effort browser-close cleanup.Verification
uv run --extra dev pytest tests/unit/test_sandbox_auto_start.py tests/unit/test_sandbox_private_spaces.py tests/unit/test_sandbox_already_active_message.py tests/unit/test_session_manager_persistence.pynpm run buildnpx eslint src/components/Layout/AppLayout.tsxFull
npm run lintstill reports existing unrelated lint issues inActivityStatusBar.tsx,agentStore.ts,main.tsx, andlogger.ts.