Skip to main content

Agent

Trait Agent 

Source
pub trait Agent: Send + Sync {
    type Options: Send + 'static;
    type Output: Send + 'static;

    // Required methods
    fn id(&self) -> Option<&str>;
    fn tools(&self) -> &ToolSet;
    fn generate(
        &self,
        call: AgentCall<Self::Options>,
    ) -> impl Future<Output = Result<GenerateTextResult<Self::Output>, Error>> + Send;
    fn stream(
        &self,
        call: AgentStreamCall<Self::Options>,
    ) -> impl Future<Output = Result<StreamTextResult<Self::Output>, Error>> + Send;
}
Expand description

An agent: a model plus configuration that answers prompts, possibly over several tool-calling steps.

Required Associated Types§

Source

type Options: Send + 'static

Per-call options (() when the agent takes none).

Source

type Output: Send + 'static

Structured output type (() when there is none).

Required Methods§

Source

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

Optional identifier used in telemetry.

Source

fn tools(&self) -> &ToolSet

Tools available to the agent.

Source

fn generate( &self, call: AgentCall<Self::Options>, ) -> impl Future<Output = Result<GenerateTextResult<Self::Output>, Error>> + Send

Runs the agent to completion.

Source

fn stream( &self, call: AgentStreamCall<Self::Options>, ) -> impl Future<Output = Result<StreamTextResult<Self::Output>, Error>> + Send

Runs the agent as a stream.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<Opt: Send + 'static, Out: Send + 'static> Agent for ToolLoopAgent<Opt, Out>

Source§

type Options = Opt

Source§

type Output = Out