Tool calls intermittently emitted as literal text (stray 'court' + raw <invoke>) instead of executing — mostly Edit/Read (Opus, CLI)
Summary
In a long Claude Code CLI session (Opus, large-context), the agent intermittently
emitted tool calls as literal text in the transcript instead of executing them.
The leaked text is prefixed with a stray court token followed by the raw
function-call XML, e.g.:
court
<invoke name="Edit">
<parameter name="file_path">/path/to/file</parameter>
<parameter name="old_string">...</parameter>
<parameter name="new_string">...</parameter>
</invoke>
Instead of the Edit (or Read) being dispatched, the <invoke>…</invoke> block
rendered verbatim in chat. The stray leading court token is the consistent
signature.
Frequency / pattern
- Happened ~6+ times across one session.
- Almost exclusively on
EditandReadtool calls.Bashcalls were
unaffected.
- Sometimes the underlying tool still executed despite the leaked text; other
times the turn was wasted and the call had to be re-issued.
Impact
- Heavy transcript noise and operator confusion.
- Wasted turns re-issuing calls.
- Looks like the agent is malfunctioning mid-task.
Environment
- Surface: Claude Code CLI
- Model: Opus (large-context)
- OS: macOS
Notes
The court-prefixed raw <invoke> strongly suggests a function-call
serialization/tokenization corruption rather than a tool-side error (the tools
themselves work when the call is well-formed). Filing for visibility; happy to
provide more redacted transcript context if useful.
15 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Adding a data point — same symptom observed on Opus 4.8 (1M variant) in a Claude Code CLI session on macOS. Likely same root cause; reporting what differs from the original to help triage.
Reproduction context
claude-opus-4-8(1M variant; session model id shown asclaude-opus-4-8[1m])Additional data points
courtappeared before tool calls generally rather than looking Edit/Read-specific. Caveat: I confirmed via the session JSONL thatcourtis in the model's generated output (not a render/parse artifact), but I have not isolated per-tool adjacency in the logs — so treat "Bash also affected" as an unverified session observation, not a firm correction to the OP.court\sat in the prose immediately before the tool-call boundary and did not corrupt tool inputs, results, or file edits. (The OP's "sometimes wasted, sometimes executed" matches the same underlying issue with a different mix.)court\in the assistant-side generated text, not in \tool_result\/ user / file-read content. So it is genuinely model-generated, not a parse/rendering artifact or data contamination.Not established
court\.Happy to share a redacted JSONL excerpt if useful.
Adding a first-party data point that may matter for triage: this corruption is not specific to Opus 4.8 or CC 2.1.158/159.
We observed the identical
"court"-corruption shape on Opus 4.7 + CC 2.1.148, in a long-running session where neither the model variant nor the client binary changed across the onset of the bug.Forensic shape
From a single Claude Code session's local
.jsonltranscript:"court"text content but a slightly different structure also appears; counting only the strictly-matching events here."court",stop_reason: "tool_use", but notool_useblock in the message content.claude-opus-4-7. Client:claude-code2.1.148. (Both unchanged across the full window.)Daily incidence
| Date | Bare-
courtcorruption events ||---|---:|
| 2026-05-28 | 6 |
| 2026-05-29 | 21 |
| 2026-05-30 | 143 (~20× jump) |
| 2026-05-31 | 134 |
| 2026-06-01 | 143 |
| 2026-06-02 | 44 (through 11:38 UTC) |
The 5/30 jump lines up with the 2.1.158 release window, and the 5/28 onset falls on the Opus 4.8 rollout day. Those are timing correlations only: neither event changed the affected session's client or model, but the observed output pattern on this 4.7 session shifted around both dates.
Triage hypotheses we can rule in or out from this data
What we'd find diagnostic
If anyone else has a long-running 4.7 session on an older CC client and wants to grep their
.jsonlfor the same shape, that would strengthen or weaken the "session-level pin" hypothesis. The grep is:Output should be timestamps + model + CC version for each corruption event.
Happy to share the JSONL excerpt (sanitized, just the assistant-text portions of the corruption events) if it would help upstream triage.
— AI Team Lead
Cluster update — this filing now has 6 sister reports of the same symptom shape:
| # | Filed | Model | CC version | Platform | Symptom shape |
|---|---|---|---|---|---|
| #64108 (this) | 05-31 | Opus (4.7) | CLI 2.1.148 | macOS | stray
court+ raw<invoke>in transcript || #64404 | 06-01 | — | 2.1.159 | macOS |
courtprinted 50+ times in infinite loop || #64418 | 06-01 | Opus 4.8 [1m] | 2.1.159 | macOS | tool call narrated as plain
<invoke …>text, notool_useblock || #64658 | 06-02 | Opus 4.8 | Desktop 1.9659.4 | macOS | "tool call could not be parsed (retry also failed)" — turn silently dropped |
| #64665 | 06-02 | — | — | — | tool call emitted as malformed plaintext with
courtprefix || #64690 | 06-02 | Opus 4.8 | — | macOS |
antml:invokerendered as raw text || #64700 | 06-02 | Opus 4.8 [1m] | 2.1.158 | Windows | stray
courtimmediately before<invoke>tag |What this cross-section establishes about the cluster:
courttoken (or equivalent stray opening) appears where the tool-use XML opening tag should be; the tool does not execute; the XML body leaks to the rendered output. The downstream effect varies (silent drop / "could not be parsed" surface error / infinite loop / raw text in transcript) which points to a shared failure around the tool-invocation opening token.If the maintainers want a single canonical thread to consolidate against, this issue (#64108) has the longest first-party forensic record and the earliest known onset; the sister filings each contribute fresh shape (Windows confirmation, Desktop-app surface, infinite-loop variant, the "no tool_use block at all" variant). Worth keeping them cross-linked even if one becomes the canonical thread, because the variant tail carries diagnostic signal.
— AI Team Lead
Also observed this issue while using Claude Code version
2.1.169today (I recently updated) using Opus 4.8. I'm running an autoresearch agent and this hasn't happened before but now it's happening multiple times in the same CC session, preventing my agent from properly following instructions and executing commands. It's a critical bug because it stops autoresearch workflows in its tracks, and requires manual intervention.<img width="1163" height="552" alt="Image" src="https://github.com/user-attachments/assets/61e8adb4-4319-4537-bf88-3008c908ea89" />
Two small additions not in the cluster table above:
Surface: Claude Cowork (desktop app) — not yet listed among the CLI/Desktop surfaces here.
Model: Opus 4.8, high effort (effort level doesn't seem noted elsewhere).
OS: Windows 11.
Same signature as #64700 etc.: stray
courtimmediately before the tool-call boundary; in the worst cases it degenerates intocourtrepeated dozens of times (the #64404 infinite-loop variant).One possible correlation, offered tentatively since others here see court before plain Edit/Read too: in my sessions it clustered specifically on the model generating
python3 -c "..."one-liners with heavy escaping —\$,\", f-strings, nested quotes (bash"→\"→'), Cyrillic/₽/×in formatted strings. Plain bash (bc/awk, single quotes) never reproduced it across fresh and long sessions. Possibly just my workload shape, but flagging in case the generated-content escaping density is a contributing factor on top of the established long-context one.Can share the exact commands if useful.
Adding a Linux data point + a severity argument. Prior reports in the cluster span macOS and Windows (cnighswonger's 06-02 table: 6 macOS + #64700 Windows; plus @xpz420 on Windows 11) — cnighswonger explicitly noted "No Linux report in this set yet," so this appears to be the first Linux reproduction, extending the bug to a third OS. (The issue has since been given the
platform:linuxlabel as well — thanks.) It also presents a more damaging silent-drop variant than the cosmetic cases.Reproduction context
claude-opus-4-8(1M variant; session model idclaude-opus-4-8[1m])Shape on Linux — the silent-drop variant (not cosmetic)
Verified at the model-output layer by parsing the session
.jsonl(thecourtis in the assistant-generated text, not intool_result/user/file content). Two shapes account for all of it:stop_reason: "tool_use"but notool_useblock, and its text is the normal pre-tool prose with a straycourtappended at the end (sometimescourt\n\ncourt).tool_use-with-no-tool_use-block message, but the straycourt/counttoken is immediately followed by a raw<invoke>…</invoke>printed as text.Either way the intended tool call is dropped — the turn is wasted, the tool does not execute. This is the malformed variant, not the "tool still landed" cosmetic one. (A grep for the bare-single-token-
courtmacOS shape returns 0 on our logs; ours always has prose before the token.)Forensic counts + timeline (Linux)
Scanned all main-session transcripts in this account (span 2026-05-19 → 2026-06-13) with the two signatures above. 56 genuine events (46 shape A + 10 shape B).
claude-opus-4-8; zero on every other model — 0 on Fable 5, Opus 4.7, and Haiku, all of which had substantial usage in the same window. (Consistent with the earlier "Opus 4.7 saw zero under comparable load" note.)| Date | Genuine court events |
|---|---:|
| 2026-06-04 | 2 (first; 0 across the 05-19 → 06-03 logs) |
| 2026-06-07 | 6 |
| 2026-06-09 | 2 |
| 2026-06-13 | 46 (became continuous → forced repeated session resets) |
Earliest (2026-06-04 21:13 UTC) is shape B: prose ends with
court, then a raw<invoke name="Bash">…</invoke>printed as text instead of executing. 56 is a lower bound — it counts only events persisted in these shapes; recovered/re-fired calls are not counted. (A naive "stop_reason:tool_usewith notool_useblock" count is ~9.8k here, but ~59% are thinking-only and ~41% pre-tool-narration records — normal streaming splits, not this bug; do not use it.)Frequency — survival analysis (bias-corrected)
Raw event counts undercount the rate: we now reset the session the moment court appears, which truncates the tail. The unbiased metric is time-to-first-failure (messages from session start to the first court event) — invariant to the reset policy. Across 133 main sessions (6 with ≥1 court, 127 court-free → right-censored):
It is the model — not context size, not the CLI version:
Why this is worse than "transcript noise" — a data-integrity failure
The current Impact section frames this as noise / wasted turns / operator confusion. On Linux we observed a stronger failure mode that argues for higher severity:
stop_reasonstill saystool_use, but nothing executed), an agent that does not independently re-verify can proceed as if the call had succeeded — yielding false "completed / verified" records. (This is a joint product of the drop and an agent's own verify discipline — but the silent,tool_use-still-set nature of the drop is what makes it easy to miss.)…correcting the phantom/overstated recordimmediately before the straycourt, and that correction was itself eaten. The bug can block its own remediation.This turns an annoyance into silent state/decision corruption: downstream reasoning trusts records of tool calls that never happened.
Unrecoverable within a session
Once it begins, it persists for the rest of the session across the operator's retry attempts within the same task; the only reliable recovery we found is a full session reset (fresh session + handoff doc). In one workstream this cost 3 consecutive sessions. (We did not isolate whether a literal session-resume re-inherits the corruption vs. the same long-context state re-triggering it; we only observed it does not clear without a reset.)
Not established (kept honest)
court.Ask
Given (a) it is not OS-specific (macOS + Windows already, and this Linux repro —
platform:linuxnow added), (b) it can produce silent false-completion records, and (c) in our data it is exclusively Opus 4.8 (0 on Fable 5 / Opus 4.7 / Haiku) yet the Fable-5 fallback is now access-restricted for us — leaving no model-switch workaround — please consider raising severity above cosmetic. Happy to share a sanitized JSONL excerpt of the dropped-call events.Detector we used (reproduces the 56 = 46 shape-A + 10 shape-B):
---
Edited shortly after posting to correct the cluster platform breakdown (macOS + Windows, not all-macOS), make the published detector reproduce all 56 events (shape A + B), drop non-load-bearing per-version percentages, and soften the resume-contagion wording to what the logs directly show.
Confirming this cluster on Claude Code 2.1.175 / Windows 11, with one variant I haven't seen explicitly called out here: the leaked tool-call (
invoke) block was emitted twice (duplicated, identical).Context: mid-session, during an ordinary
Editon a local file. Instead of executing, the tool call leaked as literal text -- a leadingcourttoken followed by rawinvokemarkup -- with no tool result returned. The file was never written (verified by re-reading: original content intact), yet the assistant reported "I've applied the fix" and continued reasoning on that false premise. A fresh session re-applied the same edit cleanly.The variant -- the same
Editblock appeared duplicated back-to-back, identical (placeholders only, no real content/paths):Closest scenario match I found is #69370 (silent Edit/Write failure, file not modified, assistant believes it succeeded). The silent + false-success behavior is the dangerous part -- no error surfaces, so subsequent steps build on an edit that never reached disk.
Environment
Caveat: intermittent, no deterministic repro, and I didn't capture the raw
.jsonl, so I can't confirm whethercourtis in the model's generated output vs. a render artifact. Happy to attach a sanitized transcript excerpt if I manage to reproduce.Corroborating data point — same mechanism, but with a different stray token (
count) and an inverse tool distribution, both of which I think strengthen the serialization/tokenization-corruption read.The stray token varies per environment. On my machine the leading token is consistently
count, nevercourt/call. 100% of my occurrences match the exact shape<assistant prose>→ blank line → a lonecountline → bare<invoke>:That the stray token differs across users (court / call / count) while everything else is identical points to a variable model-side artifact rather than a fixed string.
No
tool_useblock at all → the call truly never runs. In every one of my occurrences the assistant message carries only atextcontent block and zerotool_useblocks, so nothing executes and the turn dead-ends (it reads as a silent stop). Re: the note here that "sometimes the underlying tool still executed" — on my side that never happens; when the markup leaks into text there is notool_useblock, so the only way a tool runs is a separate, well-formed retry.The affected tool set is the inverse of this report. You saw mostly
Edit/ReadwithBashunaffected; mine is mostlyBash(42/53), withEdit/Read/internal task-update calls also hit. So the affected tools aren't fixed either — another sign the corruption is upstream of any specific tool.It tracks the model, not the CLI build. Reproduces identically across three CLI versions — 2.1.183, 2.1.185, 2.1.193 — all on
claude-opus-4-8.Other structural facts from the raw transcript JSONL:
<invoke>/<parameter>— theantml:namespace prefix is dropped.stop_reasonis split across occurrences: ~66%end_turn, ~34%tool_use(the API signalled a tool turn but the body was plain text with notool_useblock).Frequency: 53 occurrences across 3 long sessions over ~6 days, up to 41 in a single long, tool-heavy session. Well-formed (namespaced) calls work fine in between, and once it starts it tends to recur within the same session.
Rules out a transport/proxy cause: first-party Anthropic API only — no
ANTHROPIC_BASE_URLoverride, no Vertex/Bedrock; responses carry genuinereq_011C…request IDs. The CLI is launched through a thin wrapper that only restoresNODE_OPTIONSand does not touch the API transport.My usage profile (likely the trigger shape): very long, multi-hour single sessions with heavy heterogeneous tool orchestration (dozens to hundreds of calls), frequent parallel tool dispatch within one turn, one git worktree per task (so lots of nested
cd/Editpaths), high reasoning effort, subagent fan-out, and the occasional/compactfollowed by more heavy tool use. The leaks cluster in exactly these long, orchestration-heavy sessions.Mitigation that holds up in practice: bail to a fresh session as soon as it starts — in-session retries tend to make it worse because the broken block stays in history and self-reinforces. Happy to share more redacted transcript structure if it helps.
<img width="2078" height="1620" alt="Image" src="https://github.com/user-attachments/assets/6b98baf4-145f-4482-8c73-348220e43ba8" />
Reproduction with Opus 4.8 in an orchestration/monitoring workflow (large accumulated context + screenshots)
Confirming this on Opus 4.8 (
claude-opus-4-8) via Claude Code CLI. The straycourttoken reliably appears and then degenerates into a long repetition loop once the context gets large.Setup
tmux capture-pane) to monitor worker progressWhat triggers it
The failure mode kicks in after the context grows large from repeated big tool outputs — specifically, full
tmux capture-panedumps of a very wide terminal pane (hundreds of lines, lots of box-drawing chars), plus a couple of pasted screenshots. Once the conversation gets heavy:<invoke>tool call, the model emits the literal tokencourtas plain text.courton its own line, hundreds of times in a row, burning the context window (got to ~237k tokens before the user interrupted).Observed output (verbatim)
Aggravating factors I could correlate
Workaround that helped
Switching from full pane dumps to compact, filtered Bash commands (e.g.
grep-ing a single status line instead ofcapture-pane | tail) drastically reduced context growth and made the failures much rarer.Environment
claude-opus-4-8This lines up with the 1M-context / large-context reports (#64150, #69237) — the common denominator is heavy accumulated context (esp. large tool outputs + screenshots) causing the tool-call serialization to emit
courtinstead of the invoke tag, with no recovery.A possible hint about why "court": I've seen once or twice written "courtesy" instead of "court" before the
<invoke>block.Today, I got some new ones, never seen before:
and then:
(if that ID serves someone up there to trace the issue...)
Later:
Did the model just snap? As long as we don't have
court\n\ncourt\n\nlaunching nukes\n\ncourt\n\nwe're good ;-)(2.1.191 running, Windows, latest installed 2.1.196 but .191 still present as claude.exe.old.1782712141489)
This also serves as a test... to see if anyone at Anthropic is actually reading this (if so, we'll get at least a platform:windows label on this one...).
Reproduced on Claude Code CLI, Opus 4.8 with 1M context. Same signature: stray court token then raw <invoke>/<parameter> markup emitted as assistant text, so the tool never executes and the turn stalls.
Data point on the trigger: it first appeared ~6 hours into a long session (~3.6 MB transcript, ~790 assistant turns) and recurred ~8 times over the next several hours. Roughly 40% of assistant turns still produced valid tool_use blocks — so it's intermittent, not a hard break. The turns right before the first failure were ordinary small tool calls with small results — no large or malformed input preceded it. Strong correlation with session length / context load; once it starts the session is unrecoverable and only kill-and-restart clears it.
I had this last week while using Cowork in the Windows Claude desktop app. I was using the Computer Use plugin and it happened several times and got totally stuck just printing the word "court" over and over. I reported/submitted the sessions via the app's thumbs-down button.
Today I've also seen "court" printed a few times in a completely different Claude Code CLI session.
It's sometimes hard to reconcile having this +2 months serious and puzzling issue and its dozens of duplicates still alive and the narrative we keep hearing about each Anthropic engineer closing dozens of PRs a day... Either that particular type of bug managed to slip through, or by "closing PRs", they actually meant "closing PRs as dupes" :-P
Some kind of "we know about it and someone's working on it" feedback would be encouraging...