[BUG] Tool call parameters serialized into tool_use.name field on first response (no compaction)
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?
Tool call parameters are being serialized/flattened into the tool_use.name field instead of the input field, causing a 400 API error. This happens on the very first assistant response in a brand new session — no context compaction is involved.
This is similar to #25812, but that issue attributes the corruption to autocompact. In this case, the session has only 35 lines total, the corruption occurs on the first tool call (line 9), and there is no compaction event in the session history.
All three tool calls in the first assistant response are corrupted:
| Tool | Name field length | Input field |
|------|------------------|-------------|
| Task | 795 chars | {} (empty) |
| Glob | 34 chars | {path: ...} (partial) |
| Glob | 19 chars | {path: ...} (partial) |
Corrupted tool_use blocks
Expected Task call:
{
"type": "tool_use",
"name": "Task",
"input": {
"prompt": "Search GitHub issues...",
"subagent_type": "general-purpose",
"description": "Research Docker fs error",
"name": "docker-research",
"run_in_background": true
}
}
Actual (corrupted):
{
"type": "tool_use",
"name": "Task\" prompt=\"Search GitHub issues and the web for the Docker error '...' subagent_type=\"general-purpose\" description=\"Research Docker fs error\" name=\"docker-research\" run_in_background=\"true",
"input": {}
}
The Glob calls are similarly corrupted:
// Expected:
{"name": "Glob", "input": {"pattern": "docker-compose*.yml"}}
// Actual:
{"name": "Glob\" pattern=\"docker-compose*.yml", "input": {"path": "..."}}
Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.1.content.3.tool_use.name: String should have at most 200 characters"}}
Once the corrupted tool_use blocks enter the conversation history, every subsequent message triggers the same error — the session becomes unrecoverable.
Steps to Reproduce
- Start a new Claude Code session (fresh, no prior context)
- Ask a question that triggers parallel tool calls (e.g. a Task subagent + Glob calls)
- The tool_use blocks in the first response may have parameters flattened into the
namefield - Session enters unrecoverable 400 error loop
This appears intermittent — the same type of tool calls work correctly in other sessions.
Key Difference from #25812
- #25812: Corruption happens after autocompact runs mid-session
- This issue: Corruption happens on the first assistant response — compaction hasn't run and can't be the cause
- This suggests the serialization bug may have multiple triggers, not just compaction
Claude Model
claude-opus-4-6
Is this a regression?
I'm not sure / I don't know
Last Working Version
_No response_
Claude Code Version
2.1.39
Platform
Anthropic API
Operating System
macOS (Darwin 25.2.0)
Terminal/Shell
Other
Additional Information
Session ID: 0f314fcd-09ae-4013-a044-dbe1b5c913fe
The session had multiple MCP servers and skills/plugins enabled, which may contribute to tool definition count and increase the chance of this serialization issue.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗