late-queen-51746
03/10/2026, 8:18 AMmodern-fireman-99755
03/10/2026, 8:39 AMSDK or the CLI? The change I sent you is currently only available in the `SDK`'s main branch.
Re-reading your question, I’m not sure if I fully understood what you're trying to do. Could you provide an example or a concrete use case of what you would like to accomplish?late-queen-51746
03/10/2026, 10:37 AMlate-queen-51746
03/10/2026, 10:38 AMmodern-fireman-99755
03/10/2026, 10:48 AMpre_tool_use hook on the parent conversation that matches "delegate". This fires before the subagent is created:
HookConfig(
pre_tool_use=[
HookMatcher(
matcher="delegate",
hooks=[
HookDefinition(command="./cleanup_workspace.sh")
]
)
]
)
2. SESSION_START hook on the subagent definition
This fires when the subagent's conversation begins (right after creation). Define it in the agent's .md frontmatter or programmatically:
---
name: my-worker-agent
hooks:
session_start:
- matcher: "*"
hooks:
- command: "./cleanup_workspace.sh"
---
Or programmatically in the AgentDefinition:
AgentDefinition(
hooks=HookConfig(
session_start=[
HookMatcher(matcher="*", hooks=[
HookDefinition(command="./cleanup_workspace.sh")
])
]
)
)modern-fireman-99755
03/10/2026, 10:49 AM