Skip to content

fix(afk): route claude+herdr away-mode launch through the terminal-backed path - #3089

Open
NicholasACTran wants to merge 2 commits into
kunchenguid:mainfrom
NicholasACTran:fm/firstmate-afk-launch-path-wrong-on-claude
Open

NicholasACTran wants to merge 2 commits into
kunchenguid:mainfrom
NicholasACTran:fm/firstmate-afk-launch-path-wrong-on-claude

Conversation

@NicholasACTran

Copy link
Copy Markdown

What happened

Away mode delivered nothing for 95 minutes. One run logged 408 deferrals, every one carrying the identical reason supervisor pane busy (agent mid-turn). The composer guard - the accurate one - was never reached.

The mechanism

bin/fm-afk-launch.sh start-native runs the sub-supervisor daemon as a Claude Code background shell inside the captain's own pane. That leaves a · 1 shell · token in the pane's rendered footer for as long as the daemon lives. Herdr's own claude agent-detection ruleset maps that exact footer token to agent_status = "working" at priority 965, which outranks the idle rule live_prompt_box at priority 950. The away-mode busy guard trusts herdr's native agent state first, so it reads the daemon's own presence as the pane being busy and defers - every time.

This is structurally self-wedging: for the life of the away session, that pane can never read idle, so the escalation can never be delivered. The same signature appears in every away run launched this way since 2026-08-19. A production A/B across seven prior runs confirms it: every HERDR_ENV-launched run (daemon in-pane) wedged repeatedly, while the one run launched through the terminal-backed FM_SUPERVISOR_TARGET path ran 2h22m with a single deferral and zero wedges.

Full diagnosis: data/firstmate-afk-daemon-wedged-investigation/report.md (private task evidence, not part of this diff).

The fix

Route claude on the herdr backend through bin/fm-afk-launch.sh start (the existing non-visible tracked-terminal path, with the captain pane captured first and passed in as FM_SUPERVISOR_TARGET) instead of start-native. This is the same path already proven clean in the one successful control run above. Corrected the "the in-pane background job is harmless" belief recorded in three places: bin/fm-afk-start.sh, bin/fm-afk-launch.sh (header), and .agents/skills/afk/SKILL.md. Other harness/backend combinations are unaffected - only herdr's native agent_status path is implicated; tmux's rendered busy-fallback regex does not match the background-shell footer token, and grok on herdr is unproven either way, so both are left on the native path.

What this deliberately does NOT do

Does not teach the busy guard to subtract the daemon's own footer contribution from what it reads. That would couple firstmate to a private, versioned herdr ruleset (claude.toml, carrying its own updated_at) that already changes without notice - the ruleset is not a stable contract to build safety logic against.

What this does NOT fix

This cures the CAUSE (why the guard misread the pane), not the general problem (that a guard false-positive of any kind currently wedges silently for the life of a session). Bounding any future guard false-positive - by making the max-defer escape try a genuinely different path in rather than retrying the same failing guard - is a separate, sibling change (firstmate-afk-escape-and-delivery-logging) still in flight. Away mode is not yet safe against every possible guard false-positive after this PR; it is safe against this specific proven one.

Note on delivery route

This PR comes from a fork (NicholasACTran/firstmate) rather than a branch pushed directly to this repository, because the authenticated account used for this task has no push access to the upstream repository. Every other fm/ branch here is pushed directly; this one differs only for that credential reason.

Status

Do not merge. Holding to land together with its sibling ticket.

…cked path

A Claude Code background shell hosting the sub-supervisor daemon inside the
captain's own pane leaves a footer token that herdr's claude agent-detection
ruleset misreads as permanently "working", so the away-mode busy guard can
never read that pane idle and no escalation is ever delivered. Root cause
documented in data/firstmate-afk-daemon-wedged-investigation/report.md
(2026-08-26): 408 identical busy-guard deferrals over 95 minutes, versus a
clean 2h22m run on the terminal-backed FM_SUPERVISOR_TARGET path.

Route claude on the herdr backend through bin/fm-afk-launch.sh start (the
non-visible tracked terminal path) instead of start-native, and correct the
"it is fine" belief recorded in the afk skill and both launcher scripts'
header comments. Other harness/backend combinations are unaffected: tmux's
rendered busy-fallback regex does not match the background-shell footer
token, so only herdr's native agent-status path is implicated.

Deliberately not implemented: teaching the busy guard to subtract the
daemon's own footer contribution, since that couples firstmate to a private,
versioned herdr ruleset that already changes without notice.
@greptile-apps

greptile-apps Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The reviewed changes appear safe to merge because no blocking failure remains from the previously reported documentation inconsistency.

No blocking failure remains.

Reviews (2): Last reviewed commit: "docs(herdr): close the claude+herdr away..." | Re-trigger Greptile

Comment on lines +27 to +31
Its hosting differs by harness AND backend.
Pick the right path:
- **Harness WITH a native in-pane tracked-background tool** (e.g. claude's
background bash, grok's background tool): first run
- **Claude on the herdr backend: always use the terminal-backed path below, never `start-native`.**
A Claude Code background shell hosting the daemon in the captain's own pane leaves a `· 1 shell ·` token in that pane's rendered footer for as long as the daemon lives.
Herdr's own claude agent-detection ruleset maps that exact token to `agent_status = "working"` at a priority that beats the idle rule, so the away-mode busy guard reads the captain's pane as permanently busy and can never deliver an escalation into it for the life of the session - proven in `data/firstmate-afk-daemon-wedged-investigation/report.md` (2026-08-26), which found this in every claude+herdr away run since 2026-08-19.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Conflicting Herdr launch guidance

The skill now requires Claude on Herdr to use the terminal-backed path, while docs/herdr-backend.md still permits native tracked background execution and describes the terminal-backed launcher as the Pi fallback. Keeping both instructions allows the backend guide to route this combination through the in-pane path that wedges AFK delivery, so the authoritative backend documentation should be updated with the same exception.

docs/herdr-backend.md "Away-mode supervisor support" still described
native tracked-background execution as safe for every harness with the
capability, casting the terminal-backed launcher as the Pi-only fallback.
That contradicted the routing fix in .agents/skills/afk/SKILL.md and
bin/fm-afk-launch.sh: Claude on Herdr must not host the away daemon in
its own pane, because Herdr's Claude agent-detection ruleset reads the
daemon's own background-shell footer token as the agent working, at a
priority that beats the idle rule, which wedges the busy guard for the
life of the session.

State the same exception here, in this doc's own voice, so a session
that reads this file first gets the same answer as one that reads the
skill first.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Reviewed HEAD 86f889444f2c25eddc6cc357793d852cbbf9c872 (unstamped) vs main f7a387f44ed4fa942914e8944be4981a42e1e102. Full diff reviewed (.agents/skills/afk/SKILL.md, bin/fm-afk-launch.sh header, bin/fm-afk-start.sh header, docs/herdr-backend.md). Whole thread read (Greptile P2 on the Herdr doc gap, then the follow-up commit; current Greptile review is success). No .github/workflows/* change. Not disguised security.

Class: corrective. Claude on Herdr hosting the away daemon as an in-pane background shell leaves a footer token Herdr's claude agent-detection maps to working, so the busy guard never reads idle and escalations never deliver. Routing that combination through bin/fm-afk-launch.sh start (terminal-backed, FM_SUPERVISOR_TARGET) is the proven-clean path. Other harness/backend pairs are unchanged. Dispatch lives in the skill (agent-owned path pick), not a new scripted router — same pattern as the existing start vs start-native split.

This does not close #1956 or #3087. Those are watcher stale-hash / over-escalation bugs. This PR is the claude+herdr launch-path cause of a busy-guard false positive. No Fixes/Closes link.

Author body says: do not merge; hold to land with sibling #3090. Honoring that. Complementary to #3090 (bounding), not overlapping spawn-freshen or other standing holds.

VISION (per rule):

  • One captain, one interface — aligns. Restores escalation delivery so looking away is not silent.
  • Authority is explicit — aligns. No new autonomy; restores an existing away-mode grant. Deliberately does not couple to Herdr's private ruleset.
  • Scripts own the mechanics — aligns with the existing skill-owned launcher choice. The exception is recorded in the skill and the three comment/doc surfaces.
  • A restart is a non-event — aligns. Recovery still uses the recorded terminal id on the terminal-backed path.
  • Delegation with a spine — aligns. Supervision delivery is the contract being repaired.
  • The fleet outlives any vendor — aligns. Avoids encoding Herdr's versioned footer rules into the busy guard.
  • Scope — aligns.

What is not cleared:

  1. No no-mistakes-pipeline-attestation:v1 for this HEAD. Blocking for merge even after the author hold lifts.
  2. No executable regression that a claude+herdr away start takes start not start-native.
  3. Author hold: land together with fix(bin): bound the away-mode busy guard and log delivery outcomes #3090.
  4. Fork CI / Require-no-mistakes were approved after this review; they had not finished at comment time.

Security: no.

This is waiting on the author, not the captain: matching attestation, and the stated sibling-land hold.

Merge-eligible: NO. Captain-flag NOW: NO.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Reviewed the whole thread, full diff (.agents/skills/afk/SKILL.md, bin/fm-afk-launch.sh, bin/fm-afk-start.sh, docs/herdr-backend.md), sibling #3090, cross-refs #3087/#1956, and current main f7a387f44ed4fa942914e8944be4981a42e1e102 / VISION.md. Classification: corrective. No .github/workflows/* changes. No security finding.

VISION (per rule, inspected evidence):

  • One captain, one interface — aligns. Fixes the proven claude+herdr away-mode wedge so escalations can reach firstmate instead of buffering forever.
  • Authority is explicit — aligns. No new autonomy. Changes the agent-followed launch routing for one proven-bad harness/backend pair.
  • Scripts own mechanics / agents own judgment — aligns. Executable launch scripts are comment-only; the behavioral change is the skill's routing rule (which path the agent picks). That is agent judgment over harness/backend combo, not a script guessing meaning.
  • A restart is a non-event — aligns. No durable-state change.
  • Delegation with a spine — aligns. Safer away-mode delivery; does not invent a new task shape.
  • The fleet outlives any vendor — aligns. Explicitly refuses to subtract Herdr's private footer token from the busy guard (that ruleset is not a stable contract).
  • Scope — aligns. Command-layer AFK launch docs/skill, not the workshop.

Inspected the four-file diff: the only executable-path change is the skill instruction to use bin/fm-afk-launch.sh start (terminal-backed, FM_SUPERVISOR_TARGET) for Claude on Herdr, never start-native. Other harness/backend combinations stay on the native path. Greptile's earlier herdr-backend.md inconsistency was closed by 86f88944.

Not merging. There is no no-mistakes-pipeline-attestation:v1 matching current HEAD 86f889444f2c25eddc6cc357793d852cbbf9c872. The author asked to hold this with sibling #3090. Forge CI is already running on this HEAD — I did not approve a new first-time workflow run here. Waiting on the author for a matching no-mistakes attestation (and the sibling pairing). Not with the captain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants