Skip to content

JSONL cross-session contamination: all event types written to wrong session file when multiple sessions are active #26964

Closed as not planned

Description

@MitsunChieh

What's Wrong?

When multiple sessions are active in the same project directory, JSONL entries from one session are written into another session's JSONL file. All event types are affected — not just custom-title, but also assistant, user, system, progress, and queue-operation.

The cross-writes are bidirectional: session A's file contains entries from session B, and session B's file contains entries from session A. Events from different sessions are interleaved at sub-minute (sometimes sub-second) intervals within a single JSONL file.

Quantified impact

Three affected sessions (bfcfcd91, a5d6b936, 9600a743) in the same project:

File Entries with sessionId Cross-session entries Contamination rate
bfcfcd91 61 26 42.6%
a5d6b936 1,184 276 23.3%
9600a743 321 246 76.6%

Other JSONL files (7) in the same project directory are completely clean.

What Should Happen?

Each session's JSONL file should only contain entries belonging to that session. Entries should never leak into a different session's file.

Steps to Reproduce

Exact reproduction steps are not confirmed. Suspected trigger:

  1. Have multiple Claude Code sessions active simultaneously in the same project directory
  2. Interact with them in overlapping time windows
  3. Inspect the JSONL files — entries from different sessions will be interleaved in each other's files

Note: /resume was not used in the affected sessions (confirmed by scanning all entries for isResume, resumeFrom, source: "resume" — none found). This distinguishes this issue from #26563, which is triggered by /resume.

Evidence

Timeline interleaving in a5d6b936.jsonl

L599:  a5d6b936 ts=16:04:11  (own session)
L605:  9600a743 ts=16:26:37  ← 22min jump, foreign session injected
L617:  a5d6b936 ts=16:33:37  ← back to own session
L627:  bfcfcd91 ts=16:35:15  ← another foreign session
L646:  a5d6b936 ts=16:36:21  ← back to own session
...
L1040: a5d6b936 ts=18:01:33
L1041: bfcfcd91 ts=18:01:36  ← 3 seconds later, different session!
L1043: a5d6b936 ts=18:01:49  ← 13 seconds later, back again

Cross-written event types in a5d6b936.jsonl

141× assistant   (from bfcfcd91)
 98× user        (from bfcfcd91)
 12× system      (from bfcfcd91)
 12× progress    (from bfcfcd91)
  4× user        (from 9600a743)
  3× assistant   (from 9600a743)
  3× custom-title(from bfcfcd91)
  2× system      (from 9600a743)
  1× custom-title(from 9600a743)

Impact

  • Session history is unreliable: JSONL files may contain conversations from other sessions mixed in
  • Session names corrupted: custom-title cross-writes cause wrong names in the resume picker
  • Debugging is extremely difficult: a single JSONL file may contain interleaved entries from 3+ sessions

Claude Code Version

2.1.47 (Claude Code)

Platform

Anthropic API (subscription)

OS

macOS 14.6 (Darwin 23.6.0)

Related Issues

Activity

  1. github-actions commented on Feb 19, 2026

    @github-actions

    Found 2 possible duplicate issues:

    1. Hook payload session_id misattributed after /resume #26563
    2. CLAUDE_ENV_FILE: session ID mismatch on resume causes env files to be written to wrong directory #24775

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. MitsunChieh commented on Feb 19, 2026

    @MitsunChieh
    Author

    This is not a duplicate of #26563 or #24775.

    Updated findings — the problem is much larger than custom-title

    After deeper analysis of the raw JSONL files, the cross-session writing is not limited to custom-title events. All event types are affected:

    File Cross-session entries Contamination rate
    bfcfcd91 26 42.6%
    a5d6b936 276 23.3%
    9600a743 246 76.6%

    Cross-written event types include: assistant, user, system, progress, queue-operation, and custom-title. The events from multiple sessions are interleaved at sub-minute intervals in a single JSONL file.

    Why this is not #26563

    This issue (#26964) #26563
    Trigger No /resume used — confirmed by scanning all JSONL entries Explicitly triggered by /resume
    Direction Bidirectional (A→B and B→A) Unidirectional
    Likely cause Multiple sessions active simultaneously in the same project directory Session ID misattribution after /resume

    Why this is not #24775

    #24775 is about CLAUDE_ENV_FILE path mismatch — a completely different subsystem (environment variables vs JSONL storage).

    Revised description

    The original report focused on custom-title because that's where the issue was first noticed. The actual bug is broader: when multiple sessions are active in the same project, JSONL writes from one session can end up in another session's file. The custom-title cross-write is just one visible symptom.

    This may share an underlying root cause with #26563 (session ID management defects), but the trigger path is different and fixing one may not fix the other.

  3. changed the title [-]custom-title events for one session are written into a different session's JSONL file[/-] [+]JSONL cross-session contamination: all event types written to wrong session file when multiple sessions are active[/+] on Feb 19, 2026
  4. gonewx commented on Feb 20, 2026

    @gonewx

    This is a pretty serious data integrity issue. Cross-session contamination means you can not reliably review what happened in a specific session — the timeline is polluted with events from unrelated work.

    For teams that need reliable session audit trails, this makes multi-session workflows risky. If you are working on a critical feature in one session and debugging in another, contaminated logs make it impossible to reconstruct what actually happened.

    As a workaround, Mantra maintains independent session snapshots with proper isolation — each session gets its own timeline that you can browse, search, and restore. It watches the JSONL files but keeps its own clean index.

    Hope this gets fixed upstream though — session isolation should be a guarantee at the storage layer.

  5. github-actions commented on Mar 21, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  6. github-actions commented on Mar 28, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  7. locked as resolved and limited conversation to collaborators on Mar 28, 2026
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

    staleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions