Skip to content

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

Closed

Description

@Brandtweary

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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.

Activity

  1. github-actions commented on Oct 9, 2025

    @github-actions

    Found 3 possible duplicate issues:

    1. [Bug] Stop Hook Provides Stale Transcript Path #8564
    2. [BUG] PreToolUse hook is given wrong transcript path #8710
    3. [BUG] Session ID has unexpected values for SessionStart:resume hooks #7911

    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. Brandtweary commented on Oct 20, 2025

    @Brandtweary
    Author

    Issue resolved as of Claude Code 2.0.24.

    After testing with session reloads (/exit followed by claude --continue), the underlying issue has been fixed. The original bug wasn't that Claude Code was passing a "stale" session_id - it was that Claude Code was creating entirely new sessions on reload instead of continuing the existing one. This caused hooks to receive a transcript_path pointing to the old (now-abandoned) transcript file while a new transcript was being written elsewhere. The current behavior correctly maintains the same session_id and transcript_path across reload cycles, with the transcript file continuing to receive updates after resume. Hooks can now reliably use input_data.get('transcript_path') without workarounds to find the most recent transcript.

  3. github-actions commented on Oct 28, 2025

    @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.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions