[BUG] Malformed tool-call emission (stray "court" + bare <invoke>/<parameter>) in long tool-dense sessions; rendered as prose, no validation error, self-reinforcing
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?
In a long, tool-call-dense session (hundreds of Read/Edit/Bash calls, large
accumulated context), the assistant intermittently emitted literal text imitating
a tool call instead of a valid invocation: a stray token court followed by a
bare <invoke name="..."> / <parameter ...> block — missing the proper
function-calls wrapper/namespace.
The harness rendered this as plain assistant text: no tool executed, and no
validation error was returned to the model, so it got no corrective signal. The
failure was self-reinforcing — once the malformed pattern was in context (and
when it was quoted back), it repeated across several consecutive turns, while
valid tool calls still succeeded intermittently in between. Not a hard capability
loss; looks like formatting drift + context-echo amplification.
What Should Happen?
Either a valid, executed tool call — or, if the model emits an invalid
invocation, the harness should detect the malformed/attempted tool call (stray
sentinel token, <invoke outside a valid function-calls block) and return a
structured "invalid tool call" error to the model so it self-corrects, instead of
passing it through as user-visible prose with no signal.
Error Messages/Logs
No error surfaced — that is part of the bug. The malformed invocation rendered as
plain assistant text, e.g.:
court
<invoke name="Read">
<parameter name="file_path">...</parameter>
</invoke>
No debug log was produced for the session (/debug reported "No log file exists yet").
Steps to Reproduce
- Run a long Claude Code session (VSCode extension) with many sequential tool
calls (Read/Edit/Bash) and large accumulated context.
- Observe occasional tool calls emitted as plain text:
court+ `<invoke ...>
<parameter ...></invoke>` instead of a real invocation.
- No tool runs and no error appears.
- The malformed pattern recurs over subsequent turns once it is in the
conversation (especially if quoted back), while some valid calls still succeed.
Non-deterministic; correlated with session length / tool-call density.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
2.1.168
Claude Code Version
2.1.168
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
VS Code integrated terminal
Additional Information
- Self-reinforcing via context echo: malformed output (and user re-quotes of it)
act as few-shot examples that increase recurrence.
- The stray literal "court" suggests a corrupted/mis-decoded opening sentinel for
the tool-call block.
- Suggested mitigations: (1) harness-side validation of tool-call delimiters,
returning an error on a malformed invoke; (2) investigate the "court" sentinel
corruption; (3) periodic context compaction in very long sessions to reduce
drift and self-imitation.
- A full transcript excerpt can be attached on request — the malformed calls are
visible verbatim.
<img width="400" height="492" alt="Image" src="https://github.com/user-attachments/assets/876d047c-7947-48c1-80d3-86ed4a049414" />