pub struct Agent {
pub name: String,
pub instructions: Option<Instructions>,
pub model: String,
pub tools: Vec<Arc<dyn Tool>>,
pub handoffs: Vec<Agent>,
pub model_settings: ModelSettings,
pub handoff_description: Option<String>,
}Expand description
An AI agent configured with instructions, tools, and settings
Agents are the core abstraction for building AI applications. They encapsulate a model, system prompt (instructions), tools, and other configuration.
Fields§
§name: StringThe name of the agent
instructions: Option<Instructions>Instructions (system prompt) for the agent
model: StringThe model to use (e.g., “gpt-4”, “claude-3-5-sonnet”)
tools: Vec<Arc<dyn Tool>>Tools available to the agent
handoffs: Vec<Agent>Handoff agents (sub-agents the agent can delegate to)
model_settings: ModelSettingsModel settings (temperature, max_tokens, etc.)
handoff_description: Option<String>Description for when this agent is used as a handoff
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn builder(name: impl Into<String>) -> AgentBuilder
pub fn builder(name: impl Into<String>) -> AgentBuilder
Create a builder for the agent
Sourcepub fn clone_with(&self) -> AgentBuilder
pub fn clone_with(&self) -> AgentBuilder
Clone the agent with modifications
Sourcepub fn system_prompt(&self) -> Option<&str>
pub fn system_prompt(&self) -> Option<&str>
Get the system prompt for the agent
Sourcepub async fn run(
&self,
input: impl Into<String>,
config: &RunConfig,
) -> Result<RunResult>
pub async fn run( &self, input: impl Into<String>, config: &RunConfig, ) -> Result<RunResult>
Run the agent with the given input
This is a convenience method that creates a default RunConfig.
For more control, use Runner::run directly.
Sourcepub fn with_handoff(self, agent: Agent) -> Self
pub fn with_handoff(self, agent: Agent) -> Self
Add a handoff agent