[Bug] Write tool silently fails when tool_use truncated by max_tokens limit
Bug Description
Title: Write tool silently fails with "missing content" when tool_use hits max_tokens limit (hard 8k output ceiling)
Body:
Reproducible bug in Claude Code where Write tool invocations with large content parameters fail with InputValidationError: The required parameter 'content' is missing, even though the model is correctly attempting to pass content.
Root cause (verified from session jsonl): assistant responses have an 8000 output token ceiling. When the model generates a large content parameter inside a tool_use block, it can hit stop_reason=max_tokens before the content field is emitted. The API closes out the tool_use block with file_path only, and the harness rejects it as missing required param.
Evidence from session 2fa0be29-8f59-413b-89a0-ae522a8b9bd9 (2026-04-08):
- Successful EN Write, 18 077 chars:
stop_reason=tool_use,output_tokens=7 900 - 11 consecutive failures on Ukrainian translation (~18 000 chars, ~30 000 tokens due to Cyrillic BPE density): all
stop_reason=max_tokens,output_tokens=8 000 - A diagnostic
Write(content="test")between failures succeeded → rules out file/encoding/tool bugs - Retry loop makes it worse (context grows, budget unchanged)
Expected behavior (at least one of):
- Surface the real error to the model: "tool_use truncated by max_tokens — retry with smaller content or use Edit for partial updates" instead of generic "missing content"
- Auto-suggest chunking: harness could detect
stop_reason=max_tokensinside tool_use and provide actionable guidance - Allow
Writeto streamcontentacross multiple turns / raise output ceiling for tool_use blocks - Client-side heuristic: warn model when file target size exceeds safe threshold
User impact: especially bad for non-English content (Cyrillic, CJK) where token density is 3× English — files that "look normal" in characters blow the budget. User ends up in frustrating retry loops until they manually instruct chunking.
Environment Info
- Platform: win32
- Terminal: windows-terminal
- Version: 2.1.96
- Feedback ID: 1b2d7c7d-e262-414f-9fe0-4be98ff56e47
Errors
[]This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗