use crate::agent::task::Task;
use crate::agent::{AgentDeriveT, Context};
use crate::tool::ToolCallResult;
use async_trait::async_trait;
use autoagents_llm::ToolCall;
use serde_json::Value;
#[derive(PartialEq)]
pub enum HookOutcome {
Continue,
Abort,
}
#[async_trait]
pub trait AgentHooks: AgentDeriveT + Send + Sync {
async fn on_agent_create(&self) {}
async fn on_run_start(&self, _task: &Task, _ctx: &Context) -> HookOutcome {
HookOutcome::Continue
}
async fn on_run_complete(&self, _task: &Task, _result: &Self::Output, _ctx: &Context) {}
async fn on_turn_start(&self, _turn_index: usize, _ctx: &Context) {}
async fn on_turn_complete(&self, _turn_index: usize, _ctx: &Context) {}
async fn on_tool_call(&self, _tool_call: &ToolCall, _ctx: &Context) -> HookOutcome {
HookOutcome::Continue
}
async fn on_tool_start(&self, _tool_call: &ToolCall, _ctx: &Context) {}
async fn on_tool_result(
&self,
_tool_call: &ToolCall,
_result: &ToolCallResult,
_ctx: &Context,
) {
}
async fn on_tool_error(&self, _tool_call: &ToolCall, _err: Value, _ctx: &Context) {}
async fn on_agent_shutdown(&self) {}
}