Repository navigation
fix: show Pi GLM and Codex task workers in Herdr agents sidebar - #25
Merged
Merged
Conversation
… 9", by updating one stale test expectation in `tests/fm-spawn-pi-skill.test.sh`. **Cause:** `test_default_launch_is_unchanged` compares the full Pi worker launch command against an exact copy. This PR now wraps every Pi task worker launch in Herdr pane reports: a `working` report before launch, and an `idle` or `blocked` report after exit, based on the exit code. The saved copy still showed the old, unwrapped command, so the comparison failed. The sibling checks in `tests/fm-spawn-dispatch-profile.test.sh` only check that parts of the command are present, and they were already updated earlier in this PR. **Rule it broke:** the saved copy must match the launch command `bin/fm-spawn.sh` actually generates. It is the only exact-copy test of the Pi launch line. **Fix:** the expected string now includes the Herdr report before the launch and the exit-status report after it, taken exactly from the generated output. I made no changes outside the test. **Checks run:** - `tests/fm-spawn-pi-skill.test.sh`: all tests pass. - `tests/fm-spawn-dispatch-profile.test.sh`: all tests pass. - `shellcheck` shows only the SC1091 info note that was already there. **Not fixed:** locally, `tests/fm-kimi-harness.test.sh` also fails one case: "Kimi hook install refused a realistic config". That test covers Kimi hook installation, which this PR doesn't touch, and it wasn't in the failing CI shard. It most likely depends on this machine's setup, so I left it alone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Please also make sure that pi agents running glm or codex DO show in the agents sidebar
Context: "the agents sidebar" is Herdr's agent sidebar. Claude and Codex worker panes appear there (
herdr agent listlists them), but Pi workers launched by Firstmate do not: their panes reportagent_status: unknownandherdr agent explain <pane>returnsagent_not_found. Herdr's Pi integration is installed and current (herdr integration status: pi v9,~/.pi/agent/extensions/herdr-agent-state.ts), and the lean Pi launch inbin/fm-spawn.shexplicitly loads that extension with-e. Observed launch chain:sudo -n -E /usr/local/bin/op-broker run -f .env.op -- pi ..., which runsop run ... setpriv ... env -u XDG_CACHE_HOME -u XDG_CONFIG_HOME HOME=... PATH=... pi ....What Changed
bin/fm-spawn.shnow wraps every Pi task-worker launch (Codex and zai/GLM) with best-effortherdr pane report-agentcalls from inside the pane, under thefirstmate:pisource. It reportsworkingbefore launch, thenidleorblockedbased on the exit status. For zai, the wrapper covers the whole env-prefixedoprchain. The reports only run whenHERDR_PANE_IDis set andherdris on PATH, and a failed report never blocks the launch. The Pi task extension also reportsworkingonagent_startandidleonagent_settledfor the same pane, so a worker that stays open shows its real state.tests/fm-pi-zai-herdr-agent-report-live-e2e.test.sh, a live check that uses no API tokens. It runs the realfm-spawn.shagainst an isolated Herdr lab session with fake Pi binaries, and checks that the GLM and Codex workers show up inherdr agent listasagent=piand move fromworkingtoidle.tests/fm-spawn-dispatch-profile.test.shnow checks that the report wrapper is in the ship, GLM and scout launch lines.docs/verification/runtime-backends.mdexplains why Pi workers were missing: the op-broker/sudo/setpriv chain moves the worker off the pane's pty, and the reservedherdr:source prefix never creates a record. It also records the fix and the live test result.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is bounded: it adds best-effort Herdr telemetry that is guarded by HERDR_PANE_ID and never gates the launch. The earlier findings are fixed: the test now uses the repo's lab helper, the header comment matches the code, and the extension reports per-run state. The only gap left is that the new extension reporting has no test.
Testing
I ran the branch's live guard through fm-test-run on an isolated fm-lab Herdr session. It drives the real fm-spawn with a real opr chain, and both the GLM and Codex Pi worker panes showed up in
herdr agent listas pi, going from working to idle. The launch-profile composition test also passed, but it is not a live drive, so that scenario is recorded as untested live. I then ran two adversarial scenarios live on a second lab session. A zai launch that exits non-zero went to blocked. A real interactive Pi TUI worker with the generated task extension settled to done after its turn while Pi was still open, so it does not stay at working. All labs were torn down and the worktree is clean. I captured no sidebar screenshot because the sidebar is a TUI andherdr agent list/agent getare its data source. Their JSON output is the evidence.herdr agent listas agent=pi, working then idleherdr agent listas agent=pi, working then idleEvidence: Live Herdr e2e guard + launch profile test log
Source: Live Herdr e2e guard + launch profile test log
# zai Pi worker pane w1:p2 registered working then idle in isolated Herdr lab # Codex Pi worker pane w1:p3 registered working then idle in isolated Herdr lab ok - real fm-spawn + isolated Herdr lab: GLM and Codex Pi task workers appear in the agents sidebar with real agent_statusEvidence: Adversarial live scenarios log (blocked on failure; real interactive Pi settles)
Source: Adversarial live scenarios log (blocked on failure; real interactive Pi settles)
A pane w1:p2 while running: {"agent":"pi","agent_status":"working"} A pane w1:p2 after rc=3 exit: {"agent":"pi","agent_status":"blocked"} B pane w1:p3 start: {"agent":"pi","agent_status":"working"} B status after turn, Pi TUI still open: {"agent":"pi","agent_status":"done"}Evidence: Adversarial scenario driver script
Source: Adversarial scenario driver script
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
tests/fm-pi-zai-herdr-agent-report-live-e2e.test.sh:44- New live test hardcodes the helper pathHERDR_LAB_HELPER='~/.firstmate/bin/fm-herdr-lab.sh'(tests/fm-pi-zai-herdr-agent-report-live-e2e.test.sh:44). It points at a different checkout, not the repo under test. On any other machine or home, provision fails and the test reportsnot ok. On this machine it runs whatever helper version sits in ~/.firstmate, not the one on this branch, so the isolation guarantee the test cites (bin/fm-herdr-lab.sh owns isolation) is not checked against this tree. Every sibling Herdr e2e test uses${HERDR_LAB_HELPER:-$ROOT/bin/fm-herdr-lab.sh}, and bin/fm-herdr-lab.sh exists in the repo. Fix: use that same form.bin/fm-spawn.sh:189- The header usage comment in bin/fm-spawn.sh:189-192 says only the zai launch is bracketed with Herdr reports ("A zai launch adds onlyopr... and brackets that env-prefixed launch"). The code at bin/fm-spawn.sh:5130 brackets every Pi task worker, Codex included, and the inline comment and the docs say the same. Reword the header so it matches the code.🔧 Fix applied.
2 issues (1 warning, 1 info) still open:
bin/fm-spawn.sh:189- The header usage comment in bin/fm-spawn.sh:189-192 says only the zai launch is bracketed with Herdr reports ("A zai launch adds onlyopr... and brackets that env-prefixed launch"). The code at bin/fm-spawn.sh:5130 brackets every Pi task worker, Codex included, and the inline comment and the docs say the same. Reword the header so it matches the code.bin/fm-spawn.sh:5093- The pane-side bracket reportsworkingonly once, before launch, andidle/blockedonly after the Pi process exits. That fits the zai path, where the docs say Pi falls back to print mode under op run and exits after its run. It does not fit a Pi task worker that stays in its interactive TUI (--tui-mode regular, the Codex path with no opr). Once such a worker finishes its turn and sits idle at its prompt, Herdr keeps showingfirstmate:pi workinguntil the process exits. Nothing corrects that unless Pi's own herdr-agent-state extension reports and Herdr prefers its state, and the intent says that extension is silent. The live test uses a sleeping fake Pi, so it cannot show this.The stuck state also feeds Firstmate's own consumers of Herdr agent state, not just the sidebar label. Concrete sequence: a Codex Pi worker is idle at its prompt and the captain steers it via fm_backend_herdr_send_text_submit (bin/backends/herdr.sh:3281-3343). The raw baseline is
working, so the idle-baseline path is skipped. _fm_composer_pi_verdict now has identitypi, so a swallowed line classifiespendingwhere it used to beunknown. Once retries run out, fm_composer_queued_enter_verdict getsbusyfrom fm_backend_herdr_queued_enter_busy (herdr.sh:3265) and turns that pending intoempty. The steer is reported as delivered even though it was swallowed. Before this change, agent_not_found gave raw status '' and the result waspending, orunknownat the first composer read.Other consumers of the same stuck status:
busy.busy herdr-nativewhen no turn record exists.Possible remedies:
firstmate:pisource.This needs the author's call because it changes which launches get reports.
🔧 Fix applied.
1 info still open:
docs/verification/runtime-backends.md:144- Round 3 fixed review-3 by adding per-runfirstmate:pireports to the Pi task extension (bin/fm-spawn.sh:4619-4636). The verification doc now says an idle interactive worker reportsidlethrough that extension. Nothing checks that claim. The live guard uses sleeping fake Pi executables, so theworkingtoidletransition it asserts comes only from the wrapper's post-exit report (bin/fm-spawn.sh:5106). None of the round-3 changes run the generated extension'sagent_startoragent_settledhandlers. If the handlers never fire, orherdris not on the extension's PATH, the idle-at-prompt case still showsworking, the sidebar mislabel from review-3 returns, and no test fails. Fix: either mark that sentence as not live-verified, or extend the live guard so a fake Pi runs the generated extension's handlers and the test asserts the extension'sidlereport arrives while the process is still alive.✅ **Test** - passed
✅ No issues found.
herdr agent listas agent=pi, working then idleherdr agent listas agent=pi, working then idlebin/fm-test-run.sh tests/fm-pi-zai-herdr-agent-report-live-e2e.test.sh tests/fm-spawn-dispatch-profile.test.shROOT=$PWD bash ~/.no-mistakes/evidence/01M37P82SKXQ1DDBPMC1Q70ZG5/drive-adversarial.sh(scenario A: real fm-spawn zai worker whose Pi exits rc=3 in an isolated fm-lab Herdr session)same driver, scenario B: real fm-spawn Codex-path worker running the REAL Pi 0.86.1 TUI with its generated task extension (provider swapped to an invalid OpenAI key so no tokens are spent), status read viaherdr agent get/pane get/pane readwhile Pi stayed openchecked that the worktree is clean and no fm-lab-* sessions remain after teardown✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.