API Error: Claude's response exceeded the 32000 output token maximum
Asking for a whole file back — a long migration, a generated fixture, a full rewrite — fails outright instead of truncating. The fix is to stop asking for one enormous message.
Workaround verified
2 confirmations · 2 environments
- Applies through
- 2.1.216 – 2.1.220
- Last confirmed
- 2d ago
- Applies to
- Claude Code 2.1.216 – 2.1.220 (a limit, not a regression)
- Environments
- Large single-file rewrites, generated fixtures, bulk data output · All
- Severity
- Medium
Filed by struct.dev · Jul 18, 2026
Edit in place instead of printing the artifact
Let the agent apply changes with its edit tools rather than emitting the finished file into the conversation, and split generated artifacts across several turns. Both keep any single message well under the ceiling.
- 01Say what you want changed, not what you want printed. 'Update the file in place' routes through Edit and carries only a diff:
# Instead of "Rewrite src/schema.ts and show me the whole file" # Ask for "Update src/schema.ts in place. Don't print the file back; summarise what changed." - 02For genuinely large generated artifacts, ask for it in named sections across turns, written straight to disk.
- 03Add a standing rule so you stop rediscovering this:
## Output - Never print a whole file back into the conversation. Edit it in place and summarise. - Generate large fixtures section by section, writing each to disk as you go.
Fix applies to 2.1.216 – 2.1.220
Members' reports are attributed. Anonymous ones are counted separately.
Does it still happen?
What each release of Claude Code has been reported to do with this issue.
- 2.1.216Not yet tested— running Claude Code 2.1.216? Tell us below.
- 2.1.217Not yet tested— running Claude Code 2.1.217? Tell us below.
- 2.1.218Not yet tested— running Claude Code 2.1.218? Tell us below.
- 2.1.219Still affected — 1 report
- 2.1.220Still affected — 1 report
Why this happens
A task that asks for a large single output ends with:
API Error: Claude's response exceeded the 32000 output token maximum.Nothing is written to disk. It reproduces on 'rewrite this 2,000-line file and print it', on generating large fixture data, and on 'give me the full migration' prompts. Small edits to the same file are fine, which is what makes it confusing — the file size is not the trigger, the requested output size is.
Likely causeThe output-token ceiling applies to a single assistant message. Anything that asks the model to emit an entire large artifact in one turn hits it. Writing through the Edit tool doesn't, because the tool call carries a diff rather than the whole file.
Confirmed environments2
| Agent | Version | Model | OS | Framework | Outcome |
|---|---|---|---|---|---|
| Claude Code | 2.1.220 | Claude Sonnet 5 | Windows 11 | — | Reproduced |
| Claude Code | 2.1.219 | Claude Opus 5 | macOS 15.5 | — | Reproduced |
Approaches that failed1
Asking it to 'continue' after the error
There is no partial response to continue from — the message failed, so nothing was emitted. It starts over and hits the same ceiling.
vspaan · 2w ago
Other approaches that worked1
Edit in place, never print the file
The CLAUDE.md rule above. Hasn't recurred since. Also faster and much cheaper, because the file isn't round-tripping through the transcript.
struct.dev · 2w ago
Discussion · 1 comment
Strong evidence gets promoted into the record above.
Sign in to join the discussion, vote, and verify fixes.
Related pages
The useful mental model: the limit is on a single assistant message, not on the file or the session. Once that clicked, the fix is obvious — stop making the model the transport for the file contents.