Repository navigation
fix(sandbox): kill E2B sandboxes at timeout instead of pausing them - #4598
Closed
hemildesai wants to merge 1 commit into
Closed
hemildesai wants to merge 1 commit into
hemildesai wants to merge 1 commit into
Conversation
The E2B provider never set the SDK's lifecycle. Newer SDKs then leave
autoPause unset and let the server decide, and some E2B-compatible
servers default to pausing timed-out sandboxes, which keeps them around
until someone deletes them. Pass lifecycle={"on_timeout": "kill"} on
create (accepted by every SDK in the declared range, e2b>=2.36), which
sends autoPause=false.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Hemil Desai <[email protected]>
hemildesai
added a commit
that referenced
this pull request
Oct 14, 2026
E2B 2.42+ (including the locked 2.46) sends no lifecycle fields unless the caller sets them, and AgentENV then pauses timed-out sandboxes without auto-resume and never evicts them, so crashed or cancelled runs leak paused VMs. Default create.auto_resume to false, which sends kill-on-timeout explicitly; null keeps the SDK/server default and is documented as unsafe on AgentENV. Folds in #4598. Review follow-ups: update the timeout/close wording and config snippet in the docs and provider README, describe the post-resume minimum timeout as an operator setting counted from the resume, note the 410 during pause/resume and that connect() resets the timeout to 300 s, pin the AgentENV link, and add a real-SDK test that status sends only the control-plane GET. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Hemil Desai <[email protected]>
7 tasks done
Contributor
Author
|
Folded into #3757 (ba72878), which now defaults |
hemildesai
added a commit
that referenced
this pull request
Nov 2, 2026
E2B 2.42+ (including the locked 2.46) sends no lifecycle fields unless the caller sets them, and AgentENV then pauses timed-out sandboxes without auto-resume and never evicts them, so crashed or cancelled runs leak paused VMs. Default create.auto_resume to false, which sends kill-on-timeout explicitly; null keeps the SDK/server default and is documented as unsafe on AgentENV. Folds in #4598. Review follow-ups: update the timeout/close wording and config snippet in the docs and provider README, describe the post-resume minimum timeout as an operator setting counted from the resume, note the 410 during pause/resume and that connect() resets the timeout to 300 s, pin the AgentENV link, and add a real-SDK test that status sends only the control-plane GET. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Hemil Desai <[email protected]>
hemildesai
added a commit
that referenced
this pull request
Nov 2, 2026
E2B 2.42+ (including the locked 2.46) sends no lifecycle fields unless the caller sets them, and AgentENV then pauses timed-out sandboxes without auto-resume and never evicts them, so crashed or cancelled runs leak paused VMs. Default create.auto_resume to false, which sends kill-on-timeout explicitly; null keeps the SDK/server default and is documented as unsafe on AgentENV. Folds in #4598. Review follow-ups: update the timeout/close wording and config snippet in the docs and provider README, describe the post-resume minimum timeout as an operator setting counted from the resume, note the 410 during pause/resume and that connect() resets the timeout to 300 s, pin the AgentENV link, and add a real-SDK test that status sends only the control-plane GET. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Hemil Desai <[email protected]>
yaoyu-33
pushed a commit
to yaoyu-33/Gym
that referenced
this pull request
Nov 2, 2026
* feat(sandbox): enable AgentENV auto-pause and resume Expose an optional coupled pause/resume lifecycle policy, enable it in the AgentENV profile, and query control-plane status without waking paused sandboxes. Cover SDK request serialization and document the server-side resume timeout floor. Signed-off-by: Hemil Desai <[email protected]> * docs(sandbox): shorten lifecycle configuration comments Signed-off-by: Hemil Desai <[email protected]> * fix(sandbox): keep AgentENV benchmark config out of scope Signed-off-by: Hemil Desai <[email protected]> * fix(sandbox): kill E2B sandboxes at timeout by default E2B 2.42+ (including the locked 2.46) sends no lifecycle fields unless the caller sets them, and AgentENV then pauses timed-out sandboxes without auto-resume and never evicts them, so crashed or cancelled runs leak paused VMs. Default create.auto_resume to false, which sends kill-on-timeout explicitly; null keeps the SDK/server default and is documented as unsafe on AgentENV. Folds in NVIDIA-NeMo#4598. Review follow-ups: update the timeout/close wording and config snippet in the docs and provider README, describe the post-resume minimum timeout as an operator setting counted from the resume, note the 410 during pause/resume and that connect() resets the timeout to 300 s, pin the AgentENV link, and add a real-SDK test that status sends only the control-plane GET. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Hemil Desai <[email protected]> * fix(sandbox): send the E2B lifecycle on the REST create path With create.custom_extension_params set, the provider creates through POST /sandboxes, which sent no lifecycle. Sandboxes created that way (for example sandbank opt-ins) therefore missed the kill-on-timeout default and could stay paused on AgentENV. Send the same autoPause and autoResume fields the SDK create sends, and test both paths against the real SDK serialization. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Hemil Desai <[email protected]> * test(sandbox): isolate real-SDK E2B tests and cover a deleted sandbox The real-SDK lifecycle and status tests relied on an earlier test to install Gym's transport; run alone they would reach the real E2B API. Each now installs the transport itself. Add a 404 case showing that a sandbox killed at its timeout reads STOPPED through the real SDK. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Hemil Desai <[email protected]> --------- Signed-off-by: Hemil Desai <[email protected]> Co-authored-by: Hemil Desai <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
What changed and why
The E2B provider never set the SDK's
lifecycleonAsyncSandbox.create. Newer E2B SDKs (seen with 2.53.1) then send noautoPauseat all and leave the timeout action to the server. Some E2B-compatible servers default to pausing a sandbox when its timeout expires. A paused sandbox is not reaped, so a sandbox whose client crashed or abandoned it stays around indefinitely, holding snapshot storage, instead of being deleted at its TTL.Older SDKs (2.36, 2.46) sent
autoPause=falseby default, so this is a behaviour change that comes from upgrading the SDK, not from Gym.The provider now passes
lifecycle={"on_timeout": "kill"}on create, which sendsautoPause=falseon every SDK in the declared range (e2b>=2.36.0,<3.0.0). Normal runs are unaffected, because Gym deletes its own sandboxes; this only changes what happens to sandboxes that reach their timeout.Issue: none filed. This is a small fix found while load-testing E2B-compatible sandboxes.
Validation
test_sandboxes_are_killed_not_paused_at_timeout: asserts the create kwargs carrylifecycle={"on_timeout": "kill"}. It fails without the change and passes with it.lifecycleagainstAsyncSandbox.create. I also checked directly thatlifecyclebinds on e2b 2.36.0, 2.46.0 and 2.53.1.test_e2b_provider.pyandtest_e2b_build.py: 136 passed with the locked e2b 2.46.0.pre-commit run --all-files: passed.Rollout evidence
Against a live E2B-compatible gateway, I created two sandboxes with a 60 s timeout through the provider with this change and left them alone. Both were gone at 95 s:
GETreturned 404, and neither appeared in the paused listing. Without the change, sandboxes created the same way were still listed as paused hours after their timeout.Compatibility
No config or API change. Sandboxes that reach their timeout are now always killed rather than left to the server's default. The provider has no pause or resume support, so nothing in Gym depended on the paused state.
Related: #4597 (newer SDK transport keywords).
🤖 Generated with Claude Code