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§
Sourcefn on_step_start(&self, _ctx: &StepContext)
fn on_step_start(&self, _ctx: &StepContext)
Called when Agent::step begins.
Sourcefn on_tool_start(&self, _call: &ToolCall)
fn on_tool_start(&self, _call: &ToolCall)
Called before each tool dispatch inside the step loop.
Sourcefn on_tool_end(&self, _call: &ToolCall, _result: &ToolResult)
fn on_tool_end(&self, _call: &ToolCall, _result: &ToolResult)
Called after each tool dispatch completes, with the result.
Sourcefn on_step_end(&self, _response: &Message)
fn on_step_end(&self, _response: &Message)
Called when the step loop terminates with a final assistant message.
Sourcefn on_step_error(&self, _error: &str)
fn on_step_error(&self, _error: &str)
Called if the step loop errors out before producing a final message.