Skip to main content

SupportsAgentRun

Trait SupportsAgentRun 

Source
pub trait SupportsAgentRun: Send + Sync {
    // Required methods
    fn run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: Vec<Message>,
        session: Option<&'life1 mut AgentSession>,
    ) -> Pin<Box<dyn Future<Output = Result<AgentResponse, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn id(&self) -> &str;

    // Provided methods
    fn run_with_options<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: Vec<Message>,
        session: Option<&'life1 mut AgentSession>,
        options: AgentRunOptions,
    ) -> Pin<Box<dyn Future<Output = Result<AgentResponse, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn run_stream<'life0, 'async_trait>(
        &'life0 self,
        messages: Vec<Message>,
        session: Option<AgentSession>,
        options: Option<AgentRunOptions>,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<AgentResponseUpdate, Error>> + Send>>, Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn name(&self) -> Option<&str> { ... }
    fn display_name(&self) -> String { ... }
    fn create_session(&self) -> AgentSession { ... }
}
Expand description

The common interface implemented by all agents.

Required Methods§

Source

fn run<'life0, 'life1, 'async_trait>( &'life0 self, messages: Vec<Message>, session: Option<&'life1 mut AgentSession>, ) -> Pin<Box<dyn Future<Output = Result<AgentResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Run the agent to completion.

Source

fn id(&self) -> &str

A stable identifier for this agent.

Provided Methods§

Source

fn run_with_options<'life0, 'life1, 'async_trait>( &'life0 self, messages: Vec<Message>, session: Option<&'life1 mut AgentSession>, options: AgentRunOptions, ) -> Pin<Box<dyn Future<Output = Result<AgentResponse, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Run the agent to completion, applying per-run AgentRunOptions over the agent’s build-time defaults.

The default implementation ignores options and delegates to SupportsAgentRun::run, emitting a tracing::warn! when non-empty options are supplied — mirroring upstream agents that silently drop kwargs they do not understand. Agents that support per-run overrides (notably Agent) override this.

Source

fn run_stream<'life0, 'async_trait>( &'life0 self, messages: Vec<Message>, session: Option<AgentSession>, options: Option<AgentRunOptions>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<AgentResponseUpdate, Error>> + Send>>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Run the agent and stream incremental AgentResponseUpdates.

The default implementation is a buffered fallback: it runs to completion via SupportsAgentRun::run_with_options and yields the response’s messages as updates. Agents with a real streaming backend (notably Agent, WorkflowAgent, and the A2A client agent) override this to stream incrementally.

session is taken by value: the returned stream owns it and drives its context providers (including any history provider) once the stream is fully consumed. When a provider’s storage is shared (as InMemoryHistoryProvider’s is, via Arc), the write-back is observable through a clone taken before streaming.

Source

fn name(&self) -> Option<&str>

The optional human-readable name.

Source

fn display_name(&self) -> String

The display name: name if set, else id.

Source

fn create_session(&self) -> AgentSession

A fresh session for a new conversation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§