Skip to main content

Hook

Trait Hook 

Source
pub trait Hook: Send + Sync {
    // Provided methods
    fn on_build_agent(&self, config: AgentConfig) -> AgentConfig { ... }
    fn on_event(&self, _agent: &str, _event: &AgentEvent) { ... }
    fn on_register_tools(
        &self,
        _tools: &mut ToolRegistry,
    ) -> impl Future<Output = ()> + Send { ... }
}
Expand description

Lifecycle backend for agent building, event observation, and tool registration.

Default implementations are no-ops so implementors only override what they need.

Provided Methods§

Source

fn on_build_agent(&self, config: AgentConfig) -> AgentConfig

Called by Runtime::add_agent() before building the Agent.

Enriches the agent config: appends skill instructions, injects memory into the system prompt, etc. The returned config is passed to AgentBuilder.

Default: returns config unchanged.

Source

fn on_event(&self, _agent: &str, _event: &AgentEvent)

Called by Runtime after each agent step during execution.

Receives every AgentEvent produced during send_to and stream_to. Use for logging, metrics, persistence, or forwarding.

Default: no-op.

Source

fn on_register_tools( &self, _tools: &mut ToolRegistry, ) -> impl Future<Output = ()> + Send

Called by Runtime::new() to register tools into the shared registry.

Implementations insert (Tool, Handler) pairs via tools.insert(). DaemonHook delegates to each sub-hook’s on_register_tools.

Default: no-op async.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Hook for ()

Implementors§