Skip to content

autoresume: lifecycle component in sdk#1146

Merged
matthewlouisbrockman merged 49 commits intomainfrom
lifecycle-in-sdk
Mar 4, 2026
Merged

autoresume: lifecycle component in sdk#1146
matthewlouisbrockman merged 49 commits intomainfrom
lifecycle-in-sdk

Conversation

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor

@matthewlouisbrockman matthewlouisbrockman commented Feb 19, 2026

Implements the lifecycle prop on Sandbox.create, taking over and deprecating the beta_pause functionality.

Currently supports:

  • on_timeout: kill (default) | pause. Controls what should happen to the sandbox when it hits end of life. Pause allows for resuming
  • auto_resume: False (default) | True. Whether the sandbox should autoresume on traffic

Intended for additional functionality as we update the backend to support additional props. Blocked from deploying until the API and client-proxy are deployed but for pre-approval.

(Meant to be extended later as add more capabilities to the API)


Note

Medium Risk
Changes the API contract and request payload shape for sandbox auto-resume and alters lifecycle/timeout behavior mapping, which could break older integrations if backend/client versions are mismatched.

Overview
Adds a new lifecycle configuration on Sandbox.create (JS + Python) to control what happens at timeout (kill vs pause) and whether paused sandboxes auto-resume on traffic (auto_resume).

Deprecates betaPause/beta_pause and the JS autoPause create option in favor of the new lifecycle semantics, updates connect/pause call paths accordingly, and expands tests to cover resume-on-connect and auto-resume behaviors.

Updates the OpenAPI contract and generated clients so autoResume is now an object with an enabled: boolean flag (removing the previous policy enum), and bumps SDK versions via a changeset.

Written by Cursor Bugbot for commit 515f9b7. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: 515f9b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Minor
e2b Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 19, 2026

Package Artifacts

Built from dc25c40. Download artifacts from this workflow run.

JS SDK (e2b@2.13.2-lifecycle-in-sdk.0):

npm install ./e2b-2.13.2-lifecycle-in-sdk.0.tgz

CLI (@e2b/cli@2.8.1-lifecycle-in-sdk.0):

npm install ./e2b-cli-2.8.1-lifecycle-in-sdk.0.tgz

Python SDK (e2b==2.14.1+lifecycle-in-sdk):

pip install ./e2b-2.14.1+lifecycle.in.sdk-py3-none-any.whl

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

matthewlouisbrockman commented Feb 19, 2026

adding the changeset should not have caused tests to fail, tests seem a bit flaky for some reason (not related to this PR i don't think)

@matthewlouisbrockman matthewlouisbrockman changed the title (draft) lifecycle in sdk lifecycle in sdk Feb 21, 2026
@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1e0ba8559

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/js-sdk/src/sandbox/sandboxApi.ts
@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

got the issues - the end to end tests now pass on staging / fail on prod (expected; client proxy not live on prod yet so should fail)

Comment thread packages/js-sdk/src/sandbox/sandboxApi.ts Outdated
"""


def get_auto_resume_policy(lifecycle: Optional[SandboxLifecycle]) -> Optional[str]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just do this inline, no need for another function

assert False, "Sandbox not found"


def test_lifecycle_auto_resume_policy_mapping():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this

Copy link
Copy Markdown
Member

@mishushakov mishushakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved but:

  • unnecessary function get_auto_resume_policy which we don't have in JS.
  • i am confused you'd call auto_resume policy "any" - it's too vague, most people won't be able to infer the meaning of the setting (I know it's only on backend, but still).

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

approved but:

  • unnecessary function get_auto_resume_policy which we don't have in JS.
  • i am confused you'd call auto_resume policy "any" - it's too vague, most people won't be able to infer the meaning of the setting (I know it's only on backend, but still).

secure: opts?.secure ?? true,
allow_internet_access: opts?.allowInternetAccess ?? true,
network: opts?.network,
...(autoPause !== undefined ? { autoPause } : {}),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditional autoPause !== undefined is always true

Low Severity

The autoPause variable is computed as lifecycle.onTimeout === 'pause', which always produces a boolean — never undefined. The conditional autoPause !== undefined on the spread is therefore always true, making the ternary dead code. This was likely written by analogy with the autoResumePolicy check below (where undefined IS a real possibility), but it's misleading here since a reader might incorrectly assume there's a path where autoPause is intentionally excluded from the body.

Additional Locations (1)

Fix in Cursor Fix in Web

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

approved but:

  • unnecessary function get_auto_resume_policy which we don't have in JS.
  • i am confused you'd call auto_resume policy "any" - it's too vague, most people won't be able to infer the meaning of the setting (I know it's only on backend, but still).

unnecessary function get_auto_resume_policy which we don't have in JS. - getting rid of that guy, ghost code that removed it everywhere else but left in the function

auto_resume policy "any" - - originally referred to what sort of traffic to resume. lemme see how painful it is to change it now that most of the API changes are in.

Comment thread packages/python-sdk/e2b/sandbox_async/sandbox_api.py Outdated
@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

plan's it goes to any|http|envd|off eventually so the any | off for now is awkawrd but forward extensible I think

autoResume?: {
policy: 'any' | 'off'
}
} = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant type intersection for already-defined schema field

Low Severity

The type intersection & { autoResume?: { policy: 'any' | 'off' } } on the body variable is redundant because components['schemas']['NewSandbox'] already includes autoResume?: components["schemas"]["SandboxAutoResumeConfig"] which resolves to exactly { policy: "any" | "off" }. This adds unnecessary type complexity and misleadingly implies the generated schema doesn't support autoResume, when it already does.

Fix in Cursor Fix in Web

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

return None

auto_resume = lifecycle.get("auto_resume")
return "any" if auto_resume else "off"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer-acknowledged function still present after agreed removal

Low Severity

The get_auto_resume_policy helper function was explicitly flagged for removal/inlining in the PR review, and the author acknowledged they would remove it, but it remains in the final diff along with its duplicated tests. The JS SDK inlines the equivalent logic directly in createSandbox, creating an unnecessary asymmetry between the two SDKs. The function is only a few lines and the logic is simple enough to inline at the two call sites in sandbox_async/sandbox_api.py and sandbox_sync/sandbox_api.py.

Additional Locations (2)

Fix in Cursor Fix in Web

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

staging not deployed yet so new API not up

@matthewlouisbrockman
Copy link
Copy Markdown
Contributor Author

Sticking with the developer preview while cache issue and timeout parameter decision pending.

@matthewlouisbrockman matthewlouisbrockman merged commit 7027f36 into main Mar 4, 2026
23 checks passed
@matthewlouisbrockman matthewlouisbrockman deleted the lifecycle-in-sdk branch March 4, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request Improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants