Claude Code repeats "court" infinitely and halts with Response stalled mid-stream: causes and fixes
When you work in Claude Code for a long stretch, the response can suddenly repeat the same word — "court court court…" — dozens to hundreds of times, then halt with "API Error: Response stalled mid-stream. The response above may be incomplete." This is not a mistake in your prompt; it is two separate known bugs chaining together: (1) the model emitting the same token over and over — repetition (degeneration), GitHub #68740/#65823/#66950 — and (2) "Response stalled mid-stream," where the flood of output or a connection problem stops the response stream (#70840 and the official error reference). "court" means nothing; the model just fixated on that token, and it carries the area:model label as a model-side bug. This article breaks down the two layers, how it differs from the "court/invoke tag leak" type (a separate article), the trigger conditions (long sessions, large context, prose right before a tool call, unstable connections, long output), how to stop it now (interrupt with Esc, escape to a new session or /clear, call tools with no preamble, split the task), developer measures (read timeout, repetition-detection guard, retry without keeping broken history, a max_tokens cap), how to tell it apart from Connection closed mid-response and Prompt is too long, and the official status as of July 2026, where no permanent fix is confirmed — all based on the official docs and the actual issues.