[BUG] Claude Code Stopping mid-execution using Haiku 4.5
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?
Use Case: Our use case here is driving iOS e2e tests on CI, running claude code in a headless prompt mode, integrating with mobile-mcp and taking screenshots of the active simulator, etc.
These premature exits are happening maybe in 50% of tests, with some tests needing 3-4 auto-resumes.
Issue occurs when abort signal check happens after empty assistantMessages check, causing premature exit instead of proper abort handling.
Key findings:
Abort signal checked too late (line 649 vs line 555 in query.ts)
APIUserAbortError returns without yielding messages
No validation for unexpectedly empty assistantMessages array
Includes reproduction scenario, code locations, and potential solutions.
Logs
Pre-execution stop - claude_output_1.json
Post-execution stop - claude_output_2.json
What Should Happen?
Claude should not stop execution
claude_output_1.json
Error Messages/Logs
See attached Logs
Steps to Reproduce
Claude Model
Haiku 4.5
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.30
Platform
Anthropic API
Operating System
Other
Terminal/Shell
Other
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗