Tool calls corrupted in long/compacted session: stray token + non-namespaced invoke tags

Open 💬 1 comment Opened Jun 21, 2026 by fechirin-cyber

Summary

In a long, repeatedly-/compact-ed Claude Code session, the model's tool-call output started reliably breaking: a stray literal token (court) was emitted immediately before tool-call tags, and tags were emitted as bare <invoke> / <parameter> instead of the correct namespaced structured form. This caused repeated "Your tool call was malformed and could not be parsed" errors, leaving commands unexecuted and wasting many turns/tokens.

Environment

  • Product: Claude Code
  • Model: Opus 4.8 (1M context) — claude-opus-4-8[1m]
  • Platform: Windows 10
  • Session characteristics: very long session, multiple /compact operations, long correction/retry loop

Symptoms

  • A stray literal court token leaks into the assistant output right before a tool call.
  • The tool call is then serialized with non-namespaced <invoke> / <parameter> tags instead of the proper structured format, so the harness rejects it as malformed.
  • It recurs across retries — including immediately after the model explicitly acknowledged the issue and said it would stop.
  • High recurrence within a single long session → commands silently not run + token waste + badly degraded UX.

Likely trigger (hypothesis)

  • Occurs more under a long + heavily-compacted + "polluted" context (after many corrections). Looks like a structured-output serialization-boundary slip (the broken form gets echoed/imitated once it appears in context). Starting a fresh session is expected to clear it.

Impact

  • During a single feature task, malformed tool calls + the stray token compounded with verification mistakes, wasting significant user time.

Expected behavior

  • Tool calls should always be generated with correct structured/namespaced tags even in long, heavily-compacted contexts.
  • No stray/literal tokens should be injected before tool-call tags.

Notes

  • Searched the project's markdown/memory files for the literal court to rule out a context echo source — it is not present in any relevant file, so the leak appears to originate in generation, not from a file.

View original on GitHub ↗

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