Skip to content

hooks: subagent_stop (refs #26) - #45

Merged
blockmandev merged 1 commit into
mainfrom
feat/hook-subagent-stop
Oct 22, 2026
Merged

blockmandev merged 1 commit into
mainfrom
feat/hook-subagent-stop

Conversation

@blockmandev

Copy link
Copy Markdown
Member

The one Claude Code hook event incode still lacked (#26 item 5).

What

  • Event. subagent_stop in admin.json hooks (and the operator's own plugins) runs when a sub-agent, the Agent tool, finishes, on every route. It is told:
    • agent_type: the definition's name, the role, or sub-agent;
    • task;
    • last_assistant_message;
    • outcome: completed, failed or cancelled, the same value the sub-agent's tab shows.
  • No refusing. It can't keep the agent working: exit 2 is an ordinary exit. Its output is traced, not shown.
  • Where it fires. Toolbox::run_subagent, right after the child's turn ends, in the workspace, under the toolbox's session.
  • Project plugins can't add one. plugins::hooks_of gives a project's plugin only the tool events, by allowlist, so a new event is refused to it by default.
  • README updated.

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 real Agent call on an API route goes to a loopback fake model, and the hook saves the event it received. The test checks agent_type, task, last_assistant_message and outcome. 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).

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.
@blockmandev
blockmandev merged commit 9570b2a into main Oct 22, 2026
7 checks passed
@blockmandev
blockmandev deleted the feat/hook-subagent-stop branch November 15, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant