Repository navigation
fix(bin): save Claude second mate transcripts and keep model and effort on relaunch - #21
Merged
Merged
Conversation
…d effort on relaunch A Herdr pane inherits its server's environment, so a server first started from a Claude session hands CLAUDE_CODE_CHILD_SESSION to every pane, and Claude then turns transcript saving off outside tmux. Claude secondmate launches now carry CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 in the command. fm-control relaunch let a secondmate pin with no model or effort token reset both axes to default. A pin without a token now leaves that axis at its recorded value when the harness stays the same. Also stub pi in the Herdr Pi relaunch test so it no longer needs a real Pi install.
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
Start the fix so the life mate second mate is sturdy across restarts: launch Claude second mates with chat saving on, and keep their model and effort on relaunch.
Context: 2026-11-06, the life mate came back from a relaunch with model=default effort=default instead of what it had, and setting CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 did not reach the herdr pane. On 2026-11-08 its pane still shows "Transcript saving is off - inherited CLAUDE_CODE_CHILD_SESSION marker - restart with CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1", so a restart loses its conversation.
What Changed
bin/fm-spawn.shnow putsCLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1at the start of a Claude second mate's launch command. Transcript saving stays on even when the Herdr pane inherits aCLAUDE_CODE_CHILD_SESSIONmarker. Other task kinds launch as before.config/secondmate-harnesspin names neither and the harness stays the same. This covers both a manual relaunch (bin/fm-control.sh) and the automatic liveness respawn (bin/fm-spawn.sh). Before this, those values were reset todefault. A pin token or an explicit--model/--effortflag still takes precedence.tests/fm-control-relaunch.test.sh,tests/fm-secondmate-harness.test.shandtests/fm-secondmate-liveness.test.sh. Updated the CHANGELOG, the Claude harness-adapter reference and the docs (agent-control.md,configuration.md,verification/runtime-backends.md).🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is small and well-bounded: an env prefix added only to Claude secondmate launches, plus a same-harness fallback to the recorded model and effort, applied consistently in fm-control relaunch and the fm-spawn secondmate pin resolution that the liveness respawn uses, with behavioral regression tests for each path.
Testing
I ran the 3 affected test files. All passed, including the 3 new tests for chat saving, the relaunch profile and the liveness-respawn profile. A red run against the base fm-spawn.sh showed that the liveness regression test fails without the fix. I also saved the generated Claude secondmate launch command: CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 sits inline even when CLAUDE_CODE_CHILD_SESSION=1 is inherited. This is a CLI change with no UI, so there are no screenshots. I did not start a real Claude in a real herdr pane, so Claude honoring the override is taken from Claude's own documented behavior. The worktree is clean.
Evidence: Captured Claude secondmate launch command, with CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 inline
Source: Captured Claude secondmate launch command, with CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 inline
Evidence: Red run: liveness respawn regression test fails against the base fm-spawn.sh
Source: Red run: liveness respawn regression test fails against the base fm-spawn.sh
not ok - a pin naming no model must keep the recorded model across the liveness respawnEvidence: fm-secondmate-liveness test log (fixed)
Source: fm-secondmate-liveness test log (fixed)
Evidence: fm-control-relaunch test log (fixed)
Source: fm-control-relaunch test log (fixed)
Evidence: fm-secondmate-harness test log (fixed)
Source: fm-secondmate-harness test log (fixed)
Notes
Skills used: firstmate-coding-guidelines
Also tidied: the Herdr Pi relaunch test in
tests/fm-control-relaunch.test.shnow stubspilike its sibling tests, so it no longer fails on a machine without Pi installed.Reproduction (Claude Code 2.1.319, outside tmux):
CLAUDE_CODE_CHILD_SESSION=1 claudeprints "Transcript saving is off" and writes no transcript, whileCLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 CLAUDE_CODE_CHILD_SESSION=1 claudewrites one. The Herdr server inheritsCLAUDE_CODE_CHILD_SESSION=1from the Claude session that started it, and every pane inherits the server environment, so an env var set in fm-spawn's own shell never reaches the pane. The override now sits inline in the launch command. The dated record is indocs/verification/runtime-backends.md.Regression proof: with
bin/fm-spawn.shandbin/fm-control.shreverted to the base commit, the new tests fail:tests/fm-control-relaunch.test.sh: "not ok - a pin with no model token should keep the recorded model, got 'default'"tests/fm-secondmate-harness.test.sh: "not ok - Claude secondmate launch must force transcript saving in the launch command itself"tests/fm-secondmate-liveness.test.sh: "not ok - a pin naming no model must keep the recorded model across the liveness respawn" (see the evidence above)With the fix, all three pass, and
tests/fm-spawn-dispatch-profile.test.shpasses unchanged, which shows ship and scout launches are not affected.Noticed:
CLAUDE_PID,CLAUDE_CODE_SESSION_ID,CLAUDE_CODE_MESSAGING_SOCKET/TOKENandCLAUDE_EFFORTinto every pane. Starting the Herdr server from fm-spawn with those removed would fix the root cause, but that needs Herdr lifecycle work and is out of scope here.Better idea:
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-secondmate-liveness-lib.sh:373- The 'keep model and effort on relaunch' fix only coversfm-control.sh <id> relaunch(bin/fm-control.sh:1048-1062). The other way a secondmate comes back after a restart is the automatic liveness relaunch. When a mate reads as dead or missing (crash, host restart, closed pane), the session-start sweep and the watcher tick callfm-spawn.sh <id> --secondmate --backend <b>with no --model or --effort (bin/fm-secondmate-liveness-lib.sh:373-378). fm-spawn then fills model and effort only from the pin (bin/fm-spawn.sh:3450-3463) and never reads the recorded meta. Concrete case: pinclaude, metamodel=opus effort=high, the pane dies, the auto-relaunch runs, and the mate comes back with model=default effort=default. That is exactly the 2026-11-06 symptom. The two relaunch paths now also disagree for the same mate. Suggested fix: resolve this at one shared boundary. Either have the liveness respawn pass the recorded model/effort when the pin names neither and the harness is unchanged, or move the 'pin token, else recorded value on the same harness' rule into fm-spawn's secondmate pin resolution so every respawn path gets it. This changes respawn semantics for secondmates, so it needs the author's sign-off.bin/fm-control.sh:1048- Behavior change: before this change, removing the model or effort token from config/secondmate-harness (for exampleclaude opus high->claude) and running relaunch reset the mate to the harness defaults. That matched what a fresh spawn does with a bare pin. Now the relaunch keeps the recorded opus/high, and the only way back to defaults is an explicit--model default --effort default. The pin can no longer express 'use the harness default'. Please confirm this is intended and that the operator docs (docs/agent-control.md:83) give enough guidance.🔧 Fix: Keep recorded secondmate model and effort on liveness respawn
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-secondmate-harness.test.sh- all passed, including the newtest_spawn_claude_secondmate_forces_session_persistence, which spawns with CLAUDE_CODE_CHILD_SESSION=1 inheritedbash tests/fm-secondmate-liveness.test.sh- all passed, including the newtest_sweep_respawn_keeps_the_recorded_model_and_effortbash tests/fm-control-relaunch.test.sh- all passed, including the newtest_secondmate_relaunch_without_pin_tokens_keeps_recorded_profileRed check: swapped in the base-commitbin/fm-spawn.shand re-rantests/fm-secondmate-liveness.test.sh. It failed with 'a pin naming no model must keep the recorded model across the liveness respawn', so the regression test reproduces the 2026-11-06 symptom. Restored the file afterwards.Ran the session-persistence spawn test alone from a temporary copy of the test file (deleted afterwards) and saved the exact Claude secondmate launch command it captured✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.