Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Developer preview. The API may change in any 0.x release.
The Strands harness gets you a capable, ready-to-work agent in one call. It's built on the
Strands Harness SDK by the Strands team at Amazon Web Services (AWS).
It composes the SDK's building blocks (a model loop, tools, just-in-time context assembly, sessions, hooks, and more)
into one agent with sensible, tested defaults and a tuned system prompt. Every default is overridable, and what you
get back is a plain strands::Agent, so anything the harness sets up, you can change, extend, or replace.
use ;
async
The Rust harness matches the Python (strands-harness) and TypeScript
(@strands-agents/harness) harnesses in behaviour, defaults
and portable config, re-cased to Rust idiom. The places where it differs are listed in
DIVERGENCES.md.
The interface
create_harness(options).await builds a ready strands::Agent. Every field of HarnessAgentOptions is optional;
these are the defaults, with the options that have no default value commented out:
use ;
let options = builder
.model // "provider/name", a bare Bedrock id, a model or a router
.effort // Auto | Off | Minimal | Low | Medium | High | Xhigh | Max
// .instructions("...") domain text appended to the system prompt
// .tools([..]) your tools, added alongside the built-ins
// .plugins([..]) your Strands plugins, added alongside the built-in ones
// .mcp_servers(".mcp.json") MCP servers: a mcpServers JSON path or the map itself
// .builtin_tools(..) a list pins the set; a BuiltinToolsConfig edits the defaults (see below)
// .background_tasks(false) SDK Background Tasks policy; false to disable
.builtin_plugins // the default; [] for none
// .caching(false) cache system prompt, tools and history where supported; false turns it off
.context_manager // Auto | Agentic | a config or instance | Disabled
.session // true | a SessionConfig | a SessionManager | false
.skills // true (./.agent/skills) | path(s) or URL(s) | an AgentSkills plugin | false
.memory // true (./.agent/memory) | a MemoryConfig | a MemoryManager | false
// .interventions("ask") gate tool calls: "ask" | "smart" | a policy | a .cedar file | a handler
// ...plus the AgentConfig fields the harness doesn't own, such as name, aux_model or sandbox
.build;
The fields are public, so struct update syntax works too:
HarnessAgentOptions { effort: Effort::High, ..Default::default() }. The sections below walk through each option in
turn.
For a JSON-compatible definition, parse a HarnessAgentConfig with serde_json (or validate one built in code with
define_harness_agent_config) and pass it through harness_agent_options_from_config. It's the same portable format
the Python and TypeScript harnesses read. Executable values such as custom tools, models and intervention handlers are
module references there; Rust parses and round-trips them, but fails on the first one when converting to options,
since it can't load modules yet.
Installation
[]
= "0.1"
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
strands is the SDK the harness builds on. You need it alongside the harness for its types: the returned Agent,
the #[tool] macro, hooks, and interventions. The minimum supported Rust version is 1.96.
Cargo features select the providers and integrations. Everything except otel is on by default:
| Feature | Adds |
|---|---|
bedrock |
bedrock/ model strings, the default model (Claude on Bedrock also turns on strands/anthropic) and the AgentCore-backed web_search |
anthropic |
anthropic/ model strings |
openai |
openai/ model strings |
mantle |
bedrock-mantle/ model strings and the AgentCore-backed web_search; turns on openai |
mcp |
mcp_servers and the Exa-backed web_search |
cedar |
.cedar interventions |
monty-pool |
runs programmatic_tool_caller code in a monty worker subprocess |
otel |
span export selected by OTEL_TRACES_EXPORTER |
To leave out the AWS SDK, turn off the defaults and pick a provider. A model string whose provider feature is off
fails with an error naming the feature, so set model to a provider you enabled:
= { = "0.1", = false, = ["anthropic", "mcp"] }
= { = "0.1", = false }
The default agent runs on Amazon Bedrock, with credentials from the AWS default chain and the region from
AWS_REGION (or AWS_DEFAULT_REGION, else the AWS config's region). Claude on Bedrock runs on the Anthropic Messages
API through Bedrock's InvokeModel API; other Bedrock models use Converse. The other providers read
ANTHROPIC_API_KEY and OPENAI_API_KEY.
programmatic_tool_caller runs the model's code in a monty worker process when it finds one, so a crash or runaway
allocation ends only the worker. Install the worker with:
The harness looks for it through MONTY_BIN, then monty on PATH, then a target/{debug,release} build in the
running executable's cargo workspace. Without one, the interpreter runs in-process and logs a warning that it has no
crash isolation and no cap on its total memory.
What you get by default
Out of the box, create_harness gives you an agent that:
- Runs on frontier models with reasoning on, across Amazon Bedrock, Bedrock Mantle, Anthropic, and OpenAI. The default is Claude Opus 5.5 on Amazon Bedrock, behind a tuned system prompt: explore before changing things, confirm before anything irreversible, verify before calling a task done.
- Comes with working tools: a shell, file tools (
read,write,edit), web access,subagentfor delegation, andprogrammatic_tool_caller, a sandboxed Python interpreter where it writes code that chains, loops over, and parallelizes its other tools for more complex orchestration. - Manages its own context so long tasks stay coherent and affordable. It truncates bulky tool results into storage, leaving a short reference to pull them back, and summarizes older turns as the context window fills. The reused parts of each request are cached wherever the provider supports it.
- Remembers. Every conversation is saved to disk and resumable by session id, and long-term memory distills facts across conversations into markdown files it folds back into context.
- Is just a
strands::Agent. Every default is overridable, and because the return value is a plainAgent, the full SDK is yours: interventions, hooks, MCP tools, and custom session backends all plug in.
Everything above is a default, not a constraint. Here's how to adjust each piece.
Choosing a model
Pass a provider/model string, a bare Bedrock model id, or a ready-made model or ModelRouter:
use HarnessAgentOptions;
builder.model.build; // Anthropic's API directly
builder.model.build; // OpenAI
builder.model.build; // the default, spelled out
builder.model.build; // Bedrock's OpenAI-compatible API
#
The provider/model string is a shorthand for bedrock, bedrock-mantle, anthropic, and openai. For any other
provider, pass a model instance and it's used as is. Reasoning effort is mapped to whatever each provider expects, so
you set it once for every provider:
use ;
builder.effort.build; // Minimal | Low | Medium | High | Xhigh | Max, as offered
builder.effort.build; // the model vendor's default level (else High), the default
builder.effort.build; // reasoning off (the provider's `none` level if it has one)
A level the provider doesn't offer fails create_harness, so a typo or an unsupported request never passes silently.
Effort also parses from its config spelling ("xhigh".parse::<Effort>()). When you pass a model instance, a
non-default effort (like an explicit caching) is not applied and a warning is logged: configure reasoning on the
instance itself. supports_thinking and supports_web_search answer what a model string supports before you build
anything.
Giving it your own instructions and tools
instructions adds a domain block after the built-in contract. Use it to give the agent its identity, scope, and any
rules you want it to follow. tools adds your own tools alongside the built-in ones:
use ;
use ;
/// Fetch a support ticket by id.
async
async
Prefer a leaner or different tool set? builtin_tools takes two shapes. A list pins exactly the tools named (an
empty list turns them all off); a BuiltinToolsConfig edits the default set, where false removes a tool, true
adds one, and a per-tool config enables and configures it. Five tools take a config: shell (ShellConfig:
description), read (ReadConfig: media, whether images and documents come back as viewable media), web_fetch
(WebFetchConfig: model, transport), programmatic_tool_caller (ProgrammaticToolCallerConfig:
allowed_tools, timeout) and subagent (SubagentConfig: max_depth); write and edit are on or off only.
all is the baseline (the portable config's "*" key, true when unset); set it to false to start from nothing
and name what you want:
use ;
builder.builtin_tools.build; // just read
builder.builtin_tools.build; // bring your own via `tools`
builder
.builtin_tools
.build; // the defaults minus one
builder
.builtin_tools
.build; // the defaults, three of them configured
builder
.builtin_tools
.build; // start empty, add two
BUILTIN_TOOL_NAMES is the full list, and BuiltinToolName parses from a tool name ("web_fetch".parse()). Prefer
the config form for "the defaults minus X"; a list pins every name it contains, so listing web_search on a model
without built-in search fails instead of quietly staying off (opt into the Exa fallback with
.web_search(WebSearchSetting::Exa)). A tool in tools whose name collides with an enabled built-in (or a plugin's
tool) fails create_harness too, so nothing is silently shadowed; drop the built-in first to replace it.
subagent always runs in the background. By default, the model may also select background execution for any other
compatible tool. The harness waits for the work to finish and continues the parent model with its result. Pass
.background_tasks(false) to disable this behaviour, or an SDK BackgroundTasksConfig to control the policy,
concurrency, completion, and timeouts. Set wait_for_completion: Some(false) only when the application will invoke
the agent again after a result is ready.
Delegating work to subagents
The agent can hand a subtask to another agent, exposed to it as a tool. Every call runs in its own fresh conversation and returns only its final answer, so work that would otherwise flood the main context (searching many files, a multi-step change, open-ended exploration) is kept out of the way.
There are two kinds of delegation, and they coexist. The built-in subagent tool is enabled by default (it's
just a name in builtin_tools, like shell or read). The parent model calls it with a self-contained task; the
harness builds a fresh child through create_harness that inherits this agent's configuration (its model, effort,
built-in tools and plugins, skills, interventions, sandbox, and the plugins you passed, so your approval gate
reaches the delegate too) and returns a single final report. Your named consumer tools are forwarded so the
delegate can be granted them, and every MCP server stays with each delegate. The model picks the generalist role, may
write an ad-hoc role prompt, may narrow the tool set (never widen it), and chooses how much of the conversation the
child sees. Delegation depth is bounded (two levels by default, SubagentConfig::max_depth to change it, 0 to
remove the tool), so a delegate can't recurse without limit. Drop it from builtin_tools to turn it off:
use ;
builder
.builtin_tools
.build; // no subagent
The built-in tool is the SDK's subagent tool with the harness's description, presets and choices. For a fully
configured tool (custom roles, model tiers, fixed prompts), build one with make_subagent (re-exported from
strands::vended_tools::subagent) and pass it in tools with subagent dropped from builtin_tools. You supply a
ChildAgentBuilder, an async function that turns a resolved AgentSpec into the child agent (typically by calling
create_harness); this is the seam that makes the child a harness member. Each axis (instructions, tools,
model, context) becomes a parameter, or not, depending on whether it is Fixed, Inherit, Open, or Choice:
use ;
// The defaults minus delegation; web_search stays provider-dependent.
async
async
For focused expertise, pass your own Agents in tools; each becomes a tool the main agent can call, named after
the agent's name. Every call runs the specialist from the state it had when it became a tool, so it's a clean,
focused delegate rather than a shared session. Give each a clear name and description so the model knows when to
reach for it:
use Agent;
use ;
async
Each specialist is a full Agent, so it carries its own model, prompt, and tools. Use Agent::as_tool with
AgentAsToolOptions to rename one or keep its conversation across calls, or build them with create_harness too if
you want them to share the harness's defaults.
Connecting MCP servers
Point mcp_servers at a standard mcpServers config (a JSON file path, or the map inline) and the harness connects
each server, discovers its tools, and adds them to the tool list:
use json;
use JsonObject;
use HarnessAgentOptions;
builder.mcp_servers.build;
Servers are connected inside create_harness, which is why it's async. A server that fails to start contributes no
tools rather than taking the agent down; set "continueOnError": false on a server to make its failure fatal. Each
server's tools are namespaced as <server>_<tool> (characters outside [A-Za-z0-9_-] in the server name become _)
so two servers exposing the same tool don't clash; set a server's "prefix" to choose the namespace, or "prefix": ""
to opt out. An SDK McpServersSource works too, for typed server configs. This needs the mcp feature; without it,
setting mcp_servers fails create_harness.
Reaching the web
Two of the built-ins put the web in reach. web_fetch is on by default: it fetches a URL, reduces it to text, and asks
a small fast model to answer your prompt over the content, returning the answer rather than the raw page so a long
article never floods the conversation. Pages are cached for 15 minutes. The summarizer runs on the small model for
your main provider by default (so credentials line up); override it through the tool's config. The request runs as
curl inside the agent's sandbox, so a sandbox's network rules cover it; WebFetchTransport::Direct fetches from the
harness process instead:
use ;
let web_fetch = builder
.model
.transport
.build;
builder.builtin_tools.build;
web_search is the other one: it lets the agent look things up on the web mid-answer. Where the model provider has
its own search (OpenAI, Anthropic, and GPT-5, GPT-6, and Daybreak models on bedrock-mantle via Bedrock Web Search)
the harness turns that on by default. Other Amazon Bedrock models (bedrock/ and bedrock-mantle/ model strings) get
a web_search tool backed by
Amazon Bedrock AgentCore web search
instead, signed with the same AWS credentials and region resolution as the Bedrock model. With no native search (a
model instance or router, whose provider the harness can't see) web_search is off by default. To enable web search
there, you can opt into Exa with WebSearchSetting::Exa. The model then gets a web_search tool backed by Exa's
hosted search (this needs the mcp feature). It works keyless, but setting EXA_API_KEY in the environment lifts
the rate limit. You can override a provider's native web search by choosing Exa explicitly on any model. If you are
using Bedrock Web Search, you'll need the bedrock-websearch IAM action (in AmazonBedrockFullAccess) to avoid
failing search; AgentCore web search needs bedrock-agentcore:InvokeWebSearch.
[!WARNING] Web search through Exa sends every search query the model writes to Exa (exa.ai), a third-party service. Queries leave your environment and are subject to Exa's privacy policy.
use ;
builder.model.build; // native search on, it's in the defaults
builder.build; // Bedrock: AgentCore web search, also a default
builder
.builtin_tools
.build; // any model: search through Exa (third party)
Caching reused context
caching is on by default. The stable parts of a conversation (system prompt, tool definitions, earlier turns) are
cached where the provider supports it, so you're not billed to reprocess them on every turn. The harness configures
the SDK's automatic cache strategy on every provider a model string can name: Amazon Bedrock, Anthropic, OpenAI, and
Bedrock Mantle. The exceptions are Bedrock models that can't cache (Claude 3 Haiku) and a pre-built model instance,
whose provider the harness can't configure. With the default, those log a warning and run without caching; asking
for caching explicitly (.caching(true)) fails create_harness for a model that can't cache, so a deliberate request
never passes silently (a model instance only warns). Turn off what the harness configures with .caching(false):
use HarnessAgentOptions;
builder.caching.build; // don't configure caching
The harness logs its warnings and notices through tracing, so install a subscriber (for
example tracing_subscriber::fmt::init()) to see them.
Remembering conversations
By default the harness persists every conversation to disk under ./.agent/sessions, saving after each completed
message. It does not auto-resume, though: with no id it mints a fresh one each run, so a new run starts a new session.
To continue a conversation, read the minted id off the returned agent (agent.session_id()) and pass it back in a
SessionConfig, or supply your own stable id up front. Build a fresh agent per request, keyed on the id:
use ;
async
Set SessionConfig::dir to choose where state lives (default ./.agent/sessions); bulky tool results the context
manager moves out of the conversation are kept in the session's folder too. Ids are sanitized to [a-z0-9_-]. The
on-disk layout matches the TypeScript harness, so either one can resume a session the other wrote. For multi-host
setups, pass your own SDK SessionManager as session and it takes over; pass storage with it, or offloaded tool
results are embedded in its snapshots. Turn persistence off with .session(false) for a throwaway run.
Long-term memory
Separate from sessions, the harness builds up long-term memory. It remembers facts that it learns about your
preferences and the project, saved in markdown files under ./.agent/memory and folded back into context before each
user turn. The agent also has a search_memory tool for on-demand recall. Long-term memory works across conversations
and sessions. Fact extraction from your conversation history runs every few turns on the same small model as the
web_fetch summarizer. A subagent delegate shares this memory read-only, so it recalls what you've told the agent
but its subtasks never write back into your store.
memory takes true (the default), a MemoryConfig, a MemoryManager, or false. Set MemoryConfig::dir to
choose where the files live, or turn memory off with .memory(false). To swap the backend while keeping the harness's
behaviour, set MemoryConfig::stores (one or more SDK MemoryStores); the harness manages them under the same
policy, and a subagent delegate still shares them read-only. To replace the policy itself, pass your own
MemoryManager.
Extraction runs in the background between turns, so a short run can end before the latest turns are saved.
Agent::shutdown flushes what's pending; call it at your shutdown boundary:
async
use Arc;
use MemoryStore;
use ;
Teaching it skills
Drop Agent Skills into ./.agent/skills and the harness loads them automatically. Each
skill is a subdirectory with a SKILL.md (YAML frontmatter with name and description, then markdown
instructions); the model sees the metadata up front and loads the full instructions on demand via a skills tool. A
skill can bundle supporting files alongside SKILL.md (scripts, templates, references) that its instructions tell
the agent to run or read:
./.agent/skills/
├── release-notes/
│ └── SKILL.md
└── changelog/
├── SKILL.md
└── scripts/
└── collect_commits.py
Point elsewhere with skills (a directory, an https:// URL of raw SKILL.md content, or a list of them), pass a
configured SDK AgentSkills plugin to take over, or pass .skills(false) to disable. The default location is
best-effort (a missing directory is skipped); explicit sources pass straight through to the SDK, which reads them
through the agent's sandbox and warns on a missing one.
use HarnessAgentOptions;
builder.skills.build;
builder.skills.build;
builder.skills.build; // no skills
Built-in plugins
The harness ships one built-in feature plugin, on by default:
environmentinjects a short context block before each user turn: the platform, current date, working directory, the project'sAGENTS.mdcontents, and links to otherAGENTS.md/README.mdfiles a couple of levels down (links, not contents, so the block stays small). Everything is read through the agent's sandbox, so it works whether the agent runs locally, in Docker, or over SSH.
builtin_plugins selects built-in plugins by name, the same way builtin_tools does; an empty list turns them off.
EnvironmentContext is public with a config, and a plugin you pass in plugins under the same name replaces the
built-in. For a task list the agent keeps through a todo_write tool, pass the SDK's Todos plugin:
use Todos;
use ;
builder.plugins.build; // a todo list
builder.builtin_plugins.build; // no built-in plugins
Tracing
The SDK instruments the agent: every invocation, agent loop cycle, model call, and tool call is a
tracing span with OpenTelemetry gen_ai.* attributes. With the otel feature, the
harness wires up the exporter for you when you turn tracing on with the standard OTEL_TRACES_EXPORTER; there's
nothing to pass in code:
# or "console" for span JSON to stdout, or both
# where your collector is listening
Set headers, protocol, and the rest through the other OTEL_EXPORTER_OTLP_* variables. With OTEL_TRACES_EXPORTER
unset (or none), the harness touches telemetry not at all: no exporter, no cost. Without the otel feature, a set
selector logs a warning and tracing stays off. Setup runs once per process, and a tracer provider the program already
registered through strands::telemetry::setup_tracer is reused.
The spans reach the exporter through a tracing subscriber that carries the SDK's OpenTelemetry layer. When the
program has no global subscriber, the harness installs one with only that layer. A program that installs its own
subscriber owns tracing: the harness leaves it alone and logs a warning, and the program adds the layer itself,
before building agents:
#
Requiring approval for tool calls
By default the agent runs every tool call without asking. Pass interventions to gate them with a preset, a policy,
an SDK handler, or a list of these:
use ;
use HarnessAgentOptions;
builder.interventions.build; // approve every tool call
builder.interventions.build; // an LLM risk classifier flags risky calls for approval
// a natural-language policy becomes the classifier's rubric
builder.interventions.build;
// a Cedar policy file (the `cedar` feature)
builder.interventions.build;
// full control: your own handler (terminal or custom approval, trust, a Cedar principal resolver)
let ask = builder.ask.enable_trust.build;
builder.interventions.build;
// layer a policy engine under a human gate
builder.interventions.build;
Presets pause the agent through the SDK's interrupts, so a service can collect approval asynchronously: the
invocation stops with StopReason::Interrupt, and invoking the agent again with the answers resumes it:
use ;
use ;
async
A subagent delegate inherits the policy, so it can't be used to bypass it, and the tool calls
programmatic_tool_caller makes from inside its sandbox run through the agent's full tool pipeline (hooks,
interventions, middleware), so they are gated too (a denied call raises in the code; one that needs interactive
approval is refused). This is sugar over the SDK's HumanInTheLoop and CedarAuthorization; pass those directly for
anything the presets don't cover. Inline Cedar policy text isn't detected (it reads like prose), so pass a
CedarAuthorization handler for that.
It's just a Strands Agent
The return value is a regular strands::Agent, so the full SDK is available to you. HarnessAgentOptions also
carries the SDK AgentConfig fields the harness doesn't own (name, description, aux_model, system_prompt,
messages, app_state, conversation_manager, retry_strategy, structured_output_schema, sandbox, storage,
session_manager, memory_manager, trace attributes, and more), forwarded verbatim, and your explicit value always
wins over the harness default. That's the seam for SDK-native features: pass your own plugins, interventions, or
any other field alongside the harness's, and they compose.
use BeforeToolCallEvent;
use ;
use ;
async
The vended prompt
The system prompt is also available on its own, in case you want to build on it directly (for example, a serving layer that injects a timestamp or request context each turn):
use build_system_prompt;
HARNESS_CONTRACT is the contract on its own, the first part of every harness prompt.
Versioning
Strands harness is 0.x, in developer preview. In the Rust crate, a minor release (0.1 to 0.2) may break the API and a
patch release does not, though patch releases still carry new features, including new built-in tools. Cargo's default
requirement (strands-harness = "0.1") stays on one minor, so it picks up fixes and features without breaking
changes. See Versioning and Support for what the
harness counts as breaking.
Contributing ❤️
Contributions are welcome: bug reports, features, docs, or a well-scoped PR. See the Contributing Guide for development setup, how we work, and the pull-request flow. Please also review our Code of Conduct.
Security
See SECURITY.md for how to report a vulnerability. Please do not open a public issue for security concerns.
License
Apache-2.0. See LICENSE.