Repository navigation
Description
Summary
In interactive (chat) mode the supervisor only handles crewmate wakes when it is already active — i.e. on the captain's next message. A crewmate that finishes, blocks, or needs a decision during a quiet stretch sits unhandled until something pokes the supervisor. Finished work goes unrelayed, queued tasks don't dispatch, blocked crewmates wait.
Root cause
bin/fm-watch.sh has been a one-shot since the initial commit (6 commits, all refinements — coalesce signals, liveness guard, silence idle, prevent starvation — never a daemon or foreground loop). It runs as a background task, exits on every wake, and relies on the supervisor to restart it ("restart it after handling every wake"). The liveness guard (bin/fm-guard.sh) is pull-based: it surfaces a stale-watcher warning only on the supervisor's next fleet action (AGENTS.md:409 — "the protocol no longer relies on remembering"). There is no shipped mechanism that proactively routes a watcher wake into a supervisor turn.
So in chat-mode (supervisor turns paced by captain messages), wakes that land between messages are not handled promptly: the supervisor goes idle after each reply, the watcher exits on the next wake and stays exited, and the guard fires only on the next fleet action.
This is distinct from #26 (the watcher crashing on Linux stat). #26 is a crash; this is the design's wake-routing gap in interactive use.
Impact (observed in this session)
- Three finished scout tasks sat unrelayed for ~2h until the captain noticed.
- The watcher repeatedly goes stale (observed 679s and 222s stale across consecutive turns) and must be manually restarted each supervisor turn while crewmates are active.
- The captain cannot walk away and trust that in-flight crewmates will be advanced (unblocked, dispatched, relayed) — the fleet effectively stalls between captain messages.
Proposed fix
A daemon-mode watcher (or equivalent durable wake queue):
- The watcher runs continuously (does not exit on wake), detects signal/stale/check/heartbeat events internally, and appends each wake to a durable file (e.g.
state/.wake-queue). - The supervisor drains the wake-queue at the start of every turn;
fm-guard.shstill covers the "supervisor totally idle" case as a backstop. - This preserves the design's stated goals (zero-token idle, responsive to the captain, no foreground-blocking per AGENTS.md:415-416) while removing both the "watcher exits and isn't restarted" failure mode and the laggy-wake symptom.
Open question (broader scope): whether to also support an autonomous supervisor loop mode (supervisor self-paces through wakes without captain messages) for true unattended operation. The daemon-mode watcher is the minimal fix that makes the current chat-mode reliable; the autonomous loop is the larger follow-up.
Repro
- Spawn a crewmate on any task.
- Stop sending the supervisor messages; let the crewmate write a
done:status. - Observe: the watcher exits on the status signal and is not restarted; the supervisor does not relay the completion until the next captain message triggers a state check.
fm-guard.shwarns only on the supervisor's next fleet action.
Activity
e-jung commentedon Jun 20, 2026
Refined fix after reproducing this live: the root issue isn't only the watcher exiting — it's that even a durable wake queue goes unhandled when the supervisor (an interactive opencode/claude/codex session) only takes turns on captain messages. Wakes between messages sit forever.
Proposed fix: a supervisor wake-injection daemon (
bin/fm-supervise-daemon.sh, new — separable fromfm-watch.shso it doesn't conflict with #26):tmux send-keys), which triggers a fresh supervisor turn.Honest scope limit (separate follow-up): this keeps supervision alive within a harness session. Surviving the harness itself crashing (e.g. opencode auto-update exits) needs a system-level supervisor (systemd/launchd relaunch + reattach) — a distinct layer worth its own issue.
Net: daemon-mode watcher (detect reliably) + wake-injection daemon (act without the captain) = deterministic supervision. Filing this here so the fix approach is captured; can implement as a crewmate-built PR on the fork.
e-jung commentedon Jun 20, 2026
Refinement deployed locally:
fm-supervise-daemon.shnow filters routineheartbeatwakes (logs + skips injection) so autonomous supervision doesn't churn the supervisor's context with no-op fleet reviews. Actionable wakes (signal/stale/check) still inject. One-linecasebefore the injection block; worth including when this daemon lands upstream.kunchenguid commentedon Jun 20, 2026
thanks @e-jung - curious what agent harness are you running firstmate from?
kunchenguid commentedon Jun 20, 2026
Thanks again @e-jung - this and the
statfix are both excellent.Landed: a durable wake-queue (
state/.wake-queue) + singleton enforcement on the watcher, with wakes enqueued before any suppression marker advances. That kills the two concrete bugs - duplicate watchers (now physically impossible) and silently-consumed wake edges (wakes are now durable and lossless). Universal and harness-agnostic.On the remaining problem - and why a daemon won't fully solve it. We dug in and concluded the deeper gap isn't fixable in firstmate's shell layer. A shell process can detect events and queue them, but it cannot start a new agent inference turn - only the harness can. So "the supervisor wakes itself between user messages" is fundamentally a harness capability, not something a watcher daemon can manufacture. A persistent detector would faithfully fill the queue, but the queue still only gets drained when something injects a supervisor turn.
Turn-injection has exactly three flavors, per harness:
claude -p/codex exec/opencode run) to drain + act.So our plan: ship the universal durable-queue (done), model turn-injection as a per-harness adapter fact, and scope true unattended/walk-away operation as harness-specific - free where the harness offers (1) or (2), and requiring an external
exec-loop where it offers neither. A persistent-detector/blocking-waiter refactor is still on the table for ergonomics, but we don't think it's the thing that unlocks walk-away.Does that match your experience - and do you see a universal in-agent mechanism we're missing?
e-jung commentedon Jun 20, 2026
Thanks Kun! Running firstmate from opencode (glm-5.2) — the chat-mode wake gap is exactly what bit us, since opencode only turns on a user message.
Your framing matches our experience precisely. The daemon we deployed locally is the opencode-specific turn-injection: it runs the watcher, and on each wake does
tmux send-keysof the wake into the supervisor's opencode pane, which opencode treats as a user message and turns on. So walk-away works for opencode via that shim — but only because opencode accepts injected pane input as a turn-trigger, which is exactly the harness capability you're describing, not a universal one. On Claude Code we wouldn't need it (your flavor 1).So: agree there's no universal in-agent mechanism — your three-flavors model covers it cleanly. The durable queue you landed is the right universal layer; turn-injection stays per-harness. For opencode (flavor 3 — neither native completion-turns nor a scheduler), it's either the pane-injection shim (what we run) or a non-interactive
opencode runloop draining the queue — the latter is probably the cleaner long-term. Happy to help validate the per-harness adapter framing as it takes shape.feat(supervision): token-efficient sub-supervisor (closes #27) (#30)
feat(supervision): port token-efficient /afk sub-supervisor to herdr …
armchairo commentedon Aug 22, 2026
New churn case (2026-08-23): a secondmate agent parked in a FOREGROUND fm-watch-arm.sh wait (aa home) trips the parent home's stale escalation every cycle - escalations 1-6 in one night, each demanding deep inspection, while every inspection finds the same healthy state: agent revision static by design, child home's own watcher beacon fresh. The #11 idle-by-design backoff does not cover this shape because the pane reads working (blocked on the foreground tool) rather than done/paused. Suggested fix: treat a static-revision pane whose recorded home has a fresh .last-watcher-beat as idle-by-design for backoff purposes.
docs(zapp): implementation plan for policy rules and the eligibility …
fix(zapp plan): PR kunchenguid#27 has seven dependency bumps, not six
docs(zapp): spec for readable check output and CI-finished re-evaluation
docs(zapp): declare the signal-dependency set, mark results provision…
docs(zapp): implementation plan for the policy correctness fixes
feat(afk): add quiet supervision mode for a present captain (kuncheng…
Add beginner ONBOARDING.md (blank Mac to dispatch-proof first mate) (k…
feat(bin): add Deepgram as a transcription engine for the call record…