[BUG]
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?
Title: Tool calls leak as literal <invoke> text in long sessions; desktop hard-fails with "tool call could not be parsed"
Environment
- OS: Windows 11 Pro (build 10.0.26200)
- Claude Code CLI: 2.1.153
- VS Code extension: anthropic.claude-code 2.1.153 (win32-x64)
- Also reproduced in the Claude Code desktop app
- Account: official paid subscription (not a proxy / third-party endpoint)
- Model shown: Opus 4.7 (1M context), effort "Extra high", Fast mode
- Config: ~6 remote MCP servers + many skills/plugins loaded globally
Summary
In long-running agentic coding sessions, the model stops emitting structured
tool_use blocks and instead prints the tool call as literal text, e.g.:
<invoke name="Edit">
<parameter name="file_path">...</parameter>
<parameter name="old_string">...</parameter>
...
</invoke>
A short literal token ("court" or "call") precedes each leaked block — looks
like a render artifact of a stripped <function_calls> wrapper.
Behavior differs by surface (same 2.1.153):
- Desktop app: HARD FAILS. Shows "An API error occurred / The model's tool
call could not be parsed (retry also failed)." and the turn breaks.
- VS Code extension: the parser usually RECOVERS — the tool still executes
(e.g. TodoWrite todos render as completed) and the turn continues, but the
raw <invoke> text is still shown inline.
Trigger
Strongly correlated with LONG conversation context (multi-phase runs:
build → repackage EXE → verify, all in one thread; large tool outputs; big
file reads). Starting a fresh conversation (/clear or new window) reliably
makes tool calls work again. Once one text-shaped tool call lands in history,
subsequent turns imitate it and degrade further (pressing "Continue"/"Retry"
makes it worse — later calls become degenerate, e.g. <invoke name="Edit">).
<parameter name="file_path">test</parameter></invoke>
Ruled out
- NOT model strength: reproduced on Opus 4.7 at Extra high effort.
- NOT a fake/proxied model: official subscription, no ANTHROPIC_BASE_URL,
no router installed; the CLI on the same machine/version works fine.
What Should Happen?
Title: Tool calls leak as literal <invoke> text in long sessions; desktop hard-fails with "tool call could not be parsed"
Environment
- OS: Windows 11 Pro (build 10.0.26200)
- Claude Code CLI: 2.1.153
- VS Code extension: anthropic.claude-code 2.1.153 (win32-x64)
- Also reproduced in the Claude Code desktop app
- Account: official paid subscription (not a proxy / third-party endpoint)
- Model shown: Opus 4.7 (1M context), effort "Extra high", Fast mode
- Config: ~6 remote MCP servers + many skills/plugins loaded globally
Summary
In long-running agentic coding sessions, the model stops emitting structured
tool_use blocks and instead prints the tool call as literal text, e.g.:
<invoke name="Edit">
<parameter name="file_path">...</parameter>
<parameter name="old_string">...</parameter>
...
</invoke>
A short literal token ("court" or "call") precedes each leaked block — looks
like a render artifact of a stripped <function_calls> wrapper.
Behavior differs by surface (same 2.1.153):
- Desktop app: HARD FAILS. Shows "An API error occurred / The model's tool
call could not be parsed (retry also failed)." and the turn breaks.
- VS Code extension: the parser usually RECOVERS — the tool still executes
(e.g. TodoWrite todos render as completed) and the turn continues, but the
raw <invoke> text is still shown inline.
Trigger
Strongly correlated with LONG conversation context (multi-phase runs:
build → repackage EXE → verify, all in one thread; large tool outputs; big
file reads). Starting a fresh conversation (/clear or new window) reliably
makes tool calls work again. Once one text-shaped tool call lands in history,
subsequent turns imitate it and degrade further (pressing "Continue"/"Retry"
makes it worse — later calls become degenerate, e.g. <invoke name="Edit">).
<parameter name="file_path">test</parameter></invoke>
Ruled out
- NOT model strength: reproduced on Opus 4.7 at Extra high effort.
- NOT a fake/proxied model: official subscription, no ANTHROPIC_BASE_URL,
no router installed; the CLI on the same machine/version works fine.
Error Messages/Logs
Steps to Reproduce
Steps to reproduce (best effort)
- Configure several MCP servers (large tool surface) + several skills.
- Run a long multi-step agentic task with many tool calls and large outputs.
- After context grows large, observe tool calls being emitted as literal
<invoke>...</invoke> text instead of executing.
Expected: tool calls are always parsed/executed as structured tool_use.
Actual: under long context they leak as text; desktop errors with
"tool call could not be parsed (retry also failed)".
Impact
Breaks long agentic sessions on desktop; forces frequent /clear. VS Code is
usable but noisy.
Possible mitigations on client side: more robust tool-call parsing /
recovery (match VS Code's tolerant behavior on desktop), and/or guard against
the text-tool-call feedback loop once one leak enters history.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.153
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗