pub trait Observer: Send + Sync {
// Provided methods
fn on_step(&self, step_index: usize, step: &ReActStep) { ... }
fn on_tool_call(&self, tool_name: &str, args: &Value) { ... }
fn on_action_blocked(&self, tool_name: &str, args: &Value) { ... }
fn on_loop_start(&self, prompt: &str) { ... }
fn on_loop_end(&self, step_count: usize) { ... }
fn on_error(&self, error: &AgentRuntimeError) { ... }
}Expand description
Hook trait for observing agent loop events.
All methods have no-op default implementations so you only override what you care about.
Provided Methods§
Sourcefn on_tool_call(&self, tool_name: &str, args: &Value)
fn on_tool_call(&self, tool_name: &str, args: &Value)
Called when a tool is about to be dispatched.
Sourcefn on_action_blocked(&self, tool_name: &str, args: &Value)
fn on_action_blocked(&self, tool_name: &str, args: &Value)
Called when an action hook blocks a tool call before dispatch.
tool_name is the name of the blocked tool; args are the arguments
that were passed to the hook. This is called instead of on_tool_call.
Sourcefn on_loop_start(&self, prompt: &str)
fn on_loop_start(&self, prompt: &str)
Called when the loop starts.
Sourcefn on_loop_end(&self, step_count: usize)
fn on_loop_end(&self, step_count: usize)
Called when the loop finishes (success or error).
Sourcefn on_error(&self, error: &AgentRuntimeError)
fn on_error(&self, error: &AgentRuntimeError)
Called when the loop terminates with an error.
Invoked for timeout, max-iterations, and parse failures.
on_loop_end is also called immediately after on_error.