Repository navigation
hooks: subagent_stop (refs #26) - #45
Merged
Merged
Conversation
The one Claude Code hook event incode lacked. Toolbox::run_subagent, the Agent tool on every route, now runs the operator's subagent_stop with agent_type (definition, role, or sub-agent), task, the agent's last message and its outcome (completed, failed, cancelled). It cannot keep the agent working; its output is traced. A project's plugin cannot add one: plugins::hooks_of gives a project's only the tool events.
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The one Claude Code hook event incode still lacked (#26 item 5).
What
subagent_stopin admin.jsonhooks(and the operator's own plugins) runs when a sub-agent, theAgenttool, finishes, on every route. It is told:agent_type: the definition's name, the role, orsub-agent;task;last_assistant_message;outcome:completed,failedorcancelled, the same value the sub-agent's tab shows.Toolbox::run_subagent, right after the child's turn ends, in the workspace, under the toolbox's session.plugins::hooks_ofgives a project's plugin only the tool events, by allowlist, so a new event is refused to it by default.Tests
hooks::tests::subagent_stop_is_told_who_finished_and_how_and_cannot_refuse: the payload fields, and exit 2 not refusing.toolbox::subagent::tests::a_finished_sub_agent_runs_the_operators_subagent_stop_hook: end to end. A realAgentcall on an API route goes to a loopback fake model, and the hook saves the event it received. The test checksagent_type,task,last_assistant_messageandoutcome. Control: not running the hook fails it ("the subagent_stop hook did not run").Local Windows gate: fmt, clippy
-D warnings,cargo test(2225 lib + 59 bin).