[FEATURE] Hookable Workflow lifecycle events (completion) that support additionalContext
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
There is no hook event that lets tooling react to a Workflow finishing.
Workflows (e.g. the built-in /deep-research) run in the background and return their result to the conversation as an injected task-notification — not through any hook. I instrumented a catch-all logger on eight candidate events during a real /deep-research run (CLI 2.1.156) and confirmed the gap:
PreToolUse/PostToolUsefire fortool_name: "Workflow"only at launch. Thetool_responseis the launch ack —{"status":"async_launched","taskId":...,"runId":...}— never the finished report. There is no secondPostToolUsecarrying the result.TaskCreated/TaskCompletednever fired (0 occurrences) for the workflow in the CLI, even thoughTaskCompletedis documented for the Agent SDK (TypeScript-only).Stopis turn-scoped (fires when the main agent ends a turn), not workflow-scoped — it can't distinguish "a workflow just completed" from any other turn end.SubagentStart/SubagentStopfire per fan-out agent (agent_type: "workflow-subagent") — ~97 subagents in one run — so there's no single completion signal, and the final synthesize agent's stop is indistinguishable from the rest.
Compounding it: even the completion events that do fire (Stop, SubagentStop) only support the top-level decision/reason output and cannot emit hookSpecificOutput.additionalContext. Per the hooks docs, additionalContext is supported only by SessionStart, Setup, UserPromptSubmit, SubagentStart, PreToolUse, and PostToolUse. So there is no event that both (a) fires once when a workflow completes and (b) can inject context back into the conversation.
The net effect: a finished workflow's output cannot be acted on automatically. For /deep-research specifically, a multi-source, fact-checked report is produced and then lost unless the user manually persists it.
Proposed Solution
Add a workflow lifecycle hook event that fires once when a Workflow completes (e.g. WorkflowCompleted, or make the documented TaskCompleted fire for CLI workflow runs), and allow it to emit hookSpecificOutput.additionalContext.
The payload should carry enough to identify and act on the run:
hook_event_name(e.g."WorkflowCompleted")- workflow
nameandrunId(andtaskId) - the workflow's returned
result(or a path to it) status(completed / failed / cancelled)
With additionalContext support, a hook could then nudge the model — e.g. "a /deep-research report just completed; persist it to docs/research/<slug>.md" — closing the loop without user intervention. A matcher on workflow name (mirroring the tool-name matcher on PreToolUse/PostToolUse) would let hooks target specific workflows.
Alternative Solutions
Workarounds tried, all insufficient:
PostToolUseontool_name: "Workflow"— only sees the launch ack, never the result.Stophook — fires on every main-agent turn; can't tell a workflow completion apart from any turn end, and can't injectadditionalContextregardless.SubagentStop— fires dozens of times per run with no workflow-completion semantics.- Manual capture — I shipped a small skill that the user invokes after a workflow to persist the in-context report. It works, but it's manual; a completion hook is exactly what would automate it.
Priority
Medium - Would be very helpful
Feature Category
Developer tools/SDK
Use Case Example
- I run
/deep-research "<question>". The workflow fans out ~97 subagents, verifies claims, and returns a cited report to the conversation. - I want that report persisted automatically to
docs/research/<slug>.mdso future sessions don't re-research it. - With a
WorkflowCompletedhook that supportsadditionalContext, a hook matchingname: "deep-research"would fire once at completion and inject: "Persist this report todocs/research/<slug>.md." - The report is saved without me remembering to do it — the same automation pattern that
PostToolUsealready enables for ordinary tools.
Additional Context
- Observed on Claude Code CLI 2.1.156 (macOS).
- Method: a catch-all command hook wired to
PreToolUse,PostToolUse,PostToolBatch,Stop,SubagentStart,SubagentStop,TaskCreated,TaskCompleted, logging each event name + stdin payload during one/deep-researchrun. - The
additionalContextsupport matrix referenced above is from the official hooks documentation (code.claude.com/docs/en/hooks and the Agent SDK hooks page). - Related nuance:
additionalContextinjection is reported to be unreliable for some events/matchers in recent versions (open issues exist), so a new event should be specified to deliveradditionalContextreliably.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗