pub trait Agent: Send + Sync {
// Required method
fn name(&self) -> String;
// Provided methods
fn on_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_msg: Message,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_generic_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
msg: GenericMessage,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<GenericResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_stop<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn tool_invoker(&self) -> Option<&ToolInvoker> { ... }
fn tool_invoker_mut(&mut self) -> Option<&mut ToolInvoker> { ... }
}Required Methods§
Provided Methods§
fn on_start<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_msg: Message,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn on_generic_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
msg: GenericMessage,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<GenericResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_generic_message<'life0, 'life1, 'async_trait>(
&'life0 mut self,
msg: GenericMessage,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<GenericResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle a generic string message and return a generic response. Default implementation returns an echo response.
fn on_stop<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut AgentContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn tool_invoker(&self) -> Option<&ToolInvoker>
fn tool_invoker(&self) -> Option<&ToolInvoker>
Get the tool invoker for this agent (if it has actions)
Sourcefn tool_invoker_mut(&mut self) -> Option<&mut ToolInvoker>
fn tool_invoker_mut(&mut self) -> Option<&mut ToolInvoker>
Get mutable tool invoker for registration