Files
loki/scripts
g-butandClaude Opus 4.7 496dc8e97b fix(autopilot): per-tab cooldown to break the ready-fire-ready loop
User shared live revamp-it transcript: autopilot was firing the
next_best Setup template at the agent every ~1-2 min, the agent
had nothing to do (branch in sync, no blockers, deploy live), so
it wrote the same ready handoff each iteration, and the cycle
repeated indefinitely. Wasted Claude tokens, wasted agent
attention, surfaced as user-visible noise.

The status:working + blocker gates shipped earlier today
(b89fdfc + 7ded0c2) couldn't break this loop because the AGENT
itself writes status:ready each iteration — the gate is correctly
open. The missing primitive was an absolute MINIMUM INTERVAL
between consecutive autopilot fires for the same project,
independent of handoff content.

scripts/agent-hook-bridge.sh:autopilot_dispatch_and_inject() now
maintains a sentinel file per tab at /tmp/cockpit-daemon/last-
autopilot-<tab>. Default cooldown is 300s (5 min); override via
COCKPIT_AUTOPILOT_COOLDOWN_S. When the file's mtime is younger
than the cooldown, autopilot refuses the fire and logs
"cooldown 12s/300s for <tab> — staying idle". Manual dispatches
via the UI bypass this (they go through /api/orchestration/run
which has its own gates) — the cooldown only governs autopilot's
own decision to compose-and-inject.

Concrete effect: revamp-it can fire at most once per 5 min, so
the agent gets 5 min of breathing room to actually do work
before the next prompt arrives. If 5 min is too aggressive for a
healthy project, the env var lets the user tune it.

Roadmap "## Proposed" entry "Autopilot fires uncoordinated across
ALL zellij tabs" can be partly closed by this — it's the option
(2) per-tab cooldown solution. Options (1) global kill switch
and (3) decision-attestation queue are still open and have their
own design merits, but this is the minimum fix that breaks the
worst current symptom.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 13:59:08 +02:00
..