Skip to main content

Observer

Trait Observer 

Source
pub trait Observer: Send + Sync {
    // Provided methods
    fn on_step_start(&self, _ctx: &StepContext) { ... }
    fn on_tool_start(&self, _call: &ToolCall) { ... }
    fn on_tool_end(&self, _call: &ToolCall, _result: &ToolResult) { ... }
    fn on_step_end(&self, _response: &Message) { ... }
    fn on_step_error(&self, _error: &str) { ... }
}
Expand description

Lifecycle observer. Every method has a default no-op implementation so implementors override only the hooks they care about.

Provided Methods§

Source

fn on_step_start(&self, _ctx: &StepContext)

Called when Agent::step begins.

Source

fn on_tool_start(&self, _call: &ToolCall)

Called before each tool dispatch inside the step loop.

Source

fn on_tool_end(&self, _call: &ToolCall, _result: &ToolResult)

Called after each tool dispatch completes, with the result.

Source

fn on_step_end(&self, _response: &Message)

Called when the step loop terminates with a final assistant message.

Source

fn on_step_error(&self, _error: &str)

Called if the step loop errors out before producing a final message.

Implementors§