feat: add subagent lifecycle hooks

Add subagent lifecycle hooks for better control over subagent initialization and teardown.
This commit is contained in:
AresNing
2026-06-03 11:48:09 +08:00
committed by GitHub
parent b4691bc082
commit 8981d5c5fd
6 changed files with 441 additions and 3 deletions
+11 -1
View File
@@ -687,7 +687,8 @@ default_text_model = "deepseek-ai/deepseek-v4-pro"
# Configure as `[[hooks.hooks]]` under a `[hooks]` table.
#
# Available events: session_start, session_end, message_submit,
# tool_call_before, tool_call_after, mode_change, on_error, shell_env.
# tool_call_before, tool_call_after, mode_change, on_error,
# subagent_spawn, subagent_complete, shell_env.
#
# `shell_env` (#456) is special: the hook runs immediately before each
# `exec_shell` invocation and its stdout is parsed as `KEY=VALUE\n` lines.
@@ -714,6 +715,15 @@ default_text_model = "deepseek-ai/deepseek-v4-pro"
# command = "aws-vault export my-profile --format=env"
# # Optionally limit to specific tool names / categories:
# # condition = { type = "tool_category", category = "shell" }
#
# # Observe sub-agent lifecycle events. These hooks receive bounded JSON
# # metadata on stdin and are warn-only: failures do not affect sub-agent
# # scheduling, prompts, or results. continue_on_error has no effect for
# # these observer events; later matching hooks always continue.
# [[hooks.hooks]]
# name = "subagent-audit"
# event = "subagent_complete"
# command = "~/.codewhale/hooks/subagent-audit.sh"
# ─────────────────────────────────────────────────────────────────────────────────
# Runtime API (`deepseek serve --http`) (#561)