Skip to content

feat(backend/copilot): enable E2B auto_resume and reduce safety-net timeout - #12397

Merged
majdyz merged 6 commits into
devfrom
otto/secrt-2118-e2b-auto-resume
Mar 13, 2026
Merged

feat(backend/copilot): enable E2B auto_resume and reduce safety-net timeout#12397
majdyz merged 6 commits into
devfrom
otto/secrt-2118-e2b-auto-resume

Conversation

@Otto-AGPT

Copy link
Copy Markdown
Contributor

Enable E2B auto_resume lifecycle option and reduce the safety-net timeout from 3 hours to 5 minutes.

Currently, if the explicit per-turn pause_sandbox_direct() call fails (process crash, network issue, fire-and-forget task cancellation), the sandbox keeps running for up to 3 hours before the safety-net timeout fires. With this change, worst-case billing drops to 5 minutes.

Changes

  • Add auto_resume: True to sandbox lifecycle config — paused sandboxes wake transparently on SDK activity
  • Reduce e2b_sandbox_timeout default from 10800s (3h) → 300s (5min)
  • Add e2b_sandbox_auto_resume config field (default: True)
  • Guard: auto_resume only added when on_timeout == "pause"

What doesn't change

  • Explicit per-turn pause_sandbox_direct() remains the primary mechanism
  • connect() / _try_reconnect() flow unchanged
  • Redis key management unchanged
  • No latency impact (resume is ~1-2s regardless of trigger)

Risk

Very low — auto_resume is additive. If it doesn't work as advertised, connect() still resumes paused sandboxes exactly as before.

Ref: https://e2b.dev/docs/sandbox/auto-resume
Linear: SECRT-2118


Co-authored-by: Zamil Majdy (@majdyz) zamil.majdy@agpt.co

…imeout

Add auto_resume: True to E2B sandbox lifecycle config so paused sandboxes
wake transparently on SDK activity. Reduce the safety-net timeout from
3 hours to 5 minutes — safe because the explicit per-turn pause_sandbox
call is the primary mechanism, and auto_resume ensures reliable wake-up
even with the shorter timeout.

This reduces worst-case billing from 3 hours to 5 minutes when the
explicit pause call fails (process crash, network issue, etc.).
@Otto-AGPT
Otto-AGPT requested a review from a team as a code owner March 13, 2026 07:37
@Otto-AGPT
Otto-AGPT requested review from Bentlybro and Pwuts and removed request for a team March 13, 2026 07:37
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Mar 13, 2026
@github-actions github-actions Bot added platform/backend AutoGPT Platform - Back end size/m labels Mar 13, 2026
@github-actions

github-actions Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

🔍 PR Overlap Detection

This check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early.

🔴 Merge Conflicts Detected

The following PRs have been tested and will have merge conflicts if merged after this PR. Consider coordinating with the authors.

🟢 Low Risk — File Overlap Only

These PRs touch the same files but different sections (click to expand)

Summary: 1 conflict(s), 0 medium risk, 12 low risk (out of 13 PRs with file overlap)


Auto-generated on push. Ignores: openapi.json, lock files.

@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 450ef806-eed5-420a-8614-96004b0200c2

📥 Commits

Reviewing files that changed from the base of the PR and between 27457ca and 3443b1f.

📒 Files selected for processing (3)
  • autogpt_platform/backend/backend/copilot/config.py
  • autogpt_platform/backend/backend/copilot/tools/e2b_sandbox.py
  • autogpt_platform/backend/backend/copilot/tools/e2b_sandbox_test.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • autogpt_platform/backend/backend/copilot/tools/e2b_sandbox_test.py
  • autogpt_platform/backend/backend/copilot/config.py
  • autogpt_platform/backend/backend/copilot/tools/e2b_sandbox.py
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: types
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
  • GitHub Check: Check PR Status

Walkthrough

This PR updates the e2b sandbox timeout configuration from 3 hours to 5 minutes, introduces SandboxLifecycle object construction for lifecycle management, enables auto_resume behavior based on timeout strategy, and upgrades the e2b dependency from version 2.0 to 2.15.2.

Changes

Cohort / File(s) Summary
Configuration Updates
autogpt_platform/backend/backend/copilot/config.py
Reduced default e2b_sandbox_timeout from 10800 to 300 seconds (5 minutes instead of 3 hours).
Sandbox Lifecycle Implementation
autogpt_platform/backend/backend/copilot/tools/e2b_sandbox.py
Added SandboxLifecycle import and object construction in get_or_create_sandbox, replacing inline lifecycle dict. Updated docstrings to reflect 5-minute timeout default and auto_resume behavior tied to on_timeout strategy.
Test Updates
autogpt_platform/backend/backend/copilot/tools/e2b_sandbox_test.py
Updated test expectations for lifecycle objects: auto_resume set to True for "pause" timeout strategy and False for "kill" strategy. Updated docstring to document auto_resume disabling behavior.
Dependency Version
autogpt_platform/backend/pyproject.toml
Upgraded e2b package constraint from ^2.0 to ^2.15.2.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/l, platform/blocks

Suggested reviewers

  • Swiftyos
  • kcze

Poem

🐰 With timeout whispers from three hours down to five,
The sandbox dances, keeping workflows alive,
Auto-resume springs to life with grace,
Lifecycle objects set the perfect pace!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: enabling E2B auto_resume and reducing the safety-net timeout from 3 hours to 5 minutes.
Description check ✅ Passed The description provides comprehensive detail about the changes, rationale, and risk assessment, directly relating to the changeset modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch otto/secrt-2118-e2b-auto-resume
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

10 minutes gives more headroom for users thinking between messages
while still being a 18x improvement over the previous 3-hour default.
e2b 2.15.2 introduces the lifecycle parameter (SandboxLifecycle TypedDict)
on AsyncSandbox.create(). Use the proper type instead of a plain dict to
satisfy pyright.
auto_resume has no cost and no downside — always enable it when
on_timeout is 'pause'. Removes the config field and uses
SandboxLifecycle constructor directly.
@github-project-automation github-project-automation Bot moved this from 🆕 Needs initial review to 👍🏼 Mergeable in AutoGPT development kanban Mar 13, 2026
@majdyz
majdyz added this pull request to the merge queue Mar 13, 2026
Merged via the queue into dev with commit 0264573 Mar 13, 2026
20 checks passed
@majdyz
majdyz deleted the otto/secrt-2118-e2b-auto-resume branch March 13, 2026 10:49
@github-project-automation github-project-automation Bot moved this from 👍🏼 Mergeable to ✅ Done in AutoGPT development kanban Mar 13, 2026
Bentlybro pushed a commit that referenced this pull request Apr 4, 2026
…imeout (#12397)

Enable E2B `auto_resume` lifecycle option and reduce the safety-net
timeout from 3 hours to 5 minutes.

Currently, if the explicit per-turn `pause_sandbox_direct()` call fails
(process crash, network issue, fire-and-forget task cancellation), the
sandbox keeps running for up to **3 hours** before the safety-net
timeout fires. With this change, worst-case billing drops to **5
minutes**.

### Changes
- Add `auto_resume: True` to sandbox lifecycle config — paused sandboxes
wake transparently on SDK activity
- Reduce `e2b_sandbox_timeout` default from 10800s (3h) → 300s (5min)
- Add `e2b_sandbox_auto_resume` config field (default: `True`)
- Guard: `auto_resume` only added when `on_timeout == "pause"`

### What doesn't change
- Explicit per-turn `pause_sandbox_direct()` remains the primary
mechanism
- `connect()` / `_try_reconnect()` flow unchanged
- Redis key management unchanged
- No latency impact (resume is ~1-2s regardless of trigger)

### Risk
Very low — `auto_resume` is additive. If it doesn't work as advertised,
`connect()` still resumes paused sandboxes exactly as before.

Ref: https://e2b.dev/docs/sandbox/auto-resume
Linear: SECRT-2118

---
Co-authored-by: Zamil Majdy (@majdyz) <zamil.majdy@agpt.co>
Bentlybro pushed a commit to Bentlybro/AutoGPT that referenced this pull request Apr 4, 2026
…imeout (Significant-Gravitas#12397)

Enable E2B `auto_resume` lifecycle option and reduce the safety-net
timeout from 3 hours to 5 minutes.

Currently, if the explicit per-turn `pause_sandbox_direct()` call fails
(process crash, network issue, fire-and-forget task cancellation), the
sandbox keeps running for up to **3 hours** before the safety-net
timeout fires. With this change, worst-case billing drops to **5
minutes**.

### Changes
- Add `auto_resume: True` to sandbox lifecycle config — paused sandboxes
wake transparently on SDK activity
- Reduce `e2b_sandbox_timeout` default from 10800s (3h) → 300s (5min)
- Add `e2b_sandbox_auto_resume` config field (default: `True`)
- Guard: `auto_resume` only added when `on_timeout == "pause"`

### What doesn't change
- Explicit per-turn `pause_sandbox_direct()` remains the primary
mechanism
- `connect()` / `_try_reconnect()` flow unchanged
- Redis key management unchanged
- No latency impact (resume is ~1-2s regardless of trigger)

### Risk
Very low — `auto_resume` is additive. If it doesn't work as advertised,
`connect()` still resumes paused sandboxes exactly as before.

Ref: https://e2b.dev/docs/sandbox/auto-resume
Linear: SECRT-2118

---
Co-authored-by: Zamil Majdy (@majdyz) <zamil.majdy@agpt.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/backend AutoGPT Platform - Back end size/m

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants