I looked for gaps in how the loop handles the model getting stuck, and found that the three failure shapes weren't all covered. There were two detectors — LoopGuard (identical repeated calls) and the failure ledger (same signature failing repeatedly) — but two real cases fell through.
Hallucinated tool names → "did you mean". Small models constantly call tools that don't exist: read_files, writeFile, search, bash, cat. The old behavior was a bare "unknown tool" (or worse, a thrown "Unknown tool" from the registry). Now suggestNearestTools finds the nearest real tools using edit distance plus an alias map (bash→shell, cat→read_file, search→codebase_search, rg→grep, …) and substring/prefix affinity. It's wired in two places that share the helper: LoopGuard.checkAssistantTurn, which fires first at the turn level before execution, and the executor's own unknown-tool path as defense in depth. The loop test proves the recovery: the model calls read_files, gets "did you mean: read_file", corrects on the next turn, and finishes — instead of the session stalling.
Consecutive-error circuit breaker. The failure ledger catches the same call failing repeatedly, and LoopGuard catches identical calls, but neither catches "four different tools erred in a row" — the classic flail where the model thrashes between approaches. ConsecutiveErrorTracker injects a single "step back and reassess — change strategy" nudge when the error streak hits the threshold, fires once per streak, and re-arms after any success. It's wired into the executor's result path alongside the existing per-signature ledger.
I updated the existing LoopGuard test for the slightly richer suggestion wording, and recorded the key lesson in .cursorrules: there are now three distinct "stuck" detectors that must not be conflated — LoopGuard (identical calls), FailureLedger (same signature), and ConsecutiveErrorTracker (different tools erroring) — plus the note that hallucinated names are caught at the turn level before execution, so tests should scan user+tool feedback, not just tool results. AGENTS.md's harness table documents both. All on cursor/hf-massive-stage-49dd, PR #7.