Expand description
A2A Agents - Framework for building A2A Protocol agents
This crate provides a declarative, configuration-driven framework for building agents that implement the A2A Protocol v0.3.0.
§Architecture
The crate is organized into three main layers:
- Core Framework (
core) - Builder, configuration, and runtime - Plugin System (
traits) - Traits for extending agent functionality - Utilities (
utils) - Common helpers for agent development - Example Agents (
agents) - Reference implementations
§Quick Start
ⓘ
use a2a_agents::core::AgentBuilder;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
AgentBuilder::from_file("config.toml")?
.with_handler(my_handler)
.build_with_auto_storage()
.await?
.run()
.await?;
Ok(())
}§Core Framework
The core framework provides the essential building blocks:
AgentBuilder- Fluent API for agent constructionAgentConfig- TOML-based configurationAgentRuntime- Server lifecycle management
§Plugin System
Implement the AgentPlugin trait to create agents that
integrate seamlessly with the framework:
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 { "An example agent" }
fn skills(&self) -> Vec<SkillDefinition> { vec![] }
}
#[async_trait]
impl AsyncMessageHandler for MyAgent {
async fn process_message(
&self,
_task_id: &str,
_message: &Message,
_session_id: Option<&str>,
) -> Result<Task, A2AError> {
todo!()
}
}§Features
default- Includes reimbursement agent example and SQLx storagereimbursement-agent- Include reimbursement agent examplesqlx- Enable SQLx-based task storageauth- Enable authentication features (JWT, OAuth2)
Re-exports§
pub use core::AgentBuilder;pub use core::AgentConfig;pub use core::AgentRuntime;pub use core::BuildError;pub use core::ConfigError;pub use core::RuntimeError;pub use traits::AgentPlugin;pub use traits::SkillDefinition;pub use agents::reimbursement::ReimbursementHandler;