[QUANTUM BUG] Session ID Inconsistency When Resuming Session, Depending On SessionStart Hook's JSON Output Content
Resolved 💬 4 comments Opened Sep 22, 2025 by janbam Closed Jan 6, 2026
Bug Description
[QUANTUM BUG] Claude Code reports new session id when resuming a session but keeps using the original session id and appends to the old transcript file when a SessionStart Event Hook command's json output's hookSpecificOutput.additionalContext field contains a debug log.
The observer effect is strong with this one.
The bug only exists when you try to debug it 😅🌀🤪
Environment Info
- Platform: linux
- Terminal: kitty
- Version: 1.0.120
- Feedback ID: 5ddd8714-1ed3-4ef0-a847-a0e171b70442
Errors
[]
Transcript
╭────────────────────────────────────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /home/jan/ai/claude/cc-misc/contextsize-awareness-for-claude/test-sessions │
│ │
│ ──────────────────────────────────────────────────────────────────────────────── │
│ │
│ Overrides (via env): │
│ │
│ • Max thinking tokens: 14000 │
╰────────────────────────────────────────────────────────────────────────────────────╯
> <session-start-hook>
<system-information>
New Session Start:
Maximum Context Window: 186,000 tokens
(Thinking Budget: 14,000 tokens)
</system-information>
<debug-log>
2025-09-22T19:00:10.198Z: === HOOK EXECUTION START ===
2025-09-22T19:00:10.198Z: Raw input received:
{"session_id":"d5744d24-5fff-4171-9fb3-b11060a72329","transcript_path":"/home/jan/.claude/projects/-home-jan-ai-claude-cc-mi
sc-contextsize-awareness-for-claude-test-sessions/d5744d24-5fff-4171-9fb3-b11060a72329.jsonl","cwd":"/home/jan/ai/claude/cc-
misc/contextsize-awareness-for-claude/test-sessions","hook_event_name":"SessionStart","source":"startup"}
2025-09-22T19:00:10.198Z: ✓ JSON parsed successfully
2025-09-22T19:00:10.198Z: Hook event: SessionStart
2025-09-22T19:00:10.198Z: Session ID: d5744d24-5fff-4171-9fb3-b11060a72329
2025-09-22T19:00:10.198Z: Transcript path: /home/jan/.claude/projects/-home-jan-ai-claude-cc-misc-contextsize-awareness-for-
claude-test-sessions/d5744d24-5fff-4171-9fb3-b11060a72329.jsonl
2025-09-22T19:00:10.198Z: Working directory: /home/jan/ai/claude/cc-misc/contextsize-awareness-for-claude/test-sessions
2025-09-22T19:00:10.198Z: Source: startup
2025-09-22T19:00:10.198Z: Permission mode: undefined
2025-09-22T19:00:10.198Z: ✓ Input validation passed - all required fields present
2025-09-22T19:00:10.198Z: === SESSIONSTART EVENT PROCESSING ===
2025-09-22T19:00:10.198Z: SessionStart detected with source: "startup"
2025-09-22T19:00:10.198Z: Determining session type from source...
2025-09-22T19:00:10.198Z: ✓ Source "startup" → sessionType: "new"
2025-09-22T19:00:10.198Z: Generating initial message for session type: new
2025-09-22T19:00:10.198Z: Selected message type: "initial" based on sessionType: "new"
</debug-log>
<hookdata>
{
"session_id": "d5744d24-5fff-4171-9fb3-b11060a72329",
"transcript_path": "/home/jan/.claude/projects/-home-jan-ai-claude-cc-misc-contextsize-awareness-for-claude-test-sessions/
d5744d24-5fff-4171-9fb3-b11060a72329.jsonl",
"cwd": "/home/jan/ai/claude/cc-misc/contextsize-awareness-for-claude/test-sessions",
"hook_event_name": "SessionStart",
"source": "startup"
}
</hookdata>
</session-start-hook>
> hi! i'm janbam :)
what's the session id?
✻ Thinking…
The user is asking for the session ID. I can see from the session-start-hook that the session ID is
"d5744d24-5fff-4171-9fb3-b11060a72329". The user is janbam, and they're just asking a simple question about the session ID
which I can see in the hook data.
According to my instructions, I should be concise and direct. This is a simple factual question that I can answer immediately
from the hook data.
● Hi janbam! 👋
The session ID is: d5744d24-5fff-4171-9fb3-b11060a72329
<<<<<<<<<<<<<<< claude --verbose -c >>>>>>>>>>>>>>>>>>>>>
> <session-start-hook>
<system-information>
Resumed session - context measurement in progress
Maximum Context Window: 186,000 tokens
</system-information>
<debug-log>
2025-09-22T19:01:29.936Z: === HOOK EXECUTION START ===
2025-09-22T19:01:29.937Z: Raw input received:
{"session_id":"0c772589-6645-42a0-aed4-441a3cfd5665","transcript_path":"/home/jan/.claude/projects/-home-jan-ai-claude-cc-mi
sc-contextsize-awareness-for-claude-test-sessions/0c772589-6645-42a0-aed4-441a3cfd5665.jsonl","cwd":"/home/jan/ai/claude/cc-
misc/contextsize-awareness-for-claude/test-sessions","hook_event_name":"SessionStart","source":"resume"}
2025-09-22T19:01:29.937Z: ✓ JSON parsed successfully
2025-09-22T19:01:29.937Z: Hook event: SessionStart
2025-09-22T19:01:29.937Z: Session ID: 0c772589-6645-42a0-aed4-441a3cfd5665
2025-09-22T19:01:29.937Z: Transcript path: /home/jan/.claude/projects/-home-jan-ai-claude-cc-misc-contextsize-awareness-for-
claude-test-sessions/0c772589-6645-42a0-aed4-441a3cfd5665.jsonl
2025-09-22T19:01:29.937Z: Working directory: /home/jan/ai/claude/cc-misc/contextsize-awareness-for-claude/test-sessions
2025-09-22T19:01:29.937Z: Source: resume
2025-09-22T19:01:29.937Z: Permission mode: undefined
2025-09-22T19:01:29.937Z: ✓ Input validation passed - all required fields present
2025-09-22T19:01:29.937Z: === SESSIONSTART EVENT PROCESSING ===
2025-09-22T19:01:29.937Z: SessionStart detected with source: "resume"
2025-09-22T19:01:29.937Z: Determining session type from source...
2025-09-22T19:01:29.937Z: ✓ Source "resume" → sessionType: "resumed"
2025-09-22T19:01:29.937Z: Generating initial message for session type: resumed
2025-09-22T19:01:29.937Z: Selected message type: "resumedSessionError" based on sessionType: "resumed"
</debug-log>
<hookdata>
{
"session_id": "0c772589-6645-42a0-aed4-441a3cfd5665",
"transcript_path": "/home/jan/.claude/projects/-home-jan-ai-claude-cc-misc-contextsize-awareness-for-claude-test-sessions/
0c772589-6645-42a0-aed4-441a3cfd5665.jsonl",
"cwd": "/home/jan/ai/claude/cc-misc/contextsize-awareness-for-claude/test-sessions",
"hook_event_name": "SessionStart",
"source": "resume"
}
</hookdata>
</session-start-hook>
> and now?
✻ Thinking…
The user is asking "and now?" - I can see from the hookdata that this is a resumed session with a different session ID. The
user seems to be testing the context monitoring system behavior.
Looking at the debug log, I can see:
- This is a resumed session (source: "resume")
- Session ID: 0c772589-6645-42a0-aed4-441a3cfd5665
- The system selected message type: "resumedSessionError" which suggests the cc-contextsize tool might have failed to measure
the context
The user is probably asking about the new session ID to see how the system behaves when sessions are resumed vs started fresh.
● Now the session ID is: 0c772589-6645-42a0-aed4-441a3cfd5665
This is a resumed session (notice the source: "resume" in the hookdata vs source: "startup" in the previous one). The
debug log shows the system detected this as a resumed session and selected "resumedSessionError" message type, likely
because cc-contextsize couldn't measure the context in a resumed session scenario.
> are you sure? ls -al the transcript
✻ Thinking…
The user is asking me to check the transcript file to see what's actually in it. Let me use the ls command to list the
transcript file details.
From the hookdata, I can see the transcript path is: /home/jan/.claude/projects/-home-jan-ai-claude-cc-misc-contextsize-awaren
ess-for-claude-test-sessions/0c772589-6645-42a0-aed4-441a3cfd5665.jsonl
Let me list this file to see its details.
● Bash(ls -al "/home/jan/.claude/projects/-home-jan-ai-claude-cc-misc-contextsize-awareness-for-claude-test-sessions/0c772589-66
45-42a0-aed4-441a3cfd5665.jsonl")
⎿ Error: ls: cannot access '/home/jan/.claude/projects/-home-jan-ai-claude-cc-misc-contextsize-awareness-for-claude-test-sessi
ons/0c772589-6645-42a0-aed4-441a3cfd5665.jsonl': No such file or directory
✻ Thinking…
Ah! The transcript file doesn't exist. This means this is actually a brand new session, not a resumed session. The hook system
detected it as "resumed" but the file doesn't exist yet because this session literally just started.
This reveals an interesting edge case in the context monitoring system - the hook can fire with source="resume" but if the
transcript file doesn't exist yet, it's effectively a new session. The user was testing my assumption about it being a resumed
session, and they were right to question it.
● You're absolutely right! The transcript file doesn't exist yet - this means it's actually a brand new session, not a
resumed one.
The hook fired with source="resume" but since there's no transcript file yet, this session is just starting. This reveals
an interesting edge case in the context monitoring system - the hook can detect a "resume" source but the actual
transcript hasn't been created yet.
So this is effectively a new session despite the hook reporting it as resumed. Good catch!
=============================================================================
Transcript WITHOUT THE DEBUG LOG IN THE JSON OUTPUT
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /home/jan/tmp/sessionstart-hook-bug-test │
│ │
│ ─────────────────────────────────────────────── │
│ │
│ Overrides (via env): │
│ │
│ • Max thinking tokens: 14000 │
╰───────────────────────────────────────────────────╯
> <session-start-hook>
<system-information>
New Session Start:
Maximum Context Window: 186,000 tokens
(Thinking Budget: 14,000 tokens)
</system-information>
<hookdata>
{
"session_id": "5c271f3b-cc43-4683-8e95-d3658e6eaf55",
"transcript_path":
"/home/jan/.claude/projects/-home-jan-tmp-sessionstart-hook-bug-test/5c271f3b-cc43-4683-8e95-d3658e6eaf55.jsonl",
"cwd": "/home/jan/tmp/sessionstart-hook-bug-test",
"hook_event_name": "SessionStart",
"source": "startup"
}
</hookdata>
</session-start-hook>
> hi, what's the session id?
✻ Thinking…
The user is asking for the session ID. I can see this information in the session-start-hook data that was provided:
{
"session_id": "5c271f3b-cc43-4683-8e95-d3658e6eaf55",
"transcript_path":
"/home/jan/.claude/projects/-home-jan-tmp-sessionstart-hook-bug-test/5c271f3b-cc43-4683-8e95-d3658e6eaf55.jsonl",
"cwd": "/home/jan/tmp/sessionstart-hook-bug-test",
"hook_event_name": "SessionStart",
"source": "startup"
}
The session ID is: 5c271f3b-cc43-4683-8e95-d3658e6eaf55
This is a straightforward question requiring a direct answer. According to the tone and style guidelines, I should be concise
and direct.
● 5c271f3b-cc43-4683-8e95-d3658e6eaf55
> <session-start-hook>
<system-information>
Resumed session - context measurement in progress
Maximum Context Window: 186,000 tokens
</system-information>
<hookdata>
{
"session_id": "3cc5fac5-2077-4c70-af10-57009dad61b6",
"transcript_path":
"/home/jan/.claude/projects/-home-jan-tmp-sessionstart-hook-bug-test/3cc5fac5-2077-4c70-af10-57009dad61b6.jsonl",
"cwd": "/home/jan/tmp/sessionstart-hook-bug-test",
"hook_event_name": "SessionStart",
"source": "resume"
}
</hookdata>
</session-start-hook>
> and now?
✻ Thinking…
The user is asking for the session ID again, and I can see from the session-start-hook that a new session has started. The
hookdata shows a different session_id now: "3cc5fac5-2077-4c70-af10-57009dad61b6". The source is "resume" this time instead of
"startup".
So the session ID has changed from the previous one (5c271f3b-cc43-4683-8e95-d3658e6eaf55) to this new one
(3cc5fac5-2077-4c70-af10-57009dad61b6).
● 3cc5fac5-2077-4c70-af10-57009dad61b6
> are you sure? ls -al the transcript
✻ Thinking…
The user is asking me to list the transcript files to verify the session ID. I should use the ls command to check the
transcript path mentioned in the hook data.
From the hook data, the transcript path is:
/home/jan/.claude/projects/-home-jan-tmp-sessionstart-hook-bug-test/3cc5fac5-2077-4c70-af10-57009dad61b6.jsonl
I should list the files in that directory to see what's actually there.
● Bash(ls -al /home/jan/.claude/projects/-home-jan-tmp-sessionstart-hook-bug-test/)
⎿ total 56
drwx------ 2 jan jan 4096 Sep 22 21:40 .
drwxrwxr-x 85 jan jan 4096 Sep 22 21:08 ..
-rw-rw-r-- 1 jan jan 11485 Sep 22 21:10 0975db74-9c22-42b1-8bfc-a8b733c0ebcc.jsonl
-rw-rw-r-- 1 jan jan 7762 Sep 22 21:41 3cc5fac5-2077-4c70-af10-57009dad61b6.jsonl
-rw-rw-r-- 1 jan jan 4728 Sep 22 21:40 5c271f3b-cc43-4683-8e95-d3658e6eaf55.jsonl
-rw-rw-r-- 1 jan jan 11704 Sep 22 21:24 6ec2dd22-29ae-4d4f-8706-55d67057d337.jsonl
-rw-rw-r-- 1 jan jan 3824 Sep 22 21:25 e1329f44-c50b-43c5-8719-6a3f2ff0c143.jsonl
-rw-rw-r-- 1 jan jan 3658 Sep 22 21:25 eaaef87a-55d9-431f-bd67-3bcb16199e95.jsonl
✻ Thinking…
I can see both session IDs are present as transcript files:
- 5c271f3b-cc43-4683-8e95-d3658e6eaf55.jsonl (from the first session)
- 3cc5fac5-2077-4c70-af10-57009dad61b6.jsonl (from the current/resumed session)
So yes, I was correct - the current session ID is 3cc5fac5-2077-4c70-af10-57009dad61b6, as indicated by the most recent hook
data.
● Yes, I'm sure. The transcript files show both session IDs exist:
- 5c271f3b-cc43-4683-8e95-d3658e6eaf55.jsonl (the first session)
- 3cc5fac5-2077-4c70-af10-57009dad61b6.jsonl (current resumed session)
The current session ID is indeed 3cc5fac5-2077-4c70-af10-57009dad61b6.This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗