Skip to main content

AgentConfig

Struct AgentConfig 

Source
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: String

Unique identifier for this agent.

§model: String

Model identifier (e.g., “gpt-4”, “claude-3-opus”).

§system_prompt: String

System prompt for the LLM.

§max_rounds: usize

Maximum 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: LlmRetryPolicy

Retry 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

Source

pub fn new(model: impl Into<String>) -> Self

Create a new instance with the given model id.

Source

pub fn with_id(id: impl Into<String>, model: impl Into<String>) -> Self

Create a new instance with explicit id and model.

Source

pub fn with_system_prompt(self, prompt: impl Into<String>) -> Self

Set system prompt.

Source

pub fn with_max_rounds(self, max_rounds: usize) -> Self

Set max rounds.

Source

pub fn with_chat_options(self, options: ChatOptions) -> Self

Set chat options.

Source

pub fn with_fallback_models(self, models: Vec<String>) -> Self

Set fallback model ids to try after the primary model.

Source

pub fn with_fallback_model(self, model: impl Into<String>) -> Self

Add a single fallback model id.

Source

pub fn with_llm_retry_policy(self, policy: LlmRetryPolicy) -> Self

Set LLM retry policy.

Source

pub fn with_stop_condition_spec(self, spec: StopConditionSpec) -> Self

Add a declarative stop policy spec.

Source

pub fn with_stop_condition_specs(self, specs: Vec<StopConditionSpec>) -> Self

Set all declarative stop policy specs, replacing any previously set.

Source

pub fn with_plugins(self, plugins: Vec<Arc<dyn AgentPlugin>>) -> Self

Set plugins.

Source

pub fn with_plugin(self, plugin: Arc<dyn AgentPlugin>) -> Self

Add a single plugin.

Source

pub fn with_stop_condition(self, condition: impl StopPolicy + 'static) -> Self

Add a stop policy.

Source

pub fn with_stop_conditions(self, conditions: Vec<Arc<dyn StopPolicy>>) -> Self

Set all stop policies, replacing any previously set.

Source

pub fn with_tool_executor(self, executor: Arc<dyn ToolExecutor>) -> Self

Set tool executor strategy.

Source

pub fn with_parallel_tools(self, parallel: bool) -> Self

Set parallel tool execution convenience strategy.

Source

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.

Source

pub fn with_step_tool_provider( self, provider: Arc<dyn StepToolProvider>, ) -> Self

Set per-step tool provider.

Source

pub fn with_llm_executor(self, executor: Arc<dyn LlmExecutor>) -> Self

Set LLM executor.

Source

pub fn has_plugins(&self) -> bool

Check if any plugins are configured.

Trait Implementations§

Source§

impl Clone for AgentConfig

Source§

fn clone(&self) -> AgentConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AgentConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more