Agent Builder • Rust AI Agent SDK
AgentBuilder: Builder for creating agents
AgentBuilder
Defined in the builder module.
Rust AI Agent SDK
Builder for creating agents
Fields
| Name | Type | Description |
|---|---|---|
name | Option<String> | – |
instructions | Option<String> | – |
llm_config | LlmConfig | – |
tools | Vec<Box<dyn Tool>> | – |
memory_config | MemoryConfig | – |
config | AgentConfig | – |
Methods
new
fn new() -> SelfCreate a new agent builder
name
fn name(mut self, name: impl Into<String>) -> SelfSet the agent name
Parameters:
| Name | Type |
|---|---|
name | impl Into<String> |
instructions
fn instructions(mut self, instructions: impl Into<String>) -> SelfSet the system instructions
Parameters:
| Name | Type |
|---|---|
instructions | impl Into<String> |
model
fn model(mut self, model: impl Into<String>) -> SelfSet the LLM model
Parameters:
| Name | Type |
|---|---|
model | impl Into<String> |
llm
fn llm(self, model: impl Into<String>) -> SelfAlias for model() – matches Python SDK
Parameters:
| Name | Type |
|---|---|
model | impl Into<String> |
api_key
fn api_key(mut self, key: impl Into<String>) -> SelfSet the API key
Parameters:
| Name | Type |
|---|---|
key | impl Into<String> |
base_url
fn base_url(mut self, url: impl Into<String>) -> SelfSet the base URL for the LLM API
Parameters:
| Name | Type |
|---|---|
url | impl Into<String> |
temperature
fn temperature(mut self, temp: f32) -> SelfSet the temperature
Parameters:
| Name | Type |
|---|---|
temp | f32 |
max_tokens
fn max_tokens(mut self, max: u32) -> SelfSet max tokens
Parameters:
| Name | Type |
|---|---|
max | u32 |
tool
fn tool(mut self, tool: impl Tool + 'static) -> SelfAdd a tool
Parameters:
| Name | Type |
|---|---|
tool | impl Tool + 'static |
tools
fn tools(mut self, tools: impl IntoIterator<Item = impl Tool + 'static>) -> SelfAdd multiple tools
Parameters:
| Name | Type |
|---|---|
tools | impl IntoIterator<Item |
memory
fn memory(mut self, enabled: bool) -> SelfEnable memory
Parameters:
| Name | Type |
|---|---|
enabled | bool |
memory_config
fn memory_config(mut self, config: MemoryConfig) -> SelfSet memory configuration
Parameters:
| Name | Type |
|---|---|
config | MemoryConfig |
max_iterations
fn max_iterations(mut self, max: usize) -> SelfSet max iterations for tool calling
Parameters:
| Name | Type |
|---|---|
max | usize |
verbose
fn verbose(mut self, enabled: bool) -> SelfEnable verbose output
Parameters:
| Name | Type |
|---|---|
enabled | bool |
stream
fn stream(mut self, enabled: bool) -> SelfEnable/disable streaming
Parameters:
| Name | Type |
|---|---|
enabled | bool |
build
fn build(self) -> Result<Agent>Build the agent
Usage
let agent = Agent::new()
.name("assistant")
.instructions("You are helpful")
.model("gpt-4o-mini")
.build()?;Source
View on GitHubpraisonai/src/agent/builder.rs at line 47