fix(agent): classify mid-response stream deaths as transient upstream failures#3394
Merged
Merged
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(agent): classify mid-response stream..." | Re-trigger Greptile |
… failures Claude Code surfaces an SSE stream that dies after content started as "API Error: Connection closed mid-response. The response above may be incomplete." classifyAgentError did not recognize that string (nor the transport-level "socket connection was closed" variants), so these transient transport failures fell through to agent_error and hard-failed the whole task run with a raw error message instead of being treated as retriable upstream failures. Generated-By: PostHog Code Task-Id: a04c4d02-9070-4e5d-9748-bfceb251e3fa
bcef67e to
5ecb99a
Compare
charlesvien
pushed a commit
to ricardo-leiva/code
that referenced
this pull request
Jul 13, 2026
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.
Problem
When the SSE stream dies after content has started streaming (like a gateway pod replaced mid-stream, cc surfaces it as:
classifyAgentErrordoesn't recognize this string (it only matchesterminated,Connection error, timeouts, and 429/5xx), so the failure is classified as a fatalagent_error: the whole cloud task run is marked failed and the user sees the raw transport error instead of the "upstream provider failed, please retry" messageChanges
API Error: … Connection closed mid-responseasupstream_stream_terminated.socket connection (was) closedvariants (wording differs across fetch implementations) the same way