Tool-call opening tag gets stuck on a malformed form and is unrecoverable within the session
Summary
Once the model's tool-call opening tag is emitted in a malformed form (anything other than the correct antml:invoke opening tag — e.g. a truncated/abbreviated form, a typo in the namespace, or a full-width bracket), the malformed shape gets "stuck": every subsequent tool call in the same session keeps coming out malformed, the harness fails to parse them, and work halts. The only reliable recovery I have found is starting a new session — the corruption does not clear within the running session.
Environment
- OS: Windows 11 Home (10.0.26200)
- Shell: PowerShell 7
- Claude Code: CLI (please fill in exact
claude --version) - Repro is intermittent but, once triggered, is sticky for the rest of the session.
Steps that seem to trigger it
I cannot reproduce on demand, but it has correlated strongly with:
- Emitting a single tool call that packs a large/complex command inline (long multi-line shell, many chained operations, heavy quoting/escaping).
- After one such call parses incorrectly, the next tool-call opening tag also comes out malformed.
- From that point the malformed opening-tag form repeats call after call → repeated parse errors → no tool actually executes → the turn stalls.
Expected behavior
- A single malformed tool-call opening tag should be an isolated, recoverable event: the next tool call should be able to come out correctly.
- The harness should ideally surface a clear, actionable parse error rather than silently stalling, and should not let one malformed emission "lock" the session into a bad state.
Actual behavior
- The malformed opening-tag form persists for the remainder of the session.
- Parse errors chain; the agent appears to retry and re-emit the same broken shape.
- Effective work stops until the session is restarted.
Impact
This is a hard stop: when it triggers, the session becomes unusable for tool execution and the only escape is a full restart, losing in-session context. For long-running operational work this is very costly.
Notes / possibly related
- Symptom resembles the duplicated/garbled opening-tag behavior seen elsewhere (e.g. repeated/garbled tool-call open tags).
- Possibly related: anthropics/claude-code#1236 (invalid tool parameters causing recursive error).
- Mitigation we adopted on our side: keep tool calls short and route heavy/complex commands through a file instead of inlining them, which appears to greatly reduce the trigger rate — but this is a workaround, not a fix.
Suggested mitigations to consider
- Make malformed opening-tag emission self-correcting (do not carry the malformed shape forward to the next call).
- Emit an explicit, visible parse-error diagnostic instead of a silent stall.
- Guard against one malformed emission poisoning subsequent tool-call generation within the same session.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗