Skip to content

feat(sdk): retry control-plane requests on Should-Retry, falling back to 429/502/503/504 - #1998

Merged
mishushakov merged 3 commits into
mainfrom
devin/1792434077-should-retry-header
Oct 23, 2026
Merged

mishushakov merged 3 commits into
mainfrom
devin/1792434077-should-retry-header

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The SDK now lets the server decide whether a control-plane API response can be retried, through the Should-Retry response header (added in e2b-dev/belt#4687). It still has a status-code fallback for responses that don't carry the header, such as errors from a load balancer in front of the E2B proxy. JS withRetry and Python RetryableTransport / AsyncRetryableTransport behave the same way.

Should-Retry present  → retry only if it is "true" (trimmed, case-insensitive); false/malformed → never, whatever the status
Should-Retry absent   → retry 429 / 502 / 503 / 504
retry delay           → Retry-After (delta-seconds) if valid, else exponential backoff with jitter (100 ms → 10 s)
  • Removed: REPLAYABLE_METHODS, REPLAYABLE_OPERATIONS, isReplayable / is_replayable and Python NETWORK_ERRORS. No method or path checks are left. RETRYABLE_STATUSES is now {429, 502, 503, 504} and applies only when the header is absent.
  • Network errors after the request was written are no longer retried at the request level. This covers dropped connections, ECONNRESET, the browser's opaque TypeError, and httpx ReadError / RemoteProtocolError. Without the allowlists the SDK can't tell whether a replay is safe.
  • Connection-setup failures are still retried. In JS, isRetryableFetchError(error) now means isConnectionError(error). In Python, ConnectionRetryTransport handles them.
  • Unchanged: the retries count, the request-timeout budget, single-attempt streaming bodies, and the undici connector retries.

Behavior changes:

  • A 429 without Retry-After and a 504 are now retried with backoff.
  • A 502/504 on create/append operations (e.g. POST /v2/sandboxes) is now retried too, so a load-balancer 502/504 that arrives after the backend already created the sandbox can leave a duplicate.
  • Should-Retry: false stops retries for any status.

Usage

No API change. retries still controls how many times the SDK retries:

await Sandbox.create({ retries: 3 }) // 503 with `Should-Retry: true` or without the header → retried; with `Should-Retry: false` → returned
Sandbox.create(retries=3)

Linear: SDK-395

Link to Devin session: https://app.devin.ai/sessions/47966a4990af4fc19daa97413e9ad2ab
Open in Devin Desktop: https://app.devin.ai/desktop/session/47966a4990af4fc19daa97413e9ad2ab?variant=devin
Requested by: @mishushakov

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@cla-bot cla-bot Bot added the cla-signed label Oct 19, 2026
@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 310b2b7

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

This PR includes changesets to release 3 packages
Name Type
e2b Minor
@e2b/python-sdk Minor
@e2b/code-interpreter-python Patch

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

@linear-code

linear-code Bot commented Oct 19, 2026

Copy link
Copy Markdown

SDK-395

devin-ai-integration[bot]

This comment was marked as resolved.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Package Artifacts

Built from f763e68. Download artifacts from this workflow run.

JS SDK (e2b@2.59.1-devin-1792434077-should-retry-header.0, with @e2b/dockerfile-utils@0.1.2-devin-1792434077-should-retry-header.0):

npm install ./e2b-dockerfile-utils-0.1.2-devin-1792434077-should-retry-header.0.tgz ./e2b-2.59.1-devin-1792434077-should-retry-header.0.tgz

CLI (@e2b/cli@2.22.4-devin-1792434077-should-retry-header.0):

npm install ./e2b-cli-2.22.4-devin-1792434077-should-retry-header.0.tgz

Code Interpreter JS SDK (@e2b/code-interpreter@2.9.1-devin-1792434077-should-retry-header.0):

npm install ./e2b-code-interpreter-2.9.1-devin-1792434077-should-retry-header.0.tgz

Desktop JS SDK (@e2b/desktop@2.5.1-devin-1792434077-should-retry-header.0):

npm install ./e2b-desktop-2.5.1-devin-1792434077-should-retry-header.0.tgz

Python SDK (e2b==2.59.0+devin.1792434077.should.retry.header, with e2b-dockerfile-utils==0.1.1+devin.1792434077.should.retry.header):

pip install ./e2b_dockerfile_utils-0.1.1+devin.1792434077.should.retry.header-py3-none-any.whl ./e2b-2.59.0+devin.1792434077.should.retry.header-py3-none-any.whl

Code Interpreter Python SDK (e2b-code-interpreter==2.11.3+devin.1792434077.should.retry.header):

pip install ./e2b_code_interpreter-2.11.3+devin.1792434077.should.retry.header-py3-none-any.whl

Desktop Python SDK (e2b-desktop==2.7.2+devin.1792434077.should.retry.header):

pip install ./e2b_desktop-2.7.2+devin.1792434077.should.retry.header-py3-none-any.whl

@devin-ai-integration
devin-ai-integration Bot added this pull request to stack #1999 October 19, 2026 18:41
@mishushakov
mishushakov marked this pull request as ready for review October 19, 2026 18:51
@mishushakov
mishushakov self-requested a review as a code owner October 19, 2026 18:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T18:53:55.047296Z 8f1344a Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

devin-ai-integration[bot]

This comment was marked as resolved.

claude[bot]

This comment was marked as resolved.

Comment thread packages/js-sdk/src/retry.ts
@devin-ai-integration devin-ai-integration Bot changed the title feat(sdk): retry control-plane requests only on Should-Retry: true feat(sdk): retry control-plane requests on Should-Retry, falling back to 429/502/503/504 Oct 22, 2026
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1792434077-should-retry-header branch from e0a0110 to 1bcf58b Compare October 22, 2026 14:12
@mishushakov

Copy link
Copy Markdown
Member

check all the issues above

devin-ai-integration Bot and others added 3 commits October 23, 2026 09:16
Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
… absent

Co-Authored-By: mish@e2b.dev <mish@e2b.dev>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1792434077-should-retry-header branch from 1bcf58b to 310b2b7 Compare October 23, 2026 09:17
@nalekseev-e2b

Copy link
Copy Markdown
Contributor

🚀

@mishushakov
mishushakov merged commit e514999 into main Oct 23, 2026
49 checks passed
@mishushakov
mishushakov deleted the devin/1792434077-should-retry-header branch October 23, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants