Commit Graph

1 Commits

Author SHA1 Message Date
drew e9f9573c63 feat(auto-agents): mid-flight worker doom-loop probe (G4, default-OFF)
Adds _session_pattern_checks.py — pure, network-free detectors over
the OpenCode session message stream — and wires it into
_opencode_worker.run_session_blocking as a soft-threshold probe past
~30% of the wallclock budget. A detector hit short-circuits the
poll loop with a named error_kind (doom-loop, retry-cascade,
permission-deadlock, empty-reasoning-loop) instead of the opaque
watchdog-timeout that the hard timeout would otherwise produce —
turning "the worker burnt 15 minutes for unclear reasons" into a
specific diagnosis suitable for telemetry.

Flag-gated via WORKER_DOOM_LOOP_ABORT_ENABLED; default OFF preserves
the pre-G4 behaviour byte-for-byte. When OFF the probe block is a
single boolean short-circuit. When ON, the probe is throttled by
both a soft elapsed-time threshold and a 60s inter-probe interval,
keeping per-cycle network cost bounded.

A3 design constraints (carried from final-working's
session-health-full-util.md) are pinned by tests: bash sleep
invocations don't count as activity; turns whose only output is a
tool call are activity (waiting, not stuck); healthy is the default
when signals are mixed.

20 unit tests for the detectors + 3 integration tests for the
worker wiring (flag-off must not /message-fetch; flag-on + doom
pattern must abort with named error_kind; flag-on + healthy must
complete normally).

Refs: docs/development/final-working-harvest-plan.md (G4).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 19:33:23 -04:00