Skip to content

SubagentStop agent_type: null — hookSSEBridge registry lookup fails for nested agents #55

Description

@Number531

Problem

ALL SubagentStop hook events arrive with agent_type: null, phase: null, stage: null — both locally and on GCE. This occurs because:

  1. The SDK does not reliably populate agent_type in SubagentStop input (despite Stage-1 deep-plan: repoint paths to worktree + correct START-HERE launch #226 claiming this was fixed in v0.2.69+)
  2. The agent_id on SubagentStop events often does not match the agent_id from the corresponding SubagentStart — making registry lookup in hookSSEBridge fail
  3. Nested subagent stops (from Agent tool calls inside subagents) bubble up to the parent's hooks, but their corresponding SubagentStart never fires (Fix billable-canary cache-source false-fail (srcOK accepts 'cache') #225), so they were never registered

Impact

  • Agent observability timeline shows "unknown" agent type for all stop events
  • Phase/stage/wave classification unavailable on stop
  • Gate check status, report verification, and tool usage metrics are captured but cannot be attributed to a specific agent type
  • The agentTypeMap correlation (for agent_progress) partially compensates but only covers agents that had a SubagentStart

Current behavior (hookSSEBridge.js)

SubagentStart fires → agentRegistry.set(agent_id, { agent_type, classification })
SubagentStop fires  → agentRegistry.get(agent_id) → returns undefined (different ID)
                    → falls back to null for all classification fields

Data from production

  • Local: 9 SubagentStart, 43 SubagentStop — 34 orphaned stops with no matching start
  • GCE: 6 SubagentStart, 28 SubagentStop — 22 orphaned stops with no matching start
  • 100% of SubagentStop events have agent_type: null in both environments

Potential mitigation

Use temporal correlation: when a SubagentStop arrives with unknown agent_id, match it to the most recently started agent that hasn't stopped yet. This is imperfect with concurrent agents but better than null.

Alternatively, track the tool_use_id from SubagentStart and correlate with the Agent tool_result that arrives around the same time as SubagentStop.

Related upstream issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions