Skip to main content

Observer

Trait Observer 

Source
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§

Source

fn on_step(&self, step_index: usize, step: &ReActStep)

Called when a ReAct step completes.

Source

fn on_tool_call(&self, tool_name: &str, args: &Value)

Called when a tool is about to be dispatched.

Source

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.

Source

fn on_loop_start(&self, prompt: &str)

Called when the loop starts.

Source

fn on_loop_end(&self, step_count: usize)

Called when the loop finishes (success or error).

Source

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.

Implementors§