Skip to content

fix(bin): preserve transcripts for launched Claude workers - #8

Merged
rega10 merged 2 commits into
mainfrom
fm/fm-claude-child-session-persistence
Jul 27, 2026
Merged

fix(bin): preserve transcripts for launched Claude workers#8
rega10 merged 2 commits into
mainfrom
fm/fm-claude-child-session-persistence

Conversation

@rega10

@rega10 rega10 commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Intent

Fix Firstmate so an inherited parent Claude CLAUDE_CODE_CHILD_SESSION marker cannot disable transcript saving for Firstmate-launched Claude workers or second mates. Ship the durable fix through no-mistakes.

Deliberate design choices from implementation:

  • Root cause: Claude Code 2.1.220 disables transcript saving when CLAUDE_CODE_CHILD_SESSION is inherited from an ancestor, showing "Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION marker"; the previous Claude launch template only set CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false and left the parent identity pack intact.
  • Chosen environment contract (smallest verified independent top-level session): per-launch env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_SESSION_ID -u CLAUDE_PID -u CLAUDE_JOB_DIR plus the existing prompt-suggestion suppress, applied only in bin/fm-spawn.sh's Claude launch_template. Does not use CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 as the primary fix because that re-enables saving while keeping child-session semantics.
  • Scope: only Firstmate-launched Claude ordinary workers and second mates at the shared launch template; no global captain shell/Claude config mutation; non-Claude harnesses untouched. Autonomy flags, model/effort, prompt-suggestion suppression, turn-end, trust, and secondmate semantics preserved.
  • All spawn-capable backends (tmux, herdr, zellij, orca, cmux) share the same launch template, so they pick up the sanitize without per-backend copies.
  • Regression coverage: tests/fm-claude-session-env.test.sh pins ship and secondmate launch lines and evaluates the env prefix against a fake claude. Live CLI evidence recorded in docs/verification/supervision.md without transcript contents or credentials. harness-adapters documents the fact.

What Changed

  • Sanitize inherited Claude child-session identity variables in the shared launch template so Firstmate-launched workers and secondmates retain transcript saving across all spawn backends.
  • Preserve existing Claude launch options and non-Claude harness behavior while documenting the Claude-only environment contract and verification evidence.
  • Add regression coverage for ordinary worker and secondmate launch commands, effective environment cleanup, and preservation of unrelated variables.

Risk Assessment

✅ Low: The change is narrowly scoped to the shared Claude launch template, clears the complete specified parent identity pack for ordinary workers and secondmates across all backends, preserves existing launch semantics, and includes aligned regression coverage and verification documentation.

Testing

Baseline diff inspection, focused worker/second-mate environment tests, dispatch and non-Claude regression checks, the Orca launch path, and a manual effective-environment capture all passed; the evidence shows inherited Claude identity removed while prompt suppression, arguments, and unrelated environment remain intact.

Evidence: Claude session environment transcript

Polluted parent markers were all unset in the launched fake Claude process; prompt suggestions remained disabled and unrelated environment was preserved.

polluted parent environment before Firstmate launch:
  CLAUDE_CODE_CHILD_SESSION=1
  CLAUDE_CODE_SESSION_ID=parent-session-id
  CLAUDE_PID=4242
  CLAUDE_JOB_DIR=/tmp/parent-claude-job
  FM_TEST_UNRELATED_ENV=preserved

Firstmate Claude launch prefix:
  env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_SESSION_ID -u CLAUDE_PID -u CLAUDE_JOB_DIR CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false claude --dangerously-skip-permissions

effective Claude launch environment:
  CLAUDE_CODE_CHILD_SESSION=<unset>
  CLAUDE_CODE_SESSION_ID=<unset>
  CLAUDE_PID=<unset>
  CLAUDE_JOB_DIR=<unset>
  CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false
  FM_TEST_UNRELATED_ENV=preserved
received argv: <--dangerously-skip-permissions> <sample-brief>

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • git status --short and git diff --stat 21938d694ef7ea22b93200f96eada98b17adc169..7f86ea6ffcc5886d91d2ef45025a45b2b387f5bf
  • tests/fm-claude-session-env.test.sh
  • tests/fm-spawn-dispatch-profile.test.sh
  • tests/fm-kimi-harness.test.sh
  • tests/fm-backend-orca.test.sh
  • Manual polluted-parent launch through the exact env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_SESSION_ID -u CLAUDE_PID -u CLAUDE_JOB_DIR prefix against a fake claude, captured to the evidence transcript
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

When a primary still carries Claude Code's intentional child-session
identity (CLAUDE_CODE_CHILD_SESSION and related vars), firstmate-launched
Claude workers and secondmates inherited it and disabled transcript
saving. Clear that identity pack on the Claude launch template only so
each direct report gets an independent, resumable session without
touching non-Claude tools or the captain's shell.
@rega10
rega10 merged commit f788e23 into main Jul 27, 2026
10 checks passed
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