plugins/hooks/types
Hook shape — lifecycle interceptors for the conversation loop. Built-in and user-provided hooks follow the same shape.
Hook types are function signatures for now. A future phase can introduce a generic dispatch system with HookEvent types.
Types
Post-tool-execution hook: runs after tools execute, may inject warnings or halt. Returns updated history, updated guardrail state, and a halt flag.
pub type PostToolExecutionHook =
fn(
List(message.Message),
List(message.ToolCall),
List(tool.Tool),
String,
) -> #(List(message.Message), String, Bool)
Pre-API-call hook: may modify messages before they are sent to the model. Used by: compression, token warning injection.
pub type PreApiCallHook =
fn(
List(message.Message),
List(tool_def.ToolDefinition),
String,
fn(
client.Client,
List(message.Message),
List(tool_def.ToolDefinition),
) -> Result(response.ChatResponse, client.ClientError),
client.Client,
) -> List(message.Message)