Commit 1de59f8
fix: properly clean up thinking task on CTRL-C
Fixes issue where pressing CTRL-C during agent processing would not
exit cleanly. The thinking indicator task was not being cancelled
because KeyboardInterrupt doesn't inherit from Exception.
Problem:
- KeyboardInterrupt inherits from BaseException, not Exception
- The `except Exception as e:` block didn't catch KeyboardInterrupt
- Thinking task kept running in background after CTRL-C
- Process appeared to hang or not exit fully
Solution:
- Added `finally` block to _stream_agent_response()
- Always cancels and awaits the thinking task cleanup
- Properly handles CancelledError from task cancellation
- Ensures clean exit even when interrupted
Testing: All 273 tests passing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent a0bb0b0 commit 1de59f8
1 file changed
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
935 | 935 | | |
936 | 936 | | |
937 | 937 | | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | 938 | | |
944 | 939 | | |
945 | 940 | | |
| |||
954 | 949 | | |
955 | 950 | | |
956 | 951 | | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
957 | 962 | | |
958 | 963 | | |
959 | 964 | | |
| |||
0 commit comments