[Bug] Malformed tool-call markup with missing antml: namespace prefix causes self-reinforcing parse failures in long sessions

Open 💬 1 comment Opened Jun 18, 2026 by BRIDGE-AI

Summary

In a long Claude Code session, the model (Opus 4.x, 1M context) intermittently emits malformed tool-call markup: it drops the required antml: namespace prefix on the invoke/parameter tags (and sometimes adds a spurious call wrapper). The harness then either reports "malformed and could not be parsed" or silently drops the block, so the tool never runs, no result returns, and the turn just ends.

Self-reinforcing loop

Because no tool result returns and the malformed markup sits in the model's own prior output (context), autoregressive generation is primed to repeat the same error next turn. The model correctly diagnoses the cause every turn but still reproduces it within the same context. It recurred for ~6 consecutive turns and blocked all tool use until the session was reset.

Notable

While writing a bug-report file describing this, putting literal tool tags in the file body caused the parser to treat them as a real tool call ("No such tool available") — same parsing issue.

Environment

  • Claude Code CLI, Opus 4.x (1M context)
  • Multiple plugins/hooks injecting large system prompts (e.g. a terseness plugin via SessionStart hook) + several MCP servers
  • Very long session: 100+ tool calls; mostly Bash (custom CLI tooling) + file Edit/Write

Hypotheses

  1. Heavy plugin/hook system-prompt injection biases tag formatting.
  2. Once a malformed output enters the transcript, in-context repetition dominates (autoregressive lock-in).
  3. Silently dropping a malformed call gives the model no error signal, preventing self-correction.
  4. Token drift in very long context.

Severity

High once triggered, blocks all tool use until reset; the model cannot escape the loop even when the user explicitly points out the cause.

Suggested fixes

  1. Never silently drop malformed tool markup; always return a model-visible error.
  2. Tolerant parsing: accept invoke/parameter without the antml: prefix, or auto-normalize.
  3. Decoding/training guard against namespace-prefix omission in tool tokens.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗