claude-code - 💡(How to fix) Fix Opus 4.8 (1M): malformed tool-call markup (missing antml: prefix) cascades across retries

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…

Fix Action

Fix / Workaround

Workaround that reliably fixed it Emitting the tool call as the very first tokens of the turn, with no preamble text, and deliberately not echoing the prior broken lines -> parses correctly.

RAW_BUFFERClick to expand / collapse

Environment

  • Claude Code on Windows 10
  • Model: claude-opus-4-8[1m] (Opus 4.8, 1M context)
  • Long multi-hour session

Symptom Intermittently the model emits malformed tool-call markup: the antml: namespace prefix is dropped from invoke/parameter tags (renders as a bare <invoke name="...">), and a stray token (literally court) is prepended on the line before the function-call block. The harness then rejects it:

Your tool call was malformed and could not be parsed. Please retry.

Cascade (the main problem) Once a single malformed call lands in the transcript, every subsequent tool call reproduces the same malformation — it appears to self-reinforce by pattern-matching on the model's own prior (broken) output. It repeated ~5 times in a row before being broken out of.

Workaround that reliably fixed it Emitting the tool call as the very first tokens of the turn, with no preamble text, and deliberately not echoing the prior broken lines -> parses correctly.

Frequency ~5 occurrences in one session, in bursts.

Impact Each malformed call wastes a full turn and is very confusing to the user (looks like the agent is stuck/hung).

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Opus 4.8 (1M): malformed tool-call markup (missing antml: prefix) cascades across retries