Expand description
A preconfigured Strands agent in one call.
A thin composition layer over the strands crate: create_harness wires a resolved
model, the vended system prompt, built-in tools, context management, session persistence,
skills and long-term memory into a plain strands::Agent, which callers can change or
extend like any other agent.
use strands::{InterruptResponse, StopReason};
use strands_harness::{Effort, HarnessAgentOptions, create_harness};
let mut agent = create_harness(
HarnessAgentOptions::builder()
.model("anthropic/claude-opus-5")
.effort(Effort::High)
.interventions("ask")
.mcp_servers("./mcp.json")
.build(),
)
.await?;
let mut result = agent.invoke("Fix the failing test in src/lib.rs").await?;
while result.stop_reason() == StopReason::Interrupt {
let answers: Vec<InterruptResponse> = result.interrupts().iter().map(ask_user).collect();
result = agent.invoke(answers).await?;
}
agent.shutdown().await?;§Models
model takes a model or router, or a string: bedrock/<id>, bedrock-mantle/<id>,
anthropic/<id>, openai/<id>, or a bare Bedrock model id. The default is
bedrock/global.anthropic.claude-opus-5. Effort maps to each provider’s reasoning fields,
and prompt caching is on by default.
§Features
| Feature | Adds |
|---|---|
bedrock (default) | bedrock/ model strings and the default model |
anthropic (default) | anthropic/ model strings |
openai (default) | openai/ model strings |
mantle (default) | bedrock-mantle/ model strings; turns on openai |
mcp (default) | mcp_servers |
cedar (default) | .cedar interventions |
monty-pool (default) | programmatic_tool_caller in a monty worker subprocess (Isolation) |
otel | Span export selected by OTEL_TRACES_EXPORTER |
Re-exports§
pub use plugins::EnvironmentContext;pub use plugins::EnvironmentContextConfig;pub use tools::file_tools::edit_tool;pub use tools::file_tools::read_tool;pub use tools::file_tools::write_tool;pub use tools::programmatic_tool_caller::DEFAULT_PROGRAMMATIC_TOOL_CALLER_DESCRIPTION;pub use tools::programmatic_tool_caller::Isolation;pub use tools::programmatic_tool_caller::MakeProgrammaticToolCallerOptions;pub use tools::programmatic_tool_caller::ProgrammaticToolCaller;pub use tools::programmatic_tool_caller::ProgrammaticToolCallerConfig;pub use tools::programmatic_tool_caller::make_programmatic_tool_caller;pub use tools::programmatic_tool_caller::programmatic_tool_caller;pub use tools::web_fetch::WebFetchConfig;pub use tools::web_fetch::WebFetchTransport;pub use tools::web_fetch::web_fetch_tool;pub use tools::web_search::WebSearchSetting;pub use tools::web_search::web_search_tool;pub use tools::web_search::MakeAgentCoreWebSearchOptions;pub use tools::web_search::make_agent_core_web_search;
Modules§
Structs§
- Agent
Spec - The resolved configuration of one child agent, handed to the
ChildAgentBuilder(AgentSpec).Nonefields inherit from the parent. - Builtin
Tools Config - Edits to the default built-in tool set (
BuiltinToolsConfig).falsedisables a tool,trueenables it, and a per-tool config enables and configures it (web_searchtakesWebSearchSetting::Exainstead).allis the portable config’s"*"key (defaulttrue): it includes the harness defaults; set it tofalseto start from nothing and enable tools one by one. - Child
Agent Builder - Turns a resolved spec into a child agent, built the way the parent was (
AgentBuilder). The builder may be async: the child is awaited before it runs. - Choice
- The model picks from a developer-supplied set (
Choice); withmultiple, more than one. - Choice
Option - A selectable entry of a
Choice(named to stay clear of the prelude’sOption). - Fixed
- The developer pins the value; the axis adds no model-facing parameter (
Fixed). - Harness
Agent Config - The complete portable form of a harness definition (
HarnessAgentConfig). - Harness
Agent Options - Options for
create_harness(HarnessAgentOptions). Every field is optional. - Harness
Agent Options Builder - Builds
HarnessAgentOptions; the setters are its fields. - Harness
Config Builtin Tools - JSON form of
BuiltinToolsConfig(HarnessConfigBuiltinTools), withweb_fetch.modelallowed to be a module reference. - Harness
Config Memory - JSON form of
MemoryConfig(HarnessConfigMemory); stores are declared separately asmemoryStoresmodule references. - Harness
Config WebFetch - JSON form of
WebFetchConfig(HarnessConfigWebFetch). - Harness
Dependencies - Dependencies a project declares for the runtimes that load its modules (
HarnessDependencies). - Harness
Module Reference - A reference to a value defined in code (
HarnessModuleReference). Rust parses and keeps these so a config round-trips, but cannot load them yet. - Inherit
- The child takes the parent’s value; the axis adds no model-facing parameter (
Inherit). - Make
Subagent Options - Options for
make_subagent(MakeSubagentOptions). - Memory
Config - The harness’s default long-term memory (
MemoryConfig); the empty config selects the defaults. For a different policy pass the SDK’smemory_managerinstead. - Open
- The model writes the value freely; the axis adds a string parameter (
Open). - Preset
- A named role, selected with
agent_type: a partial child configuration (Preset). - Read
Config - Per-tool config for the
readbuilt-in (ReadConfig). - Session
Config - Session persistence (
SessionConfig); the empty config selects the defaults. - Shell
Config - Per-tool config for the
shellbuilt-in (ShellConfig). - Subagent
Config - Per-tool config for the
subagentbuilt-in (SubagentConfig). - Subagent
Tool - The
subagenttool: builds a fresh child per call and streams it (SubagentTool).
Enums§
- Builtin
Plugin Name - A built-in feature plugin (
BuiltinPluginName). - Builtin
Tool Name - A built-in tool (
BuiltinToolName). - Builtin
Tools Option - What
builtin_toolsaccepts: a list pins exactly those tools (an empty list disables them all), a mapping edits the defaults. - Effort
- Reasoning effort applied to the resolved model (
Effort); seeHarnessAgentOptions::effort. - Harness
Config Builtin Tools Option - The portable
builtinTools: a list of names or a mapping. - Harness
Config Context Manager - The portable
contextManager(HarnessConfigContextManager:"auto","agentic"orfalse; JSON also accepts"off"forfalse). - Harness
Config Interventions - The portable
interventions: one value or a list (presets,.cedarpaths, policies). - Harness
Config McpServers - The portable
mcpServers: a path to a JSON file, or the server map itself. - Harness
Config Model - The summarizer model in a portable
web_fetchconfig: a"provider/name"string or a model module reference. - Harness
Config Skills - The portable
skills: on or off, one source, or a list of sources. - Harness
Module Kind - What a module reference provides (
HarnessModuleKind). - Harness
Module Language - The language a module reference is written in (
HarnessModuleLanguage). - Intervention
Value - One
interventionsvalue (InterventionValue): a preset, a.cedarpath or a policy string, or a handler. - Interventions
Option - What
interventionsaccepts (InterventionsOption): one value, or a list layering, for example, a Cedar policy with one human gate. - McpServers
Option - Where
mcp_serverscome from. The type exists with or without themcpfeature; without it,create_harnessfails when servers are set. - Memory
Option - What
memoryaccepts. - Session
Option - What
sessionaccepts. - Setting
- A setting that is a boolean or a config object, such as a built-in tool’s entry in
BuiltinToolsConfig: on, off, or on with a config. - Skills
Option - What
skillsaccepts.
Constants§
- BUILTIN_
PLUGIN_ NAMES - Every built-in plugin (
BUILTIN_PLUGIN_NAMES). - BUILTIN_
TOOL_ NAMES - Every built-in tool, in canonical order (
BUILTIN_TOOL_NAMES). - HARNESS_
CONTRACT - The model-neutral behavioral contract every harness system prompt starts with.
Statics§
- DEFAULT_
HARNESS_ AGENT_ CONFIG - The defaults every key of a portable config falls back to (
DEFAULT_HARNESS_AGENT_CONFIG).
Functions§
- build_
system_ prompt - Assembles the harness contract, an optional domain block and per-request context, separated by blank lines.
- create_
harness - Builds a preconfigured Strands agent with the harness defaults.
- define_
harness_ agent_ config - Validates a config built in code the way a parsed one is.
- harness_
agent_ options_ from_ config - Maps a portable config onto
HarnessAgentOptions. - make_
subagent - Creates a subagent tool whose input schema follows the axis policies and presets.
- supports_
thinking - Whether reasoning can be configured for
model:truefor a model instance or router; for a string, whether its provider and model take any reasoning level.Noneis the harness default model. - supports_
web_ search - Whether
web_searchworks formodelwithout the Exa opt-in: where the provider has native search, and on every Bedrock API, where AgentCore web search serves it.falsefor a model instance or router, whose provider is unknown;Noneis the harness default model.
Type Aliases§
- Context
Manager Option - What
context_manageraccepts (ContextManagerOption): exactly the SDK’sContextManagerStrategy, whoseDisabledstands for bothfalseandnull.