Silent failure when model output is truncated before tool call emission
What I was trying to do
I asked Claude Code to build a Python script that parses a directory of YAML config files and generates a self-contained HTML viewer. The task required Claude to first explore ~160 directories to understand the data structure, then write a large script.
What happened
After spending many turns reading files and understanding the data patterns, Claude said "Now I have all the data patterns. Let me build the script." — and then produced no tool call. No file was written. No error was shown.
I prompted it 3 times ("still working?", "shouldn't be this long", "DO IT") and each time Claude responded with text like "Yes! Writing the script now" or "You're right, sorry. Let me just write it" — but never actually emitted a Write/Edit tool call. It appeared to be working but was producing nothing.
After reviewing the conversation transcript, the assistant responses had stop_reason=None with empty thinking blocks and zero tool calls — suggesting the output was being truncated before the tool call could be emitted, likely because the generated script was too large for a single response.
The problem
This fails completely silently. From the user's perspective, Claude just appears stuck or lazy. There's no indication that an output limit was hit, no error message, and no automatic recovery (e.g., breaking the output into smaller chunks or retrying with a different strategy).
I'm aware there are ways to work around this — breaking the task into smaller pieces, asking Claude to write the file in sections, using subagents, etc. I eventually got the task done in a follow-up session by guiding the approach differently. But this was Claude's default behavior when faced with a large write — it chose to attempt one big output, failed silently, and then got stuck in a loop of promising to do it again. The user shouldn't need to know the internals to work around this.
Expected behavior
When a response is truncated before a tool call can be fully emitted, Claude Code should:
- Surface the failure to the user — e.g., "My response was too large to complete. Let me break this into smaller pieces."
- Auto-retry with a chunked approach — detect the truncation and re-attempt with a strategy like writing the file in sections
- At minimum, not claim to be doing work it isn't doing — the follow-up responses saying "Writing the script now!" with no actual tool call are the worst part of this experience
Environment
- Claude Code CLI
- The task involved generating a ~500+ line Python script with embedded HTML/CSS/JS
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗