Runaway output: model repeats fixed string "court placeholder" thousands of times, exhausting output tokens (long-running session, large context)
Status Open
Reported on v2.1.165
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 7 comments · opened Jun 6, 2026
Runaway output: model repeats fixed string "court placeholder" thousands of times, exhausting output tokens (long-running session, large context)
Note: A deterministic clean reproduction is not yet established. Below are observations from real sessions plus a correlation-based characterization of the triggering conditions.
Summary
In long-running agent sessions of Claude Code (v2.1.165, model Claude Opus 4.8 / 1M context), after a normal response the model begins emitting the meaningless fixed string court placeholder repeatedly and runs away. Worst case: a single response consumed all 64,000 output tokens on this repetition (10,613 repeats in one message). Tool-call generation also breaks concurrently, causing loops and token waste.
Observed conditions (correlation analysis of real logs)
- Model: Claude Opus 4.8 (1M context) / Claude Code 2.1.165
- Long-running: first occurrence ~6h after session start (total ~15h uptime)
- Large cumulative context: ~275,000 tokens at first occurrence; grew to ~994,000 (near the 1M limit) as it worsened
- High-frequency tool calls: 61 tool-call/result cycles before first occurrence (periodic polling loop)
- No compaction involved (0 compaction events before first occurrence)
- First occurrence on a normal response turn right after a tool call:
court placeholderappended to the end of otherwise-normal text, then snowballed in subsequent messages
Expected vs actual
- Expected: the turn ends normally, or a well-formed tool call is generated.
- Actual: the fixed string is mass-repeated, generation breaks and loops.
Impact
- Massive token waste (64,000 output tokens of pure repetition in a single message).
- Sessions stall / loop; automated processing stops progressing.
- Recurred intermittently over ~9.4 hours (82 affected messages).
- Froze an interactive TUI session: in one instance the runaway output froze an interactive agent session's terminal UI while a user was actively on that screen, requiring manual
Esc/Ctrl-Cto break the loop and recover (~30 min unusable before manual recovery).
Environment
- Claude Code 2.1.165 / Claude Opus 4.8 (1M context) / macOS (Darwin 25.5.0)
- Injection-source check: a full-text search of local config/extensions (settings.json / skills / agents / hooks / statusline / instruction files) found no source of the string, so it does not appear to be locally injected — it looks like a model- or harness-side generation defect.
Reproduction status (honest)
- No deterministic clean repro yet. The event is state-dependent: long-running + large context (hundreds of thousands up to ~1M tokens) + high-frequency tool loop → it occurs probabilistically. It has not been reproduced in short / minimal configurations.
- A dedicated repro harness (sustained high-frequency tool calls building context near the limit) would likely be needed to force a deterministic repro.
- Available material: transcript (JSONL) excerpts including the first occurrence, the worst message, and token usage.
Showing cached comments. Read the full discussion on GitHub ↗
6 Comments
Your correlation analysis is the useful part here, and it points at a lever you can pull today even without a deterministic repro.
The runaway you're seeing (a fixed token getting mass-repeated until the 64k output budget is exhausted) is the classic long-context degeneration / repetition loop failure mode. It is not specific to the
court placeholderstring — that's just whatever low-entropy continuation the sampler latched onto. The thing that matters in your logs is the conditions you already isolated: it first appeared at ~275k cumulative tokens and got monotonically worse as context grew toward ~994k (right up against the 1M ceiling), driven by a 61-cycle polling loop with no compaction. Generation quality degrading as you approach the window ceiling is consistent with that failure mode, so the practical question is "how do I keep the session away from the ceiling," because that's the part a user can actually control.Concrete levers, in order of leverage:
1. Cap the window at 200k if you don't strictly need 1M.
CLAUDE_CODE_DISABLE_1M_CONTEXT=1removes the 1M variant entirely (it disappears from/model) and keeps you at 200k. This matters for two independent reasons:One gotcha if you try this: in v2.1.153+ the model you picked via
/model(includingopus[1m]) is persisted to themodelfield in settings and reloaded on new sessions —/cleardoes not clear it. So if you've ever selected a[1m]variant, also check that neither your settingsmodelfield norANTHROPIC_DEFAULT_OPUS_MODELends in[1m], or the alias will keep forcing 1M regardless of the env var. (Source: thecode.claude.com/docs/en/model-configExtended context section.)2. If you genuinely need the large window, compact proactively instead of letting it drift to 994k.
Your first occurrence was at 275k with zero compaction events. A periodic polling loop that never compacts is the context-growth engine here.
/compact(or/clearat natural boundaries) before you cross ~600–700k keeps you out of the part of the window where this shows up. Trimming or summarizing the large tool results from the polling loop before they accumulate has the same effect.3. Reduce the polling-loop blast radius.
61 tool-call/result cycles before the first occurrence is a lot of raw result text glued into context. If the loop is polling for a condition, lowering frequency or having the loop return a compact status instead of full payloads cuts the accumulation that's pushing you toward the ceiling.
None of this is a root-cause fix — the model emitting 10,613 repeats of a meaningless token in one turn is a generation-side problem, and the durable fix would be on the Claude Code / model side: a runtime guard that detects an identical-substring run exceeding N repeats and aborts the turn early, instead of letting it burn the full 64k output budget. That detection is cheap and would cap the worst-case cost even when the underlying degeneration happens. Worth filing/keeping as the actual ask, separate from the user-side mitigations above.
If you can capture the exact cumulative-token count at the moment the first
court placeholderappears across a few more occurrences, that single number (does it cluster, e.g. always >250k?) would be the strongest signal for a deterministic repro.Thank you for the technical explanation. However, I want to be direct:
This is your bug, not my problem to work around. I should not have to disable features, run manual compaction commands, or monitor token counts to prevent Claude from malfunctioning and consuming my entire usage limit. That is Anthropic's responsibility, not mine.
Giving users a list of workarounds instead of fixing the bug looks like you're shifting the blame onto the customer. When your own software enters an infinite loop and burns through a paid usage limit, that is effectively taking money from users without delivering a service — and that looks a lot like fraud.
The fix is simple and you even described it yourself: add a runtime guard that detects repeated identical output and stops generation automatically. Do that. Don't tell paying users to manage your broken software for you.
I want my usage limit restored. Your own analysis confirms this was caused entirely by a bug in Claude, not by anything I did.
Corroborating report — same failure mode, plus one data point this issue notes it lacks.
Environment: Claude Opus 4.8 (1M context), Claude Code on macOS (Darwin 25.5.0). Long-running self-paced agent loop running the same ~8-step prompt once per turn over many near-identical iterations (a database audit, one record per turn). Each turn is tool-heavy: SSH/
psql, multiple MCP calls, image reads.Symptom matches exactly: a normal response, then the text collapses into the same fixed string repeated until the output-token limit is hit and the turn dies. Observed the
courttoken mass-repeated (thecourt placeholderstring described here). It happened twice in one session.Added data point — both occurrences were post-compaction. The first occurrence reported here had 0 compaction events and grew toward ~994k tokens. Ours happened in a session that had already been auto-compacted, i.e. in a smaller reconstructed context, and then recurred. So compaction does not prevent it, and it is not strictly a function of approaching the 1M ceiling — the common factor in our case was the repetitive, high-tool-frequency loop structure rather than raw context size.
Small difference in where it started: in our case the degeneration began at a prose/section transition immediately before a planned tool call (right after writing a
## Step 2header), rather than appended after a completed tool call. Same prose↔tool boundary, slightly different side.No deterministic repro on our end either — same probabilistic, state-dependent behavior.
We hit the same runaway repetition ("court") and went through our raw transcripts. I filed the occurrence data as #79011 — 37 bursts across 3 sessions, all at ≥434k input tokens, and zero occurrences on Opus 4.7 (17,525 turns) under the same workload — plus the recovery step that worked for us. Linking here since it looks like the same bug.
Corroborating report — and honestly, I'm angry about this at this point.
This has been open for months. It hits multiple independent users, across different platforms and workloads, all describing the exact same collapse. And there is still no assignee. Nobody at Anthropic has taken ownership of a bug that outright kills long-running sessions.
We've hit this exact failure repeatedly — the model degenerating mid-session into an endless repeated token until the turn dies — and it is not some rare, exotic edge case. It has happened enough times, in ordinary long sessions, including while the model was doing something as basic as writing a session handoff summary, that we now genuinely dread running Opus for anything long. That is not how a product we pay for should behave.
And meanwhile, new flagship models and features keep shipping on schedule. A core, currently-supported model has been left broken like this for months, with reports stacking up, and it still hasn't been assigned to anyone. That ordering — new launches on time, a basic reliability bug ignored — tells us where the actual priorities are. A company that lets its main model sit broken like this while moving on to the next release is not a company we can trust with production work.
At minimum, ship a runtime guard now: detect a run of identical/near-identical output and abort the turn instead of burning the full output budget. Then fix the actual root cause. But first, someone needs to actually own this issue. Months of silence on a bug this severe is not acceptable.
This just happened to me right now, that's how I landed here. Opus 4.8 Extra. Got my first 50
courtoccurrences at less than 100k tokens. A few messages later at around 200k tokens it got into an infinite loop ofcourtmessages. Burned through 10k tokens until I realized it wasn't doing anything and I managed to stop it.