Skip to main content

AgentExecutor

Trait AgentExecutor 

Source
pub trait AgentExecutor: Send + Sync {
    // Required methods
    fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        task: &'life1 mut Task,
        message: &'life2 Message,
        ctx: &'life3 ExecutionContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn agent_card(&self) -> AgentCard;

    // Provided method
    fn extended_agent_card(&self, _claims: Option<&Value>) -> Option<AgentCard> { ... }
}
Expand description

Trait that users implement to define agent behavior.

The server calls execute when a message arrives. The executor updates the task’s status, appends artifacts, etc.

Required Methods§

Source

fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, task: &'life1 mut Task, message: &'life2 Message, ctx: &'life3 ExecutionContext, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Process a message against a task.

The task is mutable — update its status, append messages/artifacts. Return Ok(()) on success. The server persists the updated task.

ctx provides auth identity, tenant, and cancellation support. Executors that don’t need context can ignore it with _ctx.

Source

fn agent_card(&self) -> AgentCard

Return the public agent card (unauthenticated discovery).

Provided Methods§

Source

fn extended_agent_card(&self, _claims: Option<&Value>) -> Option<AgentCard>

Return the extended agent card for authenticated callers. Return None if extended card is not supported.

Implementors§