Expand description
Ergonomic helpers for implementing AgentExecutor.
The AgentExecutor trait requires Pin<Box<dyn Future>>
return types for object safety. These helpers reduce the boilerplate.
§boxed_future helper
Wraps an async block into the Pin<Box<dyn Future>> form:
use a2a_protocol_server::executor_helpers::boxed_future;
use a2a_protocol_server::executor::AgentExecutor;
use a2a_protocol_server::request_context::RequestContext;
use a2a_protocol_server::streaming::EventQueueWriter;
use a2a_protocol_types::error::A2aResult;
use std::pin::Pin;
use std::future::Future;
struct MyAgent;
impl AgentExecutor for MyAgent {
fn execute<'a>(
&'a self,
ctx: &'a RequestContext,
queue: &'a dyn EventQueueWriter,
) -> Pin<Box<dyn Future<Output = A2aResult<()>> + Send + 'a>> {
boxed_future(async move {
// Your logic here — no Box::pin wrapper needed!
Ok(())
})
}
}§agent_executor! macro
Generates the full AgentExecutor impl from plain
async bodies:
use a2a_protocol_server::agent_executor;
use a2a_protocol_server::request_context::RequestContext;
use a2a_protocol_server::streaming::EventQueueWriter;
use a2a_protocol_types::error::A2aResult;
struct EchoAgent;
agent_executor!(EchoAgent, |_ctx, _queue| async {
Ok(())
});Structs§
- Event
Emitter - Ergonomic helper for emitting status and artifact events from an executor.
Functions§
- boxed_
future - Wraps an async expression into
Pin<Box<dyn Future<Output = T> + Send + 'a>>.