Skip to content

Interactive Claude sessions: transcript not persisted at reported path → session metrics silently empty (0 records) #523

Description

@8nevil8

Description

For interactive Claude Code sessions launched via codemie-claude, Claude Code (2.1.218) does not write its session transcript JSONL to ~/.claude/projects/<cwd>/<session>.jsonl — the project dir contains only a memory/ subdir. However, Claude's SessionStart/UserPromptSubmit hook payload still reports that transcript_path, and CodeMie's correlation marks it status: "matched". At Stop/SessionEnd, the metrics processor reads the absent path, reports "0 records processed", and writes no sessions/*_metrics.jsonl. Session metrics are silently lost, and correlation reports matched for a file that doesn't exist — masking the gap.

Headless --task mode persists the transcript normally, so its metrics work.

Steps to Reproduce

  1. Run the agent suite: npm run test:integration:agent (or just TC-024 in tests/integration/agent-model.test.ts).
  2. TC-024 drives codemie-claude interactively via node-pty, does a /model switch + a prompt, then /exit.
  3. Observe the session's logs/debug-*.log: hooks fire, but both Stop and SessionEnd log Session processing complete: 0 records processed.
  4. ~/.claude/projects/<cwd-hash>/ contains only memory/ — no .jsonl.

Expected Behavior

Interactive-session metrics are recorded (a sessions/*_metrics.jsonl is written with the model used), as with --task mode.

Actual Behavior

No metrics file is produced; getLatestMetricsRecord throws No metrics files found. The transcript at the correlated path never exists on disk.

Investigation (ruled out)

Temp vs persistent cwd · workspace trust · the /model switch · provider (ai-run-sso vs anthropic-subscription) · session duration / turn count (4 turns / 75s) · flush-on-clean-exit. A "normally" launched interactive codemie-claude session (same claude --plugin-dir … invocation) does persist its transcript, so the trigger appears specific to how a programmatically-driven (node-pty) interactive session is handled by Claude Code — i.e. likely an upstream transcript-persistence behavior, not CodeMie logic.

Partial mitigation (already landed)

src/cli/commands/hook.ts now logs an explicit WARN when the reported transcript path is missing (or empty) at Stop/SessionEnd, instead of silently reporting "0 records processed", so the gap is diagnosable.

Suggested follow-ups

  • Don't mark correlation matched for a transcript path that doesn't exist on disk.
  • Bisect Claude Code versions to confirm where interactive-PTY transcript persistence changed.
  • Adjust TC-024 to assert against the API-sent session metric, or drive the model check via --task.

Environment

Field Value
OS Darwin 25.5.0 arm64
Node.js v26.5.0
CodeMie CLI 0.15.0
Claude Code 2.1.218
Shell / Terminal zsh / ghostty

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions