[BUG] Claude Code returns tool-result state 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?
A tool call is partially streamed, then SIGINT/cancellation is delivered. Claude Code still returns tool-result state for the interrupted call after the cancellation boundary. The reproducer verifies the post-cancellation tool-result state; it does not claim an independently verified filesystem side effect.
The reproduction uses a local deterministic provider, so no external model behavior or provider outage is required.
Severity / performance impact: High. Cancellation should be the user stop boundary; returning stale tool-result state after that boundary can keep the agent spending compute/API credits after the user tried to stop it.
What Should Happen?
After cancellation, Claude Code should drop the interrupted tool call and should not return tool-result state for that response.
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/27fa2d22d047af17c88231ce1418b69d
The Gist contains claude-tool-executes-after-cancel.reproduce.py. Download and run:
gh gist clone 27fa2d22d047af17c88231ce1418b69d claude-tool-executes-after-cancel-reproducer
cd claude-tool-executes-after-cancel-reproducer
python3 claude-tool-executes-after-cancel.reproduce.py
To reuse an already-built local image:
python3 claude-tool-executes-after-cancel.reproduce.py --skip-build
Key output from a local run against the affected version:
process_exit=143
provider_requests=57
tool_result_counts={'edit_cancel_1': 55}
late_stream_events_after_stop=0
tool_result edit_cancel_1: observed=55 expected>=1
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 ↗