pub struct AgentConfig {Show 13 fields
pub id: String,
pub model: String,
pub system_prompt: String,
pub max_rounds: usize,
pub tool_executor: Arc<dyn ToolExecutor>,
pub chat_options: Option<ChatOptions>,
pub fallback_models: Vec<String>,
pub llm_retry_policy: LlmRetryPolicy,
pub plugins: Vec<Arc<dyn AgentPlugin>>,
pub stop_conditions: Vec<Arc<dyn StopPolicy>>,
pub stop_condition_specs: Vec<StopConditionSpec>,
pub step_tool_provider: Option<Arc<dyn StepToolProvider>>,
pub llm_executor: Option<Arc<dyn LlmExecutor>>,
}Expand description
Runtime configuration for the agent loop.
Fields§
§id: StringUnique identifier for this agent.
model: StringModel identifier (e.g., “gpt-4”, “claude-3-opus”).
system_prompt: StringSystem prompt for the LLM.
max_rounds: usizeMaximum number of tool call rounds before stopping.
tool_executor: Arc<dyn ToolExecutor>Tool execution strategy (parallel, sequential, or custom).
chat_options: Option<ChatOptions>Chat options for the LLM.
fallback_models: Vec<String>Fallback model ids used when the primary model fails.
Evaluated in order after model.
llm_retry_policy: LlmRetryPolicyRetry policy for LLM inference failures.
plugins: Vec<Arc<dyn AgentPlugin>>Plugins to run during the agent loop.
stop_conditions: Vec<Arc<dyn StopPolicy>>Composable stop policies checked after each tool-call round.
When empty (and stop_condition_specs is also empty), a default
crate::engine::stop_conditions::MaxRounds condition is created from max_rounds.
When non-empty, max_rounds is ignored.
stop_condition_specs: Vec<StopConditionSpec>Declarative stop condition specs, resolved to Arc<dyn StopPolicy>
at runtime.
Specs are appended after explicit stop_conditions in evaluation order.
step_tool_provider: Option<Arc<dyn StepToolProvider>>Optional per-step tool provider.
When not set, the loop uses a static provider derived from the tools
map passed to run_step / run_loop / run_loop_stream.
llm_executor: Option<Arc<dyn LlmExecutor>>Optional LLM executor override.
When not set, the loop uses GenaiLlmExecutor with Client::default().
Implementations§
Source§impl AgentConfig
impl AgentConfig
Sourcepub fn with_id(id: impl Into<String>, model: impl Into<String>) -> Self
pub fn with_id(id: impl Into<String>, model: impl Into<String>) -> Self
Create a new instance with explicit id and model.
Sourcepub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self
Set system prompt.
Sourcepub fn with_max_rounds(self, max_rounds: usize) -> Self
pub fn with_max_rounds(self, max_rounds: usize) -> Self
Set max rounds.
Sourcepub fn with_chat_options(self, options: ChatOptions) -> Self
pub fn with_chat_options(self, options: ChatOptions) -> Self
Set chat options.
Sourcepub fn with_fallback_models(self, models: Vec<String>) -> Self
pub fn with_fallback_models(self, models: Vec<String>) -> Self
Set fallback model ids to try after the primary model.
Sourcepub fn with_fallback_model(self, model: impl Into<String>) -> Self
pub fn with_fallback_model(self, model: impl Into<String>) -> Self
Add a single fallback model id.
Sourcepub fn with_llm_retry_policy(self, policy: LlmRetryPolicy) -> Self
pub fn with_llm_retry_policy(self, policy: LlmRetryPolicy) -> Self
Set LLM retry policy.
Sourcepub fn with_stop_condition_spec(self, spec: StopConditionSpec) -> Self
pub fn with_stop_condition_spec(self, spec: StopConditionSpec) -> Self
Add a declarative stop policy spec.
Sourcepub fn with_stop_condition_specs(self, specs: Vec<StopConditionSpec>) -> Self
pub fn with_stop_condition_specs(self, specs: Vec<StopConditionSpec>) -> Self
Set all declarative stop policy specs, replacing any previously set.
Sourcepub fn with_plugins(self, plugins: Vec<Arc<dyn AgentPlugin>>) -> Self
pub fn with_plugins(self, plugins: Vec<Arc<dyn AgentPlugin>>) -> Self
Set plugins.
Sourcepub fn with_plugin(self, plugin: Arc<dyn AgentPlugin>) -> Self
pub fn with_plugin(self, plugin: Arc<dyn AgentPlugin>) -> Self
Add a single plugin.
Sourcepub fn with_stop_condition(self, condition: impl StopPolicy + 'static) -> Self
pub fn with_stop_condition(self, condition: impl StopPolicy + 'static) -> Self
Add a stop policy.
Sourcepub fn with_stop_conditions(self, conditions: Vec<Arc<dyn StopPolicy>>) -> Self
pub fn with_stop_conditions(self, conditions: Vec<Arc<dyn StopPolicy>>) -> Self
Set all stop policies, replacing any previously set.
Sourcepub fn with_tool_executor(self, executor: Arc<dyn ToolExecutor>) -> Self
pub fn with_tool_executor(self, executor: Arc<dyn ToolExecutor>) -> Self
Set tool executor strategy.
Sourcepub fn with_parallel_tools(self, parallel: bool) -> Self
pub fn with_parallel_tools(self, parallel: bool) -> Self
Set parallel tool execution convenience strategy.
Sourcepub fn with_tools(self, tools: HashMap<String, Arc<dyn Tool>>) -> Self
pub fn with_tools(self, tools: HashMap<String, Arc<dyn Tool>>) -> Self
Set static tool map (wraps in [StaticStepToolProvider]).
Prefer passing tools directly to [run_loop] / [run_loop_stream];
use this only when you need to set tools via step_tool_provider.
Sourcepub fn with_step_tool_provider(
self,
provider: Arc<dyn StepToolProvider>,
) -> Self
pub fn with_step_tool_provider( self, provider: Arc<dyn StepToolProvider>, ) -> Self
Set per-step tool provider.
Sourcepub fn with_llm_executor(self, executor: Arc<dyn LlmExecutor>) -> Self
pub fn with_llm_executor(self, executor: Arc<dyn LlmExecutor>) -> Self
Set LLM executor.
Sourcepub fn has_plugins(&self) -> bool
pub fn has_plugins(&self) -> bool
Check if any plugins are configured.
Trait Implementations§
Source§impl Clone for AgentConfig
impl Clone for AgentConfig
Source§fn clone(&self) -> AgentConfig
fn clone(&self) -> AgentConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more