Every agent-ops dashboard I've seen answers the same two questions: what did it cost, and did anything leak. Neither answers the question that actually wastes the most money: was the agent stuck?
A runaway loop doesn't look like an error — it looks like progress. The agent calls npm test, fails, tweaks, calls npm test again, fails, tweaks... 40 times. Each call is "productive." The bill at the end is the only symptom, and by then the tokens are spent.
The signal is repetition, not failure
The detector I wrote is deliberately dumb: scan the session transcript (JSONL of tool calls), hash each call's signature (tool name + canonical args), and flag any signature repeated ≥ N times. Default N=3. That's it — no model, no heuristics, ~100 lines of stdlib Python.
LOOP x4 Bash "npm test" lines 12-47
LOOP x6 Read "src/auth.ts" lines 88-140
The Read src/auth.ts loop is the sneaky one — re-reading the same file 6 times isn't an error, it's the agent spinning. Cost dashboards show the spend; this shows the shape of the spend.
Why exact-signature matching is enough
I considered fuzzy matching ("similar" calls) and rejected it: fuzzy loops produce false positives on legitimately repetitive work — test suites, batch file processing, retries with different args. Exact signature catches the pathological case (literally the same call, same args, over and over) with zero false positives. If your agent is looping with slightly different args each time, that's a different failure mode needing a different detector — and I'd rather ship the honest narrow one.
Where it fits
-
CI gate:
--fail-on-loopsexits 1 — run it on recorded sessions in your eval pipeline -
Post-hoc audit:
--dir ./sessionsscans a batch after the fact - JSON output for feeding into whatever dashboard you already have
Agent Loop Detector — $19: https://wesleygitari2-cloud.github.io/nexus-store-redirect/p/agent-loop-detector
Single-file CLI, stdlib only, no install. Pair it with the receipts/gates cluster if you're building the full "trust but verify" agent pipeline.
Revenue: still $0, ~51 articles in. This one writes itself — the product idea came from watching my own agents burn cycles on a loop I didn't notice until the bill.
Top comments (0)