[BUG] Claude Code consumes provider deltas after cancellation
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
During a streaming tool call, a SIGINT/cancellation boundary is crossed. Claude Code still consumes provider deltas that arrive after cancellation and after the terminal stream state.
Severity / performance impact: High. Accepting deltas after cancellation lets stale stream data mutate tool-call state after the user stop boundary. That can trigger extra requests, stale tool results, and wasted paid model/API credits instead of stopping cleanly.
The reproduction uses a local deterministic provider, so no external model behavior or provider outage is required.
What Should Happen?
After SIGINT/cancellation, Claude Code should ignore any later provider deltas for the interrupted message and should not apply them to the active tool call state.
Error Messages/Logs
Steps to Reproduce
Standalone reproduction
Prerequisites: Docker, Python 3, and the GitHub CLI (gh) for the clone command below. The linked reproducer is self-contained and uses only Python standard-library modules plus Docker. It builds the affected CLI version from the public upstream package/release source and starts a local mock provider; it does not require this repository or any private fuzzing harness. The Docker run is limited to 2 CPUs and 4 GiB RAM by default.
This SIGINT-timed reproduction can be timing-sensitive; if it prints NOT_REPRODUCED, rerun the same command once before concluding the target is unaffected.
Complete self-contained reproducer: https://gist.github.com/N0zoM1z0/e2118ffc21e6d695626a4d1724718b96
The Gist contains claude-late-provider-delta-after-cancel.reproduce.py. Download and run:
gh gist clone e2118ffc21e6d695626a4d1724718b96 claude-late-provider-delta-after-cancel-reproducer
cd claude-late-provider-delta-after-cancel-reproducer
python3 claude-late-provider-delta-after-cancel.reproduce.py
To reuse an already-built local image:
python3 claude-late-provider-delta-after-cancel.reproduce.py --skip-build
Key output from a local run against the affected version:
process_exit=143
provider_requests=65
tool_result_counts={'edit_1': 63}
late_stream_events_after_stop=64
REPRODUCED
Claude Model
Other
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Code 2.1.168
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Non-interactive/CI environment
Additional Information
The scenario is intentionally minimal: it controls only the provider stream and local interruption/cancellation events needed to reproduce the behavior.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗