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
impl Debug for AgentConfig
Auto Trait Implementations§
impl !RefUnwindSafe for AgentConfig
impl !UnwindSafe for AgentConfig
impl Freeze for AgentConfig
impl Send for AgentConfig
impl Sync for AgentConfig
impl Unpin for AgentConfig
impl UnsafeUnpin for AgentConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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