claude-code - 💡(How to fix) Fix After /compact on Opus 4.8 (1M), whole tool calls emitted as <invoke> text instead of executing (not seen on 4.7)

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…

Error Message

Error Messages/Logs

Suggested fixes: (a) during compaction, don't render tool_use/tool_result blocks as literal <invoke> markup -- summarize them semantically or strip the wire format; (b) guard against <invoke name=...> emitted in the text channel -- re-route to a real tool call or error rather than rendering it as content.

Root Cause

Related (searched): #49747 (Opus 4.7, the XML-leaks-into-JSON variant), and the whole-call-as-text reports #63870 (open), #61221 and #60584 (closed). Filing separately because this is observed only since 4.8 and appears compaction-triggered with the WHOLE call emitted as text -- please link/dedup if you consider it the same root.

Code Example

Rendered as visible message text, no tools invoked; note the same block is duplicated (the tell):


<invoke name="Bash">
<parameter name="command">~/.../check-inbox.sh manager</parameter>
<parameter name="description">Check manager inbox</parameter>
</invoke>
<invoke name="Bash">
<parameter name="command">cd ~/project && gh pr list --json number,headRefOid,state --state open</parameter>
<parameter name="description">Check open PR heads live</parameter>
</invoke>
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

On Opus 4.8 (claude-opus-4-8[1m], 1M tier), after the session has been /compact'ed, the model emits the ENTIRE tool call as literal <invoke name="...">...</invoke> text in the assistant message instead of issuing a structured tool call. Nothing executes -- the session looks like it answered normally but no tool ran (a silent no-op).

I did NOT observe this on Opus 4.7; it started with 4.8, so from my side it reads as a 4.8 regression. It concentrates on a long-lived session that polls on a timer running the same 2-3 Bash commands every turn; a fresh session is fine, and it returns a few compactions into a new session.

Related (searched): #49747 (Opus 4.7, the XML-leaks-into-JSON variant), and the whole-call-as-text reports #63870 (open), #61221 and #60584 (closed). Filing separately because this is observed only since 4.8 and appears compaction-triggered with the WHOLE call emitted as text -- please link/dedup if you consider it the same root.

What Should Happen?

The model should emit a structured tool call that executes. /compact should never cause a tool call to be produced as assistant text.

Error Messages/Logs

Rendered as visible message text, no tools invoked; note the same block is duplicated (the tell):


<invoke name="Bash">
<parameter name="command">~/.../check-inbox.sh manager</parameter>
<parameter name="description">Check manager inbox</parameter>
</invoke>
<invoke name="Bash">
<parameter name="command">cd ~/project && gh pr list --json number,headRefOid,state --state open</parameter>
<parameter name="description">Check open PR heads live</parameter>
</invoke>

Steps to Reproduce

  1. Run a long-lived Opus 4.8 (1M) session that, every turn, issues the same small set of tool calls (e.g. a timer-driven inbox poll running 2-3 Bash commands).
  2. Let it /compact (auto or manual), ideally a few times.
  3. After compaction, the assistant prints <invoke name=...> blocks as message text instead of executing them; the same block is often duplicated.

Not observed on Opus 4.7 (same workflow); appeared with the 4.8 upgrade.

Root-cause hypothesis: /compact serializes prior tool_use blocks into the summary as literal <invoke>/<parameter> markup, and the post-compaction model pattern-completes on that in the text channel. Correlates strongly with tool-call-monotonous transcripts (a summary that is a wall of near-identical tool calls).

Suggested fixes: (a) during compaction, don't render tool_use/tool_result blocks as literal <invoke> markup -- summarize them semantically or strip the wire format; (b) guard against <invoke name=...> emitted in the text channel -- re-route to a real tool call or error rather than rendering it as content.

Severity: high for autonomous/looping agents -- a silent no-op that mimics a normal response, so the agent looks alive but does nothing until a human spots the raw XML.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.158

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

Environment: Claude Code Desktop app (macOS), not a CLI in a terminal -- so Terminal/Shell = Other. The change correlates with the Opus 4.7 -> 4.8 model upgrade rather than a specific Claude Code version, so 'regression = Yes' reflects the model change.

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 After /compact on Opus 4.8 (1M), whole tool calls emitted as <invoke> text instead of executing (not seen on 4.7)