[BUG] session summary/prompt-based hook recursion, docs contradictory

Resolved 💬 6 comments Opened Nov 12, 2025 by kierr Closed Jan 22, 2026

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?

Dear Claude,

  1. SessionStart events trigger session summaries before any user input
  2. Those brand-spanking-new (and awesome) events trigger SubagentStop hooks
  3. Any (incl. prompt-based) SubagentStop hooks start spiralling...
  4. All 'internal' prompting events trigger more UserPromptSubmit hooks
  5. Any (incl. prompt-based) UserPromptSubmit hooks spiral as well...

...leading to cascading recursive implosion!

Scoping internals via origin may be a wise move; perhaps a stop_hook_active-esque for prompt-based hooks? Otherwise a depth counter, parentId chaining, etc.

Additionally, docs are contradictory: "only supported for Stop and SubagentStop"1 vs. "Prompt-based hooks work with any hook event, but are most useful for [...] Stop/SubagentStop/UserPromptSubmit/PreToolUse"2

Love,
Human

What Should Happen?

Session Summary, Session Memory, prompt-based hook magic

Error Messages/Logs

Steps to Reproduce

sequenceDiagram
  autonumber
  participant App as "Claude Code"
  participant Hooks as "Hook Engine"
  participant Model as "LLM"

  Note over App,Model: Hook recursion bug

  %% Session Start
  App->>Hooks: SessionStart
  Hooks->>Model: Generate session summaries (b9I/WY)
  Model-->>Hooks: N summaries created

  %% Subagent lifecycle
  loop For each summary
    Hooks->>Hooks: SubagentStart
    Hooks->>Model: Background subagent work
    Model-->>Hooks: Completed

    %% Bug: SubagentStop triggers prompt hook
    Hooks->>Hooks: SubagentStop → prompt hook fires

    %% Prompt hook execution
    Note over Hooks,Model: Prompt hook runs and emits a non-user UserPromptSubmit
    Hooks->>Model: Evaluate prompt condition
    Model-->>Hooks: Response

    %% Recursion loop
    loop Recursive loop
      Hooks->>Hooks: UserPromptSubmit (non-user)
      Hooks->>Model: Evaluate (prompt hook)
      Model-->>Hooks: Response
    end
  end

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.36

Claude Code Version

2.0.37

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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