pub trait Agent<C>: Send + Sync{
// Required methods
fn name(&self) -> String;
fn description(&self) -> String;
fn run(
&self,
ctx: C,
prompt: String,
resources: Vec<Resource>,
) -> impl Future<Output = Result<AgentOutput, BoxError>> + Send;
// Provided methods
fn definition(&self) -> FunctionDefinition { ... }
fn supported_resource_tags(&self) -> Vec<String> { ... }
fn select_resources(&self, resources: &mut Vec<Resource>) -> Vec<Resource> { ... }
fn init(&self, _ctx: C) -> impl Future<Output = Result<(), BoxError>> + Send { ... }
fn tool_dependencies(&self) -> Vec<String> { ... }
}Expand description
Strongly typed interface for an AI agent.
§Type Parameters
C: Runtime context implementingAgentContext.
Required Methods§
Sourcefn name(&self) -> String
fn name(&self) -> String
Returns the unique agent name.
Names are registered case-insensitively and stored in lowercase.
§Rules
- Must not be empty;
- Must not exceed 64 characters;
- Must start with a lowercase letter;
- Can only contain: lowercase letters (a-z), digits (0-9), and underscores (_);
- Unique within the engine in lowercase.
Sourcefn description(&self) -> String
fn description(&self) -> String
Returns a concise description of the agent’s capability.
Sourcefn run(
&self,
ctx: C,
prompt: String,
resources: Vec<Resource>,
) -> impl Future<Output = Result<AgentOutput, BoxError>> + Send
fn run( &self, ctx: C, prompt: String, resources: Vec<Resource>, ) -> impl Future<Output = Result<AgentOutput, BoxError>> + Send
Executes the agent with the given context and inputs.
§Arguments
ctx: The execution context implementingAgentContext.prompt: The input prompt or message for the agent.resources: Additional resources selected for this agent. Ignore resources that are not useful.
§Returns
A future resolving to AgentOutput.
Provided Methods§
Sourcefn definition(&self) -> FunctionDefinition
fn definition(&self) -> FunctionDefinition
Returns the function definition used for LLM/tool-call integration.
§Returns
FunctionDefinition: The structured definition of the agent’s capabilities.
Returns resource tags this agent can consume.
The default implementation returns an empty list, meaning no resources
are selected for this agent. Return vec!["*".into()] to accept all
attached resources.
§Returns
Resource tags supported by this agent.
Sourcefn select_resources(&self, resources: &mut Vec<Resource>) -> Vec<Resource>
fn select_resources(&self, resources: &mut Vec<Resource>) -> Vec<Resource>
Removes and returns resources matching this agent’s supported tags.
Sourcefn init(&self, _ctx: C) -> impl Future<Output = Result<(), BoxError>> + Send
fn init(&self, _ctx: C) -> impl Future<Output = Result<(), BoxError>> + Send
Initializes the agent with the given context.
Runtimes call this once while building the engine.
Sourcefn tool_dependencies(&self) -> Vec<String>
fn tool_dependencies(&self) -> Vec<String>
Returns tool names required by this agent.
Runtimes use this list to validate that required tools are registered.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.