-
Notifications
You must be signed in to change notification settings - Fork 89
fix(daemon): retry Anthropic stream aborted by transport (LUM-1537) #30586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ashleeradka
merged 2 commits into
main
from
devin/1778696525-lum-1537-anthropic-transport-abort-retry
May 13, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a non-Anthropic provider's own
createStreamTimeout()aborts the SDK call, the OpenAI/Gemini catch sites only preserveabortReasonfrom the external caller signal and otherwise wrap non-API aborts as aProviderErrorwithstatusCode === undefined; if that SDK reports the sameRequest was abortedtext, this new provider-agnostic predicate will retry the deterministic 30-minute timeout three more times instead of surfacing it. Anthropic rewrites its inner timeout before this point, but the other providers do not, so this should be scoped to the Anthropic/OpenRouter-Anthropic transport-abort shape or those catch sites should tag/rewrite inner timeouts first.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — confirmed and fixed in
55ad034.Walked through the catch-sites:
providers/openai/chat-completions-provider.ts:338-382— computesabortReasonfrom the externalsignal?.aborted, so when the innercreateStreamTimeoutfires (timing outtimeoutSignal, notsignal),abortReasonstaysundefined. The OpenAI SDK throwsAPIUserAbortError extends APIErrorwithstatus === undefinedandmessage === "Request was aborted.", so the catch falls into theOpenAI.APIErrorbranch and throwsProviderError("OpenAI API error (undefined): Request was aborted.", "openai", undefined, {})— no message rewrite. ❌ would have retried.providers/openai/responses-provider.ts:401-443— same shape,providerLabelsubstituted. ❌ would have retried.providers/gemini/client.ts:336-372— same shape,"Gemini API error (undefined): ...". ❌ would have retried.providers/openrouter/client.tsextends chat-completions-provider, so it inherits the OpenAI catch-site path. ❌ would have retried.providers/anthropic/client.ts:1417-1523— the only catch-site with theinnerTimeoutFiredcheck that rewrites the message to"Anthropic stream timed out after Xs (inner streamTimeoutMs)", ensuring inner-timeout failures don't match"Request was aborted". ✓ safe.Tightened the pattern to
/^anthropic api error:\s*request was aborted/iso it matches only the Anthropic catch-site's verbatim output. Non-Anthropic providers' aborted-stream errors (including their(undefined)parenthetical form) fall through to network-error classification, unchanged from before this PR.Added a regression test (
does NOT retry OpenAI/Gemini-shaped 'Request was aborted') that pins this — feeding"OpenAI API error (undefined): Request was aborted."throughRetryProviderconfirmscallCount === 1(zero retries).The right long-term fix is for the OpenAI/Gemini catch-sites to grow the same
innerTimeoutFireddistinction, at which point the pattern set here can be expanded to cover them. Out of scope for LUM-1537 since (a) there's no telemetry showing transport aborts on those providers in our fleet (1,344/4d is Anthropic-specific), and (b) it requires touching three more provider files plus their tests.