claude-code - 💡(How to fix) Fix Tool-call opening tag gets stuck on a malformed form and is unrecoverable within the session

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Error Message

  • 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.
  • Possibly related: anthropics/claude-code#1236 (invalid tool parameters causing recursive error).
  • Emit an explicit, visible parse-error diagnostic instead of a silent stall.

Root Cause

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.

Fix Action

Fix / Workaround

  • 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

RAW_BUFFERClick to expand / collapse

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:

  1. Emitting a single tool call that packs a large/complex command inline (long multi-line shell, many chained operations, heavy quoting/escaping).
  2. After one such call parses incorrectly, the next tool-call opening tag also comes out malformed.
  3. 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

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.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING