[BUG] Hooks receive stale session_id and transcript_path after /exit and --continue

Resolved 💬 3 comments Opened Oct 9, 2025 by Brandtweary Closed Oct 20, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Environment:

  • Claude Code version: 2.0.11
  • Platform: Linux
  • Hook type affected: All hooks (UserPromptSubmit, Stop, etc.)
  • Trigger: /exit followed by claude --continue

When using /exit to close a session and then resuming with claude --continue, all hooks (UserPromptSubmit, Stop, etc.) continue to receive the original session's session_id and transcript_path instead of the current session's values. This persists across multiple exit/continue cycles, causing hooks to read conversations from hours/days ago instead of the current conversation.

Expected Behavior:

Hooks should receive the current session's session_id and transcript_path pointing to the actively-written transcript file.

Actual Behavior:

Hooks receive the first/original session's session_id and transcript_path from when the project directory was first opened, even though Claude Code is writing to a completely different transcript file.

What Should Happen?

When resuming a session with claude --continue, hooks should receive updated metadata:

  • session_id: The current session's ID
  • transcript_path: Path to the actively-written transcript file for the current session

Each exit/continue cycle should trigger hooks to receive fresh session metadata, not cached values from the initial session. Hooks should always point to the conversation currently being recorded, enabling real-time monitoring and context extraction from the correct transcript.

Steps to Reproduce

Steps to Reproduce:

  1. Start a Claude Code session in a project directory
  2. Set up a UserPromptSubmit hook that logs the received JSON (session_id and transcript_path)
  3. Have a conversation, then use /exit to close
  4. Resume with claude --continue
  5. Send a new message
  6. Check the hook's log

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Claude Code Version

2.0.11

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

Related Issues:

Similar to #3019 (transcript_path after /clear) and #8614 (session ID with --dangerously-skip-permissions), but this affects normal exit/continue workflow.

View original on GitHub ↗

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