We opened our production traces and found an agent reading the same CSS file 24 times
very team running autonomous coding agents in production eventually has a humbling afternoon with their telemetry logs. Ours happened when we inspected a stubborn e-commerce storefront run that had been chewing through tokens for twenty minutes. The model wasn't struggling with some arcane distributed-systems race condition. It was reading store/src/styles.css—the exact same untouched file—for the twenty-fourth time.
If you spend time in AI engineering circles right now, you know this isn't unique to any single model. Whether you run Claude Code, OpenCode, Codex, or a custom multi-agent harness, watch an agent wrestle with a real 500-file repository for forty minutes and the same eerie pattern emerges: it tries a fix, fails a test, reads the error log, makes a tiny cosmetic tweak, re-reads the file, and repeats until a budget cap puts it out of its misery.
The reflex is to blame the LLM's IQ and wait for the next checkpoint release. That misses the real culprit. Infinite loops aren't a raw intelligence problem—they are a mechanical side effect of context rot.
How a million-token window quietly turns into an echo chamber
When a human engineer hits a wall for twenty minutes, they stand up, grab water, and question their starting hypothesis. An autoregressive model has no instinct to walk away. Every turn is conditioned on everything sitting in its context window—and after thirty tool calls, that window is packed wall-to-wall with failed stack traces, stale file dumps, and abandoned patches.
Two ugly things happen simultaneously as that window bloats. First, 'Lost in the Middle' attention drift pushes your original architectural rules out of focus while the noisy tail of recent errors dominates attention. Second, the model falls into a statistical echo chamber: because its own failed attempts occupy half the prompt, predicting tokens consistent with its context literally biases it toward repeating the same broken move.
Worse still is what engineers call the patch-on-patch trap. Rather than stepping back and deleting a flawed abstraction, a rot-addled agent keeps stacking try-catch blocks, compatibility wrappers, and duplicate helpers on top of broken code—making the repo harder to understand on every single iteration.
Prompt engineering is dead. Long live context engineering.
That is why the sharpest conversation in AI engineering this year has pivoted away from clever single-turn prompts toward context engineering: curating, pruning, and structuring what an agent is allowed to see across long-running loops.
In practice, four unglamorous harness primitives beat ten pages of prompt gymnastics every time: (1) a cached structural repository map so the agent sees routes, exports, and scripts before opening a single file; (2) AST symbol outlines and targeted symbol reads instead of dumping 2,000-line files; (3) a deterministic duplicate-read circuit breaker that stops an agent from burning tokens re-reading an unchanged file; and (4) isolated subagent contexts so a research tangent never pollutes the main engineering thread.
# What actually stops coding agents from thrashing:
1. Map before touching: inspect cached .helix/repo-index.json first
2. Read symbols, not megabytes: file_outline -> read_symbol
3. Break loops deterministically: short-circuit repeated unchanged read_file calls
4. Verify with real tools: run tsc / tests after every meaningful editTRY HELIX IN PRODUCTION
Launch an isolated workspace free
Start free on Console or issue tenant-scoped keys inside Developer Console.

