After /compact on Opus 4.8 (1M), whole tool calls emitted as <invoke> text instead of executing (not seen on 4.7)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] 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
- 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).
- Let it /compact (auto or manual), ideally a few times.
- 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.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗