Skip to content

Subagent (Agent tool) does not fire Stop hook on completion #33049

Description

@kok1eee

Description

When a subagent spawned via the Agent tool (or TeammateTool) completes and returns results to the parent agent, no Stop hook is fired. Other lifecycle hooks (UserPromptSubmit, PreToolUse, PostToolUse) fire correctly for the subagent with its own session_id, but the completion event is missing.

Steps to reproduce

  1. Configure a Stop hook in .claude/settings.json that logs session_id
  2. Spawn a subagent via the Agent tool (e.g., subagent_type: "Explore")
  3. Wait for the subagent to complete and return results to the parent
  4. Observe that the Stop hook fires for the parent session but never fires for the subagent session

Expected behavior

When a subagent completes (returns results to parent), a Stop hook should fire with the subagent's session_id, allowing external tools to detect session lifecycle completion.

Actual behavior

  • Subagent fires UserPromptSubmit and PreToolUse hooks → external tools register a new session
  • Subagent completes → no Stop hook → external tools see a "ghost session" that never ends
  • Ghost sessions accumulate over time

Impact

Hook-based external tools (session monitors, sidebars, etc.) cannot distinguish between:

  • A subagent that is still running
  • A subagent that has completed

This leads to ghost sessions accumulating in any tool that tracks sessions via hooks.

Environment

  • Claude Code version: 2.1.x (latest)
  • OS: macOS (Darwin)
  • Hooks used: Stop (shell script)

Related issues

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