[BUG] Session transcripts and prompt history vanish while other session files survive

Status Open
Reported on v2.1.291
Maintainer reply None cached
Activity 1 comment · opened Oct 6, 2026

What's Wrong?

Update, 7 October: I found the trigger and can now reproduce it. An interactive claude started with CLAUDE_CODE_CHILD_SESSION=1 in its environment runs normally but never writes its transcript, its subagent transcripts or its history.jsonl lines, which is exactly the pattern below. My earlier test that "ruled this out" used -p mode, which does save. The details below show how big the loss can get and how invisible it is. Updated sections: Steps to Reproduce, and the notes at the end.

I run several Claude Code sessions side by side, one per terminal tab, and often park one and come back to it days later with claude --resume.

Over the last two months, more and more of those resumes have failed with No conversation found with session ID. Forking fails the same way. When I looked properly, I found it had happened in two separate episodes:

  • 15 to 23 August
  • 23 September to 3 October

Counting only sessions that clearly did real work (they edited files or saved tool output), 61 of 188 sessions from August to October can no longer be resumed or forked. Almost all of them fall inside those two windows. These were not empty sessions; one of them had 72 prompts and about 480 tool calls.

Nothing warned me at the time. Each session worked normally while I used it. I only found out when I went back to it.

What makes this unusual: only the conversation itself is gone. The transcript file, the subagent transcripts, and the prompts in my prompt history (history.jsonl) are missing. Everything else Claude keeps for those same sessions is still on disk: file-edit checkpoints, saved tool outputs, subagent metadata, session environment folders. So the sessions clearly existed and ran; only their conversation records are gone.

I think this may be the same loss reported in #88126, which was filed on 20 August, during my first episode. This report adds what that one does not have: exactly which records disappear, that it came back in a second episode on different versions, and the dates of both. Details are in the sections at the end.

What Should Happen?

A session I worked in should stay resumable until I delete it or my cleanupPeriodDays setting (365) expires it.

Error Messages/Logs

$ claude --resume 6a354e85-4d26-4eb5-a130-2af7285f39c0
No conversation found with session ID: 6a354e85-4d26-4eb5-a130-2af7285f39c0

$ claude --resume 6a354e85-4d26-4eb5-a130-2af7285f39c0 --fork-session
No conversation found with session ID: 6a354e85-4d26-4eb5-a130-2af7285f39c0

Steps to Reproduce

This reproduces every time on 2.1.291:

  1. In a terminal, run CLAUDE_CODE_CHILD_SESSION=1 claude.
  2. Send one prompt. The model answers normally.
  3. Run /exit. No "Resume this session with" line is printed.
  4. No <id>.jsonl exists under ~/.claude/projects/, history.jsonl has no new line, and claude --resume <id> says No conversation found.

Without the variable, the same steps save the session. CLAUDECODE=1 or CLAUDE_CODE_SESSION_ID alone do not cause it. In -p mode the session is saved even with the variable set.

How the variable got there: on my machine, a Claude session ran code -g <file> from its Bash tool. That started VS Code with Claude's environment, so every VS Code terminal inherited CLAUDE_CODE_CHILD_SESSION=1, and every claude started there stopped saving, silently, until VS Code was fully quit. I caught two live sessions in that state on 6 October. For the two earlier episodes I cannot prove the same path, because process environments are not recorded anywhere, but the files left behind match exactly.

When the earlier episodes happened:

  1. Both episodes happened while I kept one long-running terminal app open with many Claude Code sessions in its tabs, some running for hours or days, while Claude Code updated itself in the background.
  2. First episode, 15 to 23 August: surviving sessions from around then ran 2.1.232 to 2.1.235.
  3. Second episode, 23 September to 3 October: surviving sessions ran 2.1.281 just before and 2.1.287 just after, so the lost ones ran the versions in between.
  4. On 5 October I restarted the terminal app, and sessions started there have been saved normally since. On 6 October I found two more unsaved sessions running in VS Code terminals, which led to the trigger above.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

Unclear: it came and went. Sessions on 2.1.281 and on 2.1.287 and later survive; see the episode versions above.

Claude Code Version

Episodes on roughly 2.1.232 to 2.1.235 (August) and on the versions between 2.1.281 and 2.1.287 (September to October). Exact versions are unknown because the auto-updater removes old binaries. Still happening on 2.1.291, reproduced as above.

Platform

Anthropic API

Operating System

macOS (Darwin 25.5.0, arm64)

Terminal/Shell

Other (an Electron terminal app built on xterm.js, login zsh per tab)

Additional Information

What I know, and what I don't. These sessions ran (their other records are on disk) and their conversation files were never written: the reproduction above produces the same set of missing and surviving files. What I cannot prove is how the variable reached the terminals in the August and September episodes.

<details>
<summary>Exactly which files are missing and which survive</summary>

| Record | For the affected sessions |
|---|---|
| projects/<project>/<id>.jsonl (the transcript) | missing |
| Prompts in history.jsonl | none at all from 16 to 23 August, and none from 25 September to 1 October |
| projects/<project>/<id>/subagents/agent-*.jsonl | missing (145 subagent .meta.json files across 27 sessions have no transcript beside them; 24 of those sessions have also lost their main transcript) |
| projects/<project>/<id>/subagents/agent-*.meta.json | present |
| projects/<project>/<id>/tool-results/* | present |
| file-history/<id>/ | present wherever the session edited files |
| session-env/<id>/ | present |

Every .jsonl belonging to these sessions is missing; every other file type is present.

</details>

<details>
<summary>How I counted</summary>

Claude creates a session-env/<id>/ folder for every session, and it survived for all affected sessions, so it serves as a list of sessions that started. Headless runs that deliberately save nothing also create one, so I counted only sessions that clearly did work: those with a file-history/<id>/ folder or a projects/<project>/<id>/ folder. That gives 188 sessions from August to October, 61 of them with no transcript anywhere under ~/.claude/projects, dated by their earliest surviving file: 18 from 15 to 19 August, 1 on 10 September, and 42 from 23 September to 3 October. (Counted on 6 October, before I found the two live VS Code sessions.)

Separately, my terminal app records each session id when it starts (from a SessionStart hook), and its log independently confirms the second episode: of 91 ids it recorded, 74 have no transcript, and 70 of those 74 had prompts typed in them. A text search of every remaining transcript for the largest missing ids finds nothing, so the conversations were not moved into another file.

</details>

<details>
<summary>Why the files were never written (confirmed by the reproduction)</summary>

In each affected subagents/ folder, the folder's modification time equals the write time of its newest .meta.json. If the subagent transcripts had been deleted in place later, the folder's time would have moved forward at that moment. Nothing syncs or copies ~/.claude on this machine.

</details>

<details>
<summary>What I ruled out</summary>

  • Retention cleanup: cleanupPeriodDays is 365, and older transcripts on both sides of each gap survive.
  • Resuming from the wrong folder: resuming a known session from another folder works.
  • Deleting sessions in the Desktop app (#98642): the Desktop session store has no deletion markers and none of the affected ids, and that bug also removes file-history, which survives here.
  • A command in any surviving transcript that deletes from ~/.claude/projects or rewrites history.jsonl: none found.

</details>

<details>
<summary>How this relates to #88126 and #98642</summary>

  • #88126 (silent deletion, filed 20 August on CLI 2.1.236) falls inside my first episode and is probably the same bug. It does not say which records disappear, and it predates my second episode.
  • #98642 (deleting from the Desktop sidebar since 2.1.284) needs a user action in the Desktop app and also removes file-history; neither applies here.

</details>

Suggested fix: an interactive session started by a person should not be treated as a child session just because the variable is inherited. At minimum, warn at startup that this session will not be saved.

Workaround until then: quit VS Code fully and reopen it from the Dock, or run unset CLAUDE_CODE_CHILD_SESSION before claude.

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet (updated: other reports of the same variable may exist; the closest I linked, #88126, may be the same bug)
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code (2.1.291)

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗