pub trait AgentPlugin:
AsyncMessageHandler
+ Clone
+ Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn skills(&self) -> Vec<SkillDefinition>;
// Provided methods
fn version(&self) -> &str { ... }
fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn shutdown<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Plugin trait that all agents should implement.
This trait extends AsyncMessageHandler with metadata and capability discovery.
Agents implementing this trait can be automatically configured and discovered
by the framework.
§Example
use a2a_agents::traits::{AgentPlugin, SkillDefinition};
use a2a_rs::port::AsyncMessageHandler;
use a2a_rs::domain::{A2AError, Message, Task};
use async_trait::async_trait;
#[derive(Clone)]
struct MyAgent;
impl AgentPlugin for MyAgent {
fn name(&self) -> &str {
"My Agent"
}
fn description(&self) -> &str {
"A simple example agent"
}
fn skills(&self) -> Vec<SkillDefinition> {
vec![
SkillDefinition {
id: "hello".to_string(),
name: "Say Hello".to_string(),
description: "Greets the user".to_string(),
keywords: vec!["hello".into(), "hi".into()],
examples: vec!["Hello!".into()],
input_formats: vec!["text".into()],
output_formats: vec!["text".into()],
}
]
}
}
#[async_trait]
impl AsyncMessageHandler for MyAgent {
async fn process_message(
&self,
task_id: &str,
message: &Message,
session_id: Option<&str>,
) -> Result<Task, A2AError> {
// Implementation
todo!()
}
async fn validate_message(&self, message: &Message) -> Result<(), A2AError> {
Ok(())
}
}Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Agent description
Sourcefn skills(&self) -> Vec<SkillDefinition>
fn skills(&self) -> Vec<SkillDefinition>
Skills provided by this agent
Provided Methods§
Sourcefn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Optional: Initialize the agent (load models, connect to services, etc.)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<T> AgentPlugin for ReimbursementHandler<T>
Implement AgentPlugin for ReimbursementHandler with InMemoryTaskStorage