Harden Claude stream interruption handling#1893
Conversation
- preserve interrupted Claude turns separately from runtime failures - ignore ede_diagnostic-only results and mark interrupted tool results as declined - add regression coverage for interrupted stream edge cases Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This PR hardens error handling in the Claude adapter to correctly distinguish between user-initiated interruptions and actual failures, avoiding false error reports and marking interrupted tools appropriately. Changes are self-contained with comprehensive tests, and the author is the file's original maintainer. You can customize Macroscope's approvability policy. Learn more. |
Split out from #1891.
Summary
ede_diagnostic-only results and mark interrupted tool results as declinedTesting
bun fmtbun lintbun typecheckbun run testNote
Medium Risk
Changes core Claude runtime turn/stream error classification, which can affect how sessions and tool calls are marked completed/failed/interrupted. Risk is moderate due to new branching around interrupts/diagnostics and updated tool-result status mapping.
Overview
Hardens Claude stream/turn error handling so user-initiated interrupts and SDK aborts are treated as
interruptedinstead of generic stream failures, using taggedClaudeStream*Errortypes plus aninterruptRequestedflag.Filters SDK-internal
[ede_diagnostic]entries so they don’t surface as runtime errors (includingis_error=falseerror results), and marks tool results that represent rejected tool use afterinterruptTurnasdeclinedrather thanfailed.Adds regression tests covering ede_diagnostic-only results, interrupted tool-result flows, and stream failures/abort messages after interruption; also tightens a
stopSessionassertion and slightly standardizes Claude provider probe error messages.Reviewed by Cursor Bugbot for commit 625da23. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Harden Claude stream interruption handling to distinguish interrupted, diagnostic, and failed states
ClaudeStreamInterruptedErrorandClaudeStreamFailedErrortyped errors inClaudeAdapter.tsto classify stream failures early, enabling differentiated downstream handling.interruptRequestedflag toClaudeSessionContextso that subsequent messages, tool results, and stream exits can be handled appropriately afterinterruptTurnis called.[ede_diagnostic]) from user-facing error paths; these now complete turns as interrupted without emitting a runtime error.declinedinstead offailed.interruptedwhen caused by a user-requested interrupt or SDK diagnostics.Macroscope summarized 625da23.