Skip to main content

callback

Attribute Macro callback 

Source
#[callback]
Expand description

Generate an AgentCallback implementation from an impl block, overriding only the methods you define.

§Example

struct LogCallback;

#[callback]
impl LogCallback {
    async fn on_tool_start(&self, _agent: &str, tool: &str, _args: &Value) {
        println!("Tool started: {tool}");
    }
    async fn on_final_answer(&self, _agent: &str, answer: &str) {
        println!("Final answer: {answer}");
    }
}