Skip to content

fix(server): stopping a Claude turn no longer surfaces a raw stream error - #5162

Open
abcdmku wants to merge 2 commits into
pingdotgg:mainfrom
abcdmku:cluade-interupt-fix
Open

fix(server): stopping a Claude turn no longer surfaces a raw stream error#5162
abcdmku wants to merge 2 commits into
pingdotgg:mainfrom
abcdmku:cluade-interupt-fix

Conversation

@abcdmku

@abcdmku abcdmku commented Aug 1, 2026

Copy link
Copy Markdown

The interrupt bug will be fixed with the new ClaudeAdapterV2 in #2829. Fixes are here and here. Since that PR has been open for awhile I figured I'd open a request for the current ClaudeAdapter:

What Changed

Stopping a Claude turn no longer surfaces a raw runtime error. interruptTurn records the stop request on the session context, and both places that classify how a turn ended (handleStreamExit for stream failures, handleResultMessage for error results like ede_diagnostic) treat what follows as an interruption, completing the turn with a graceful message. The flag resets on turn start and completion. Includes a test for each path.

Why

The adapter inferred interruption by matching error text against known phrases, so any stop producing an unrecognized message was recorded as failed with a runtime error (#4713, #3836). Claude is the only provider with this problem: the other adapters get typed stop signals, while the Claude SDK's interrupt() returns nothing and the turn ends with an arbitrary error. Tracking intent is the approach Grok already uses.

original-test

After fix:
fix-test

Thread before/after:
before-after

Verified with
vp test run apps/server/src/provider/Layers/ClaudeAdapter.test.ts (64 passed),
pnpm run tc,
and a manual test for the photos above

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (none)

Note

Medium Risk
Changes turn-completion and error classification in the legacy Claude adapter on user stop; behavior is scoped to explicit interrupts but affects runtime events the UI relies on.

Overview
When a user stops a Claude turn, the adapter now records intent instead of inferring interruption only from error text.

interruptTurn adds the target turn id to interruptedTurnIds on the session context before calling the SDK interrupt(). handleResultMessage and handleStreamExit then treat a non-success result or stream failure for that turn as interrupted, completing with a graceful message and not emitting runtime.error. The set is cleared when a turn completes.

Tests cover error-result and stream-failure paths after a user stop.

Reviewed by Cursor Bugbot for commit 1cb6a8f. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix Claude turn stops to emit interrupted instead of surfacing a raw stream error

  • Adds an interruptedTurnIds set to ClaudeSessionContext to track turns the user explicitly stopped.
  • When a result message with a non-success subtype arrives for an interrupted turn, the turn completes as interrupted rather than failed, suppressing the runtime.error event.
  • When the stream fails after a user-initiated interrupt, the turn also completes as interrupted with the message 'Claude runtime interrupted.' instead of emitting a runtime.error.
  • interruptTurn now records the target turn ID before calling query.interrupt(), so subsequent result and stream-exit handlers can detect the interruption correctly.

Macroscope summarized 1cb6a8f.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

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 Plus

Run ID: 6ee35401-c9d9-4366-abe1-1f9eaa1ed81c

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd3dfb0c5c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/provider/Layers/ClaudeAdapter.test.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 092f68d

Straightforward bug fix that prevents raw stream errors from being surfaced when users intentionally stop a Claude turn. The implementation tracks interrupted turns and treats their errors as expected interruptions. Changes are limited in scope with comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

@abcdmku
abcdmku force-pushed the cluade-interupt-fix branch from 092f68d to 1cb6a8f Compare August 1, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant