Skip to main content

create_harness

Function create_harness 

Source
pub async fn create_harness(options: HarnessAgentOptions) -> Result<Agent>
Expand description

Builds a preconfigured Strands agent with the harness defaults.

Every default is overridable through HarnessAgentOptions, and the result is a plain Agent that can be changed further. Resolution is async because MCP servers are connected here.

use strands_harness::{HarnessAgentOptions, create_harness};

let mut agent = create_harness(
    HarnessAgentOptions::builder()
        .model("anthropic/claude-opus-5")
        .interventions("ask")
        .build(),
)
.await?;
let result = agent.invoke("Fix the failing test in src/lib.rs").await?;
println!("{result}");
agent.shutdown().await?;

§Errors

An invalid option (an unknown model provider, an unsupported effort level, a tool name registered twice, an empty session id, …), a provider whose cargo feature is disabled, an MCP config that cannot be loaded, or an agent the SDK rejects.