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) { ... }
}
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).

Implementors§