#[non_exhaustive]pub enum HookEvent<'a> {
Show 14 variants
SessionStart {
goal: &'a str,
},
PreToolCall {
name: &'a str,
args: &'a Value,
},
PostToolCall {
name: &'a str,
args: &'a Value,
result: &'a str,
duration_ms: u64,
},
PreCompact {
transcript_len: usize,
},
PostCompact {
removed: usize,
summary_chars: usize,
},
SessionEnd {
outcome: &'a RuntimeOutcome,
},
UserPromptSubmit {
content: &'a str,
},
Stop {
outcome: &'a RuntimeOutcome,
},
SubagentStart {
goal: &'a str,
depth: usize,
},
SubagentStop {
outcome: &'a RuntimeOutcome,
depth: usize,
},
PostToolCallFailure {
name: &'a str,
args: &'a Value,
error: &'a str,
},
PermissionDenied {
tool_name: &'a str,
reason: &'a str,
},
Notification {
message: &'a str,
},
Setup,
}Expand description
Events emitted at lifecycle points during an agent run.
This enum is #[non_exhaustive] — new variants may be added in future
releases without a breaking change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SessionStart
Fired at the start of an agent run, before any LLM call.
PreToolCall
Fired before a tool is dispatched (after the permission hook).
Fields
PostToolCall
Fired after a tool returns.
Fields
PreCompact
Fired before compaction is attempted.
PostCompact
Fired after compaction completes.
Fields
SessionEnd
Fired at the end of an agent run, before returning.
Dispatched by AgentRuntime::run() after every turn completes.
Fields
outcome: &'a RuntimeOutcomeThe outcome that will be returned.
UserPromptSubmit
Fired after the user submits a message, before the LLM processes it.
Stop
Fired when the agent completes normally (NoMoreToolCalls).
Fields
outcome: &'a RuntimeOutcomeThe final outcome.
SubagentStart
Fired before a sub-agent is dispatched.
SubagentStop
Fired after a sub-agent completes.
PostToolCallFailure
Fired when a tool call returns an error (before PostToolCall).
Fields
PermissionDenied
Fired when a permission check denies a tool call.
Fields
Notification
Fired when the agent emits a notification to the user.
Setup
Fired once at the very beginning, before SessionStart, for one-time setup.