[FEATURE] Include the subagent task prompt in SubagentStart hook input (refile of stale-closed #32016)
Preflight Checklist
- [x] This is a single feature request (not multiple features)
- [x] I have searched existing requests. Closest matches, disclosed up front: #32016 is this exact ask, stale-closed by the bot on 2026-04-30 with "please open a new issue if this is still relevant" — this is that new issue. Open #78949 asks only for the Task tool's
descriptionfield (dashboard attribution); this request is for the full task prompt, for context injection. #69545 (updatedInput for model routing) was a different ask.
Problem Statement
SubagentStart hook input carries only session-level fields plus agent_id and agent_type (verified on v2.1.233; matches the hooks reference):
{
"session_id": "...",
"transcript_path": "...",
"cwd": "...",
"prompt_id": "...",
"agent_id": "a216198197bfc04c4",
"agent_type": "general-purpose",
"hook_event_name": "SubagentStart"
}
The task prompt the parent passed to the Agent tool is not included. The hooks reference documents that SubagentStart hooks "can inject context into the subagent" via hookSpecificOutput.additionalContext (also verified working on 2.1.233), and the natural use case is relevance-based injection: look at what the subagent is being asked to do and inject the matching project memory, safety rules, or domain notes. Without the prompt, a hook can only inject the same static blob for every subagent.
Proposed Solution
Add one field to SubagentStart hook input, for example agent_prompt, containing the task prompt passed to the Agent tool. agent_id is already present, so no other change is needed.
Alternative Solutions
- Scraping
transcript_pathfrom the hook for the most recent Agent tool_use: racy with parallel spawns, and per a report on #32016 the transcript is not yet written when SubagentStart runs. - Correlating the parent's
PreToolUseon the Agent tool (which does carry the prompt) with the later SubagentStart: PreToolUse fires beforeagent_idexists, and FIFO session-level pairing misattributes under parallel fan-out (analysis in #78949).
Priority
Medium - Would be very helpful
Feature Category
Developer tools/SDK
Use Case Example
- A memory/recall system registers a SubagentStart hook that injects
additionalContext(the documented, working path). - Today the hook must inject one static bundle for every subagent regardless of its task.
- With
agent_prompt, the hook runs recall against the actual task text and injects only the relevant project memory, rules, or domain notes. - The same field also solves the attribution problem in #78949 (fleet dashboards showing what each subagent was asked to do).
Additional Context
- SubagentStart
additionalContextinjection is documented and verified working on v2.1.233, so context delivery already exists; the prompt field is what makes injection task-aware instead of static. - #69283 (subagent context inheritance) closed as completed 2026-08-17: subagents now load CLAUDE.md, covering static context. Hook-injected dynamic context is the remaining piece.
- Refiling #32016 per the close bot's instruction; that issue is locked, so a comment there was not possible.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗