SubagentStart Hook

SubagentStart

Triggered before the Subagent starts execution. Unlike Stop and SubagentStop, the SubagentStart Hook cannot prevent the Subagent from executing, but can provide suggestions or warnings to the Subagent through the model or Shell script.

Input Parameters

The parameter format is consistent with SubagentStop.

Output Parameters

{
"hookSpecificOutput": {
"hookEventName": "SubagentStart",
"additionalContext": "Please follow security guidelines: do not access production environment databases"
}
}

Configuration Methods

Prompt Method

Provide suggestions to the Subagent through the model:

  • Use matcher to match Subagent names
  • Use pipe | to match multiple names, e.g., Explore|Test
  • Use * to match all Subagents
{
"hooks": {
"SubagentStart": [
{
"matcher": "Explore",
"hooks": [
{
"type": "prompt",
"prompt": "Review this subagent task: $ARGUMENTS. If the task description is vague or potentially dangerous, warn the user."
}
]
}
]
}
}

Command Method

Execute commands through Shell script:

{
"hooks": {
"SubagentStart": [
{
"matcher": "Explore",
"hooks": [
{
"type": "command",
"command": "node D:/Javaworks/hawa-code/hooks/SubagentStart.js"
}
]
}
]
}
}

Example script:

import * as fs from 'fs';

const input = fs.readFileSync(0, 'utf-8');
const output = {
"hookSpecificOutput": {
"hookEventName": "SubagentStart",
"additionalContext": "Please follow security guidelines: do not access production environment databases. Input parameters: " + input
}
};

console.log(JSON.stringify(output));