tmux/psmux auto-detection disables session transcript persistence — .jsonl never written

Open 💬 2 comments Opened Jun 23, 2026 by masa6161

Bug Description

When Claude Code is started inside a tmux (or psmux) session, the session transcript .jsonl file is never created in ~/.claude/projects/<project>/. The session runs normally — the user can interact, tools execute, hooks fire — but no conversation data is persisted to disk. On exit, the session is permanently lost with no recovery path.

The root cause is that claude.exe auto-detects the TMUX environment variable and injects --teammate-mode tmux into its own process command line, even when the user is running their primary session (not a teammate spawned by agent teams). This teammate classification apparently disables transcript persistence entirely.

Steps to Reproduce

  1. Start a tmux or psmux session:

``
tmux new-session -s work
``

  1. Inside the tmux pane, run:

``
claude
``

  1. Have a conversation (multiple turns, tool use, etc.)
  2. Exit with /exit
  3. Check ~/.claude/projects/<project>/no .jsonl file exists for this session

Expected Behavior

Session transcript .jsonl should be written to disk regardless of whether the session is running inside tmux.

Actual Behavior

  • ~/.claude/session-env/<uuid>/ directory IS created (session infrastructure works)
  • ~/.claude/projects/<project>/<uuid>.jsonl is never created (transcript persistence skipped)
  • --resume cannot find the session (no data on disk)
  • No errors are shown to the user — the failure is completely silent

Diagnostic Evidence

Process inspection confirms auto-injected flag

Running Get-CimInstance Win32_Process (Windows) on all claude.exe processes:

| Launch context | Actual command line | .jsonl |
|---|---|---|
| Normal terminal | claude.exe | ✅ Created |
| Inside tmux | claude.exe --teammate-mode tmux | ❌ Never created |
| Inside tmux + explicit override | claude.exe --teammate-mode in-process | ❌ Never created |

The user typed bare claude in all cases — the --teammate-mode tmux flag is injected by the binary itself.

Debug log (--debug-file) confirms

[TeammateModeSnapshot] Captured from CLI override: tmux

This line appears even when the TMUX environment variable is explicitly unset ($env:TMUX = $null), suggesting detection uses process tree inspection, socket file scanning, or another mechanism beyond the env var.

Other debug observations:

  • [concurrentSessions] updatePidFile failed: ENOENT — repeated PID file write failures in ~/.claude/sessions/
  • Zero transcript-related log entries — no append, write, flush, or error messages about session .jsonl files. The persistence code path appears to be entirely skipped.
  • MCP server "ide": Connection failed — expected (not in IDE), but confirms IDE is not handling persistence either

Timeline analysis

In ~/.claude/session-env/, 97+ session directories exist spanning weeks. In ~/.claude/projects/<project>/, only 14 .jsonl files exist — all created on or before 2026-06-16. After that date, no new .jsonl files were ever created for tmux sessions, though the user had dozens of sessions.

The one session that continued to be updated (5e0cb126, modified 2026-06-23) was originally created before the issue began and was resumed via --continue.

Attempted mitigations (all failed)

| Mitigation | Result |
|---|---|
| Unset $env:TMUX | Still detected, --teammate-mode tmux still injected |
| Unset $env:TERM_PROGRAM, $env:VSCODE_INJECTION, all VSCODE_* vars | No effect |
| Change settings.json teammateMode from "auto" to "in-process" | CLI override takes precedence |
| Explicit --teammate-mode in-process CLI flag | .jsonl still not created |
| --debug-file run | Confirmed teammate auto-detection, no persistence logs |

Only starting Claude outside tmux entirely produces a working .jsonl.

Root Cause Analysis

Two issues combine:

  1. Overly aggressive tmux auto-detection: claude.exe detects tmux and assumes the session is a teammate (spawned by agent teams), when in reality the user is running their primary interactive session inside tmux as their normal workflow.
  1. Teammate sessions skip transcript persistence: When classified as a teammate, the session does not write a .jsonl file at all. Even if this is intentional for actual teammates (whose data might be managed by the lead session), it should not apply to primary sessions that happen to run inside tmux.

Suggested Fix

  • Do not disable transcript persistence for any session type. Even teammate sessions should persist their transcripts for debugging and recovery.
  • OR distinguish between "user manually running in tmux" and "Claude Code spawned this as a teammate pane" — e.g., by checking for a specific env var that only the team-spawning code sets.

Environment

  • OS: Windows 11 (10.0.26200)
  • Claude Code: v2.1.186
  • Terminal multiplexer: psmux (native Windows tmux, via winget)
  • Shell: PowerShell 7 inside psmux, launched from VS Code integrated terminal
  • Settings: teammateMode: "auto", CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: "1"
  • Plugins: oh-my-claudecode, codex, agentmemory

Related Issues

  • #57203 — Sessions missing from --resume list (my earlier comments on this issue describe the same root cause)
  • #34150 — psmux support for Claude Code agent teams (CLOSED/stale) — documents that psmux deliberately sets TMUX env var for tmux compatibility
  • #53417 — Resumed sessions silently stop writing to session JSONL after version upgrade (similar silent persistence failure pattern)
  • #29207 — teammateMode: "tmux" silently falls back to in-process

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗