pub trait Agent: Send + Sync {
// Required methods
fn plan<'life0, 'life1, 'async_trait>(
&'life0 self,
intermediate_steps: &'life1 [(AgentAction, String)],
inputs: PromptArgs,
) -> Pin<Box<dyn Future<Output = Result<AgentEvent, AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_tools(&self) -> Vec<Arc<dyn Tool>>;
// Provided methods
fn plan_with_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
intermediate_steps: &'life1 [(AgentAction, String)],
inputs: PromptArgs,
) -> Pin<Box<dyn Future<Output = Result<(AgentEvent, Option<TokenUsage>), AgentError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn plan_stream<'a>(
&'a self,
intermediate_steps: &'a [(AgentAction, String)],
inputs: PromptArgs,
) -> PlanEventStream<'a> { ... }
}Required Methods§
fn plan<'life0, 'life1, 'async_trait>(
&'life0 self,
intermediate_steps: &'life1 [(AgentAction, String)],
inputs: PromptArgs,
) -> Pin<Box<dyn Future<Output = Result<AgentEvent, AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tools(&self) -> Vec<Arc<dyn Tool>>
Provided Methods§
Sourcefn plan_with_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
intermediate_steps: &'life1 [(AgentAction, String)],
inputs: PromptArgs,
) -> Pin<Box<dyn Future<Output = Result<(AgentEvent, Option<TokenUsage>), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn plan_with_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
intermediate_steps: &'life1 [(AgentAction, String)],
inputs: PromptArgs,
) -> Pin<Box<dyn Future<Output = Result<(AgentEvent, Option<TokenUsage>), AgentError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Like plan, and also returns the tokens the model call(s) used, so
AgentExecutor can report a run’s total.
The default returns no usage. Agents built on an LLM chain override it.
Sourcefn plan_stream<'a>(
&'a self,
intermediate_steps: &'a [(AgentAction, String)],
inputs: PromptArgs,
) -> PlanEventStream<'a>
fn plan_stream<'a>( &'a self, intermediate_steps: &'a [(AgentAction, String)], inputs: PromptArgs, ) -> PlanEventStream<'a>
Like plan, but streams the model’s text while it is generated.
The default implementation calls plan_with_usage and, when the agent finishes,
emits the final answer as one Text chunk, then the usage (if any), then Done.
Agents whose raw model output is readable text (like
OpenAiToolAgent) override it to stream token by
token.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".