Skip to content

Fix/interrupt claude code sdk#12

Merged
zxyao145 merged 2 commits intomainfrom
fix/interrupt-ClaudeCodeSdk
Feb 6, 2026
Merged

Fix/interrupt claude code sdk#12
zxyao145 merged 2 commits intomainfrom
fix/interrupt-ClaudeCodeSdk

Conversation

@zxyao145
Copy link
Owner

@zxyao145 zxyao145 commented Feb 6, 2026

No description provided.

  - keep reading ReceiveResponseAsync during cancellation to flush buffered messages
  - trigger InterruptAsync from cancellation callback instead of aborting the reader token
  - stop disposing the client inside ClaudeSdkClient.InterruptAsync so buffered output is not lost to the next query

(cherry picked from commit 2f1d4ec9a0cc27ce5741a10d6ff6afd3ae277485)
Signed-off-by: zxyao145 <zxyao145@gmail.com>
@zxyao145 zxyao145 merged commit 3c46b5c into main Feb 6, 2026
6 checks passed
Copy link

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

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: 8829c9a62a

ℹ️ 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 on lines +205 to +208
//
var interruptRequested = 0;
using var cancellationRegistration = cancellationToken.Register(() =>
{

Choose a reason for hiding this comment

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

P1 Badge Keep cancellation registration alive during streaming

The using var cancellationRegistration = cancellationToken.Register(...) is scoped to SendUserInput, so the registration is disposed as soon as the method returns. That means cancellations that happen while the caller is still streaming responses will never invoke InterruptAsync. Since you also switched the client calls to CancellationToken.None, this change effectively disables mid-stream cancellation, so long-running responses will continue to run even after the caller cancels. Consider keeping the registration alive for the duration of the stream (or passing the token through) so cancellation still interrupts the client.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments