pub struct AgentOptions { /* private fields */ }Expand description
Configuration options for an AI agent instance.
AgentOptions controls all aspects of agent behavior including model selection,
conversation management, tool usage, and lifecycle hooks. This struct should be
constructed using AgentOptions::builder() rather than direct instantiation
to ensure required fields are validated.
§Architecture
The options are organized into several functional areas:
- Model Configuration:
model,base_url,api_key,temperature,max_tokens - Conversation Control:
system_prompt,max_turns,timeout - Tool Management:
tools,auto_execute_tools,max_tool_iterations - Lifecycle Hooks:
hooksfor monitoring and interception
§Thread Safety
Tools are wrapped in Arc<Tool> to allow efficient cloning and sharing across
threads, as agents may need to be cloned for parallel processing.
§Examples
use open_agent::AgentOptions;
let options = AgentOptions::builder()
.model("qwen2.5-32b-instruct")
.base_url("http://localhost:1234/v1")
.system_prompt("You are a helpful coding assistant")
.max_turns(5)
.temperature(0.7)
.build()
.expect("Valid configuration");Implementations§
Source§impl AgentOptions
impl AgentOptions
Sourcepub fn builder() -> AgentOptionsBuilder
pub fn builder() -> AgentOptionsBuilder
Creates a new builder for constructing AgentOptions.
The builder pattern is used because:
- Some fields are required (model, base_url) and need validation
- Many fields have sensible defaults that can be overridden
- The API is more discoverable and readable than struct initialization
§Example
use open_agent::AgentOptions;
let options = AgentOptions::builder()
.model("qwen2.5-32b-instruct")
.base_url("http://localhost:1234/v1")
.build()
.expect("Valid configuration");Sourcepub fn system_prompt(&self) -> &str
pub fn system_prompt(&self) -> &str
Returns the system prompt.
Sourcepub fn max_tokens(&self) -> Option<u32>
pub fn max_tokens(&self) -> Option<u32>
Returns the maximum tokens setting.
Sourcepub fn temperature(&self) -> f32
pub fn temperature(&self) -> f32
Returns the sampling temperature.
Sourcepub fn auto_execute_tools(&self) -> bool
pub fn auto_execute_tools(&self) -> bool
Returns whether automatic tool execution is enabled.
Sourcepub fn max_tool_iterations(&self) -> u32
pub fn max_tool_iterations(&self) -> u32
Returns the maximum tool execution iterations.
Trait Implementations§
Source§impl Clone for AgentOptions
impl Clone for AgentOptions
Source§fn clone(&self) -> AgentOptions
fn clone(&self) -> AgentOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentOptions
Custom Debug implementation to prevent sensitive data leakage.
impl Debug for AgentOptions
Custom Debug implementation to prevent sensitive data leakage.
We override the default Debug implementation because:
- The
api_keyfield may contain sensitive credentials that shouldn’t appear in logs or error messages - The
toolsvector contains Arc-wrapped closures that don’t debug nicely, so we show a count instead
This ensures that debug output is safe for logging while remaining useful for troubleshooting.
Source§impl Default for AgentOptions
Default values optimized for common single-turn use cases.
impl Default for AgentOptions
Default values optimized for common single-turn use cases.
These defaults are chosen to:
- Require explicit configuration of critical fields (model, base_url)
- Provide safe, sensible defaults for optional fields
- Work with local inference servers that don’t need authentication