Skip to main content

AgentConfig

Struct AgentConfig 

Source
pub struct AgentConfig {
Show 26 fields pub tools: Vec<ToolSource>, pub plugins: Vec<Arc<dyn Plugin>>, pub interventions: Vec<Arc<dyn InterventionHandler>>, pub model: Option<ModelSource>, pub aux_model: Option<ModelSource>, pub messages: Vec<Message>, pub system_prompt: Option<SystemPrompt>, pub app_state: Option<JsonObject>, pub model_state: Option<JsonObject>, pub printer: Option<bool>, pub retry_strategy: Option<Vec<RetryStrategy>>, pub structured_output_schema: Option<JsonSchema>, pub name: Option<String>, pub description: Option<String>, pub id: Option<String>, pub sort_tools: Option<bool>, pub tool_executor: Option<ToolExecutorStrategy>, pub conversation_manager: Option<Arc<dyn ConversationManager>>, pub context_manager: Option<ContextManagerStrategy>, pub background_tasks: Option<Toggle<BackgroundTasksConfig>>, pub trace_attributes: Option<BTreeMap<String, AttributeValue>>, pub baggage_attributes: Option<BTreeMap<String, String>>, pub sandbox: Option<Arc<dyn Sandbox>>, pub storage: Option<Arc<dyn Storage>>, pub session_manager: Option<SessionManager>, pub memory_manager: Option<MemoryManagerSource>,
}
Expand description

Configuration for an Agent (AgentConfig).

Build an agent from it with Agent::new, or set the same keys on Agent::builder.

use strands::{Agent, AgentConfig};
use strands::testing::MockModel;

let agent = Agent::new(AgentConfig {
    model: Some(MockModel::new().with_turn("Hi").into()),
    system_prompt: Some("You are a concise assistant.".into()),
    printer: Some(false),
    ..Default::default()
})?;
assert_eq!(agent.name(), "Strands Agent");

Fields§

§tools: Vec<ToolSource>

Initial tools; nested lists are flattened and agents become tools (ToolList). Set them with the builder’s tools(..), which takes any iterator of ToolSource items.

§plugins: Vec<Arc<dyn Plugin>>

Plugins to initialize with the agent. Set them with the builder’s plugins(..), which takes plugins by value or as Arcs.

§interventions: Vec<Arc<dyn InterventionHandler>>

Intervention handlers, evaluated in registration order at each lifecycle point (interventions); names must be unique. Set them with the builder’s interventions(..), which takes handlers of one type by value or as Arcs, or one at a time with intervention(..).

§model: Option<ModelSource>

The model the agent calls: a model instance, a ModelRouter or a Bedrock model id. Defaults to Bedrock, resolved when the agent first calls it. With a router, the agent’s model is the router’s default model.

§aux_model: Option<ModelSource>

The model for auxiliary side calls (conversation-manager summaries, memory extraction, classification); defaults to model. The context manager’s summarize strategy does not use it: it resolves its own model, then model. A router is rejected: side calls run outside the loop it attaches to.

§messages: Vec<Message>

Initial conversation history.

§system_prompt: Option<SystemPrompt>

The system prompt.

§app_state: Option<JsonObject>

Initial app state.

§model_state: Option<JsonObject>

Initial model-provider state, such as a restored response id.

§printer: Option<bool>

Print text, reasoning and tool activity to stdout as it streams. Defaults to true; turn it off in services with printer(false).

§retry_strategy: Option<Vec<RetryStrategy>>

Retry strategies for failed model calls. None installs the default DefaultModelRetryStrategy; an empty list disables retries.

§structured_output_schema: Option<JsonSchema>

JSON schema the agent’s final answer must satisfy. The builder sets it from a type with structured_output_schema::<T>(), or from JSON with structured_output_schema_json(..).

§name: Option<String>

The agent’s name. Defaults to Strands Agent.

§description: Option<String>

What the agent does.

§id: Option<String>

The agent’s id. Defaults to agent.

§sort_tools: Option<bool>

Send tool specs to the model sorted by name on every request (model calls, context summaries, token counts), to keep prompt-cache prefixes stable when the same tools are registered in a different order, for example from MCP servers (sortTools). Sorting happens before middleware, which can still reorder them. Defaults to false, which keeps registration order.

§tool_executor: Option<ToolExecutorStrategy>

How the tool calls of one model turn run. Defaults to concurrent.

§conversation_manager: Option<Arc<dyn ConversationManager>>

Keeps the history within the context window. Defaults to a SlidingWindowConversationManager of 40 messages; a stateful model uses NullConversationManager and rejects one. The builder’s conversation_manager(..) takes a manager by value or as an Arc.

§context_manager: Option<ContextManagerStrategy>

Strategy-driven context management: a preset, a configuration, an instance, or Disabled. When set (except Disabled) it owns overflow recovery and compression, and a co-provided conversation_manager is ignored.

§background_tasks: Option<Toggle<BackgroundTasksConfig>>

Background tool execution: true, a BackgroundTasksConfig, or false. Unset is off.

§trace_attributes: Option<BTreeMap<String, AttributeValue>>

Attributes added to every span of the agent, replacing a standard attribute of the same name. Keys other than the standard ones need the otel feature. The builder takes any iterator of key and value pairs.

§baggage_attributes: Option<BTreeMap<String, String>>

OpenTelemetry baggage entries attached to the context for every invocation, propagated to downstream services in the W3C baggage header; needs the otel feature. The builder takes any iterator of key and value pairs.

§sandbox: Option<Arc<dyn Sandbox>>

Where sandbox-aware tools run commands and code and read and write files (sandbox). None uses the shared NotASandboxLocalEnvironment, the host with no isolation. A configured sandbox’s get_tools are registered at initialization, except those whose name is already registered. The builder’s sandbox(..) takes a sandbox by value or as an Arc.

§storage: Option<Arc<dyn Storage>>

Default storage backend for agent subsystems (storage). Subsystems without their own storage (the session manager, the context manager’s archive) resolve from it, each under its own namespace; a subsystem’s own storage always wins. The builder’s storage(..) takes a storage by value or as an Arc.

§session_manager: Option<SessionManager>

Saves and restores the agent’s session. With one attached, the agent’s session id is the manager’s and the model receives it in its AgentMetadata.

§memory_manager: Option<MemoryManagerSource>

Cross-session memory: a MemoryManager or a MemoryManagerConfig the agent builds one from.

Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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