Feature request: doom_loop-style permission gate to guard against runaway agent loops

Open 💬 0 comments Opened Jul 2, 2026 by chirag127

Problem

No first-class guard against runaway agent loops (subagent recursion, plan-then-execute cycles that never terminate, tool-call storms).

What OpenCode has

A doom_loop permission key in its permission schema (allow/ask/deny), alongside read, edit, bash, task, etc. Fires when the runtime detects a plausible loop pattern before it burns more tokens. Ref: https://opencode.ai/docs/permissions/

Why it matters

Long autonomous sessions on Opus at high effort can silently spend $10-20 before I notice a stuck loop. Hooks (Stop, SubagentStop) fire after damage. A pre-detection permission gate would prompt-or-halt at the pattern, not the outcome.

Suggested shape

  • New permissions.doom_loop: "ask" | "deny" in settings.json.
  • Triggered heuristics: same tool + args ≥N times, subagent depth > M, no-progress iterations > K, cumulative-cost per-session ceiling.
  • Emits a new hook event LoopDetected so users can log or auto-halt.

Thanks for the great work on Claude Code!

View original on GitHub ↗