[FEATURE] Name the parent and display name in the SubagentStart hook
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Tools that show a session's subagents from hooks can't rebuild the tree Claude Code draws. When a subagent launches its own, as /code-review does with its review angles, every hook payload looks like a flat sibling:
{"hook_event_name":"SubagentStart","agent_id":"a1cf865b805f072c4","agent_type":"general-purpose", ...}
Nothing says which subagent launched a1cf865b805f072c4, and agent_type is general-purpose for every row. Claude Code's own UI shows code-review with its workers under it, so it has both facts. They just aren't in the payload.
Proposed Solution
Add two fields to the SubagentStart hook input, and to every hook that fires inside a subagent:
parent_agent_id: theagent_idof the subagent that launched this one. Absent when the main thread launched it.agent_name: what Claude Code shows for the subagent in its own UI. That is the skill's name for a forked skill, such ascode-review, and otherwise the task'sdescription.
SubagentStart already runs inside the launching context, which knows both values. The runner already records parentAgentId and the display name in the metadata it writes:
{
"hook_event_name": "SubagentStart",
"agent_id": "a1cf865b805f072c4",
"agent_type": "general-purpose",
"parent_agent_id": "ac15f9fedbcaa9669",
"agent_name": "Simplification angle"
}
Adding the same two fields to the shared hook input fields means any hook inside a subagent can place it without having seen its start, for example a hook installed mid-session.
Both fields are additive, so existing hooks are unaffected.
Alternative Solutions
- The base hook input (session_id, transcript_path, cwd, permission_mode, agent_id, agent_type) has no parent field. Checked against 2.1.292.
subagents/agent-<id>.meta.jsonbeside the transcript hasparentAgentId,nameanddescription. But it's undocumented, so a hook reading it breaks silently on any format change. It's also written after theSubagentStarthooks run, so the start hook can't read it. In a real/code-reviewrun the file appeared 30 to 65 ms after the subagent's first transcript line, and 5 to 11 seconds before its first tool call.- The Agent tool's
PostToolUsenames the child (tool_response.agentId) and the parent (the payload'sagent_id). For a foreground subagent, though, it fires only when the child finishes, too late to show it running.
Priority
Medium - Would be very helpful
Feature Category
Developer tools/SDK
Use Case Example
I'm working on https://github.com/KieranP/multishell , which integrates with claude code to show agents and their subagent structure.
Additional Context
_No response_