Skip to content

Harden Claude stream interruption handling#1893

Open
juliusmarminge wants to merge 1 commit intomainfrom
t3code/claude-stream-interrupts
Open

Harden Claude stream interruption handling#1893
juliusmarminge wants to merge 1 commit intomainfrom
t3code/claude-stream-interrupts

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Apr 10, 2026

Split out from #1891.

Summary

  • preserve interrupted Claude turns separately from runtime stream failures
  • ignore ede_diagnostic-only results and mark interrupted tool results as declined
  • add regression coverage for interrupted Claude stream edge cases

Testing

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test

Note

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 interrupted instead of generic stream failures, using tagged ClaudeStream*Error types plus an interruptRequested flag.

Filters SDK-internal [ede_diagnostic] entries so they don’t surface as runtime errors (including is_error=false error results), and marks tool results that represent rejected tool use after interruptTurn as declined rather than failed.

Adds regression tests covering ede_diagnostic-only results, interrupted tool-result flows, and stream failures/abort messages after interruption; also tightens a stopSession assertion 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

  • Introduces ClaudeStreamInterruptedError and ClaudeStreamFailedError typed errors in ClaudeAdapter.ts to classify stream failures early, enabling differentiated downstream handling.
  • Adds interruptRequested flag to ClaudeSessionContext so that subsequent messages, tool results, and stream exits can be handled appropriately after interruptTurn is called.
  • Filters SDK diagnostic messages (containing [ede_diagnostic]) from user-facing error paths; these now complete turns as interrupted without emitting a runtime error.
  • Tool results arriving after an interrupt with rejection text are marked declined instead of failed.
  • Behavioral Change: stream exits that were previously surfaced as runtime errors may now resolve as interrupted when caused by a user-requested interrupt or SDK diagnostics.

Macroscope summarized 625da23.

- 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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 890ca798-7c07-455d-9eac-5001938198c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/claude-stream-interrupts

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

@github-actions github-actions bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Apr 10, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 10, 2026

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant