Kiro Hooks: Checking Subagent Work with Subagent Stop
Eric Greene November 25, 2026Kiro CLI 3.6.0, released on November 24, added a hook trigger called Subagent Stop. It runs when a subagent finishes its turn, before its answer goes back to the agent that dispatched it, and it can send that subagent back for one more turn with a new instruction. If your team splits work across subagents in the Kiro CLI, it gives you a place to check a subagent's output with your own code, and send it back, instead of trusting the parent agent to notice what was skipped. This post explains how Kiro hooks work, what the new trigger adds, and what a team should set up before relying on it.
How Kiro hooks work
A Kiro hook pairs a trigger with an action. The trigger is a session event: a prompt submitted, a tool about to run, a file saved, a spec task finished, a conversation about to be compacted. The action is either a shell command or an agent prompt. The Kiro hooks overview describes each hook as a JSON file in .kiro/hooks/ in the project, with a name, a trigger, an optional matcher, the action, a timeout (60 seconds by default) and an enabled flag. Kiro CLI V3 also reads global hooks from ~/.kiro/hooks/, and workspace and global hooks run side by side.
The two action types behave differently, and the difference matters for cost and predictability. According to the hook actions page, a shell command runs locally with no model involved, uses no credits, and is usually faster. An agent prompt starts a new agent loop, so it consumes credits. A command that exits with 0 adds its standard output to the agent's context. Any other exit code sends standard error to the agent and tells it the hook failed; on a Pre Tool Use trigger that blocks the tool call.
A good rule of thumb: use a command when the check is deterministic (run the linter, run the tests, refuse a path), and an agent prompt when the check needs judgment (review this change for security problems). Deterministic checks belong in commands because they give the same answer every time and cost nothing to run.
Not every trigger runs everywhere. The hook triggers reference has a table of which triggers each surface supports. The IDE, CLI and Kiro Web share the core triggers such as Prompt Submit, Agent Stop, Pre Tool Use and Post Tool Use. Several, including Session End, are CLI V3 only, and so is Subagent Stop.
What Subagent Stop adds
In Kiro CLI V3, an agent can hand part of a task to a subagent with the invoke_sub_agent tool: a code reviewer, a test writer, a researcher. Agent Stop fires when the main agent finishes its turn, and Post Tool Use runs after a tool call, but neither one can return a subagent to work with a new instruction. The 3.6.0 changelog adds a trigger that can.
The triggers reference spells out the details:
- The hook fires when a dispatched subagent finishes a turn, before its result returns to the parent.
- It does not fire when the subagent times out, fails or is cancelled.
- The matcher is a regular expression tested against the subagent's agent name. An empty matcher or
*runs the hook for every subagent. - The hook receives JSON on standard input with the session ID, the working directory, the subagent's
agent_idandagent_name, and its final reply inlast_assistant_message. - To send the subagent back, the command either exits with 1 and writes the instruction to standard error, or exits with 0 and prints a JSON object with
decisionset toblockand the instruction inreason. - The subagent then runs one more turn with that instruction. If it has already reached its turn limit, the hook still runs, but the subagent stops and its result goes back to the parent.
The input looks like this, as shown in the reference:
{
"hook_event_name": "SubagentStop",
"cwd": "/current/working/directory",
"session_id": "abc123-def456-789",
"agent_id": "subagent-run-id",
"agent_name": "code-reviewer",
"last_assistant_message": "The subagent's final reply."
}Here is a small command a team might attach to a reviewer subagent, with the matcher set to code-reviewer. It sends the reviewer back when its reply doesn't report a test run. The check itself is your team's own convention, not something Kiro defines.
#!/usr/bin/env bash
input=$(cat)
reply=$(printf '%s' "$input" | jq -r '.last_assistant_message')
if ! printf '%s' "$reply" | grep -qi 'tests passed'; then
echo 'Run the test suite and report the result before you finish.' >&2
exit 1
fi
exit 0A string match on the reply is a blunt instrument, and it is only an example. A stronger version runs the tests itself and blocks on a failing exit code, so the decision rests on what the code does, not on what the subagent says it did.
The rest of the 3.6.0 release
Two other changes in the same release touch hooks and long sessions.
First, hook output over 3,000 characters is now saved to a file. The agent gets the start of the output and the file's path, so a long test log no longer floods the conversation, and the full log is still there when the agent needs it.
Second, compaction can take instructions. In V3 sessions you can type something after /compact, and Kiro uses it to shape that one summary; the changelog's example asks it to keep the migration decisions and the remaining validation steps. Later compactions without instructions go back to the standard summary. This pairs well with the Pre Compaction and Post Compaction hook triggers, which the reference lists for the IDE and for CLI V3 from 3.1.0. A Pre Compaction command can add guidance to the agent's context, or cancel the compaction with exit code 2, and a Post Compaction hook gets the summary and the path of the file that holds the full text.
Rolling hooks out across a team
Hooks run commands on developers' machines and in CI, so treat them like any other shared automation:
- Keep workspace hooks in the repository. Files in
.kiro/hooks/go through pull request review like the code they guard. Keep personal preferences in global hooks, so one developer's habits don't become everyone's rules. - Prefer commands for gates. A Pre Tool Use command that refuses a risky shell call, or a Subagent Stop command that runs the tests, gives the same answer every time and uses no credits. Save agent prompts for reviews that need judgment.
- Watch the extra turns. Each block sends a subagent around once more, and the reference describes one extra turn per block. A check that can never pass will burn turns until the subagent hits its limit, so write checks a correct answer can satisfy.
- Know which surface runs what. Subagent Stop, Session End and global hooks are CLI V3 features. A hook that works in a developer's terminal may never fire in the IDE, so test each hook on the surfaces your team uses.
- Upgrade older agents first. The
.kiro/hooks/JSON format arrived with Kiro IDE 1.0 and CLI V3. Teams still on CLI 2.x agents need to move them with/upgrade-agentbefore the new triggers apply.
What this means for training plans
Subagents make Kiro faster on large tasks, and they also make it easier to lose track of which agent did what. Subagent Stop gives a team a checkpoint it controls when a subagent finishes a turn, but only if someone writes and maintains those checks. It has limits: it doesn't fire when a subagent times out, fails or is cancelled, and a subagent at its turn limit returns its result even after a block. When a check is mandatory, run it again in an independent gate, such as CI, as well. The skills involved are ordinary engineering: deciding which rules are deterministic, writing small scripts that read JSON from standard input, and reviewing hook files like code.
Our Spec-Driven Agentic Coding with Kiro course covers hook files, triggers including Subagent Stop, command and agent actions, custom agents and subagents, and Kiro CLI in CI. Teams that want the spec workflow across several tools can start with Spec-Driven Development with AI Coding Agents. Both sit with the other courses on the AI coding assistant training page.