Skip to content

Cross-Session Summary Contamination in Claude Code #2597

@phpmypython

Description

@phpmypython

Description

Claude Code incorrectly writes summaries from previous sessions into the current session's JSONL file when starting a new conversation in the same directory.

Steps to Reproduce

  1. Have a conversation in a project directory (Session A)
  2. Close Claude Code before summaries are generated for Session A
  3. Later (hours or days), start a new Claude Code session in the same directory (Session B)
  4. Check Session B's JSONL file (~/.claude/projects/<project-name>/<session-id>.jsonl)
  5. Observe that Session B's file contains summary entries from Session A

Expected Behavior

  • Summaries should be written to their original session files
  • Each session's JSONL file should only contain summaries for its own conversations

Actual Behavior

  • On startup, Claude Code scans all session files in the current directory
  • For any conversation chains lacking summaries, it generates them
  • These summaries are incorrectly appended to the CURRENT session file instead of their original files
  • This causes session files to contain unrelated summaries with leafUuid values pointing to messages in other sessions

Impact

  • Confuses session history and makes it difficult to understand conversation flow
  • Pollutes session files with unrelated content
  • The leafUuid values in summaries reference messages that don't exist in the current session

Additional Context

  • This appears to be caused by a delayed summary generation feature that runs on startup
  • The global session singleton writes all generated summaries to the current session file
  • Message UUIDs are reused across sessions (each appears exactly twice), which may be related to the session continuation feature

Environment

  • Claude Code version: 1.0.34
  • Platform: macOS Darwin 24.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions