Interactive session silently stopped persisting its transcript for 2+ weeks — inherited CLAUDE_CODE_CHILD_SESSION marker treated a primary user session as a child session
Summary
My main long-running interactive session (my "brain" session for a multi-week project) silently stopped writing its transcript to disk on Jul 9, while the session kept running normally for two more weeks (Jul 14–19 was heavy daily use: hundreds of tool calls, ~40–50% context used). Everything typed and generated after Jul 9 was permanently lost from the transcript. There was no warning at the time — the session looked completely normal.
Only after updating to a recent version (currently v2.1.215+) did the status line reveal the cause:
⚠ Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION marker · restart with CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 to keep future transcripts
The session had inherited the child-session environment marker — most likely because it was resumed from a terminal whose environment descended from another Claude Code process (I run a scheduled fleet of claude --print agents, and Windows Terminal tabs inherit the environment of the process that spawned them). From that point on, Claude Code classified my primary interactive session as a child session and dropped all transcript persistence — silently.
Environment
- Claude Code: bug active on ~v2.1.2xx (Jul 2026); warning line appeared after updating (v2.1.215 or later)
- OS: Windows 11 Home 10.0.26200
- Shell: Git Bash inside Windows Terminal
- Plan: Claude Max 5x; session ran Fable 5 / Opus 4.8
- Session ID:
212cc35b-6f1a-4ad3-a397-ed25fd18c535(project dirC--Users-david-Documents-MY-PORTFOLIO-agent-os)
Root cause — confirmed empirically (2026-07-23)
envinside the affected live session showsCLAUDE_CODE_CHILD_SESSION=1— the session process itself carries the marker.- The marker is exported to every subprocess of a Claude session (verified from a Bash tool call). So any terminal tab,
wt.exewindow, or script launched from inside any Claude session inherits it — and anyclaudelater started in that environment is silently classified as a child session with transcript persistence disabled. - Likely carrier in my case: a session-restore workflow that opens Windows Terminal tabs (via
wt.exe) withclaude --resumepre-filled, invoked from inside a running Claude session. Every restored tab inherited the marker; resuming my primary session from such a tab permanently flipped it to "child" behavior on each subsequent resume.
Timeline / evidence (all verifiable on my machine)
- Session transcript
212cc35b-….jsonl— last record Jul 9, 12:41 UTC; file never grew again (verified repeatedly, including today Jul 23 while the session was actively in use). ~/.claude/logs/session-212cc35b.log(per-session tool log) — proves hundreds of tool calls Jul 14–19, i.e. the session was alive and heavily used while zero transcript records were written.- Resuming the session repeatedly (including after
claude update) reproduced it: each resume kept inheriting the marker; every conversation after Jul 9 vanished on next resume. - After the CLI update, the status line now shows the
⚠ Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION markerwarning in this session. - Partial self-rescue: the session had run
/exporton Jul 6, Jul 16, and Jul 20, so some chat was recovered; Jul 17–19 conversation is permanently gone. - Related papercut: on Jul 20, bare
/exportand/export tragedy.txtin this session both failed withFailed to export conversation: EEXIST: file already exists, mkdir 'C:\Users\david\Documents\MY_PORTFOLIO\agent-os'— exporting to a subpath (docs/name.txt) worked.
Why this is severe
- Silent, long-duration data loss on the exact session type users care most about (long-lived primary sessions). Weeks of conversation lost with zero indication.
- The marker propagates invisibly through terminal environment inheritance — any user who ever opens a terminal (or whose terminal app was launched) from within a Claude-spawned process can poison their real sessions.
--resumeof an interactive, TTY-attached session should arguably never be treated as a child session, regardless of environment.
Suggested fixes
- Don't classify TTY-attached interactive sessions as children — clear/ignore
CLAUDE_CODE_CHILD_SESSIONwhen stdin is a TTY, or at minimum on--resumeof an existing user session. - The new warning is good — but make it blocking/loud on interactive startup (a one-time confirm), not a status-line footnote; the failure mode is silent data loss.
- Consider a periodic integrity check: if a session has produced N messages with zero transcript flushes, surface an error.
- Fix the
/exportEEXIST failure when exporting to the CWD on Windows.
Ask
Primarily reporting so this gets fixed. If any server/local recovery of the Jul 14–19 transcript records is possible, I'd love to hear it, but I understand they were likely never written.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗