Tool calls emitted as literal <invoke> text instead of executing, in long tool-heavy sessions (Opus 4.7 1M tier)

Resolved 💬 3 comments Opened May 21, 2026 by henpen6 Closed May 21, 2026

Summary

In long, tool-heavy sessions on the Opus 4.7 1M-context tier, Claude Code intermittently emits a tool call as literal text (the <invoke name="..."> / <parameter> markup, sometimes prefixed with a stray word like count) in the assistant's response instead of executing a structured tool call. The command never runs, so the session appears frozen while the assistant otherwise looks like it responded normally.

Environment

  • Claude Code 2.1.146
  • Model: claude-opus-4-7[1m] (1M extended-context tier), effort medium
  • macOS (Apple Silicon), Terminal, --remote-control wrapper sessions

Symptom

The assistant message contains the raw tool-use markup as visible text. No tool executes. In the iPhone app the transcript shows the <invoke> / <parameter> block rendered as plain text.

Trigger

Appears after a session accumulates large context (observed ~500K+ tokens) with sustained tool use. Two independent sessions hit it on the same day once their context was large; a fresh/short session does not exhibit it.

Self-reinforcing

Once one tool call leaks as text, the assistant keeps mimicking the textual form on subsequent turns (the leaked markup sits in context as a pattern it continues). Single corrective nudges recover it only transiently before it recurs.

What does NOT fix it

Restarting the process with --resume does not fix it — the same (contaminated) context reloads and the glitch recurs immediately on the next tool call.

What DOES fix it

/compact reliably fixes it — the summary replaces the verbatim leaked-markup turns, removing the pattern the model was mimicking. Caveat observed: /compact must be issued at an idle prompt; if sent while the session is busy it is queued rather than executed.

Related (different backends, same class of failure)

  • jundot/omlx#159 — emits literal [Tool call: ...] text / stalls under long prompts (Anthropic /v1/messages + MCP)
  • ollama/ollama#15529 — prints raw JSON instead of executing tool calls

Severity

A session can silently stall for an extended period before a human notices, because the assistant appears to be responding normally — the only signal is that nothing actually executes.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗