Skip to main content

harness_agent_options_from_config

Function harness_agent_options_from_config 

Source
pub fn harness_agent_options_from_config(
    config: &HarnessAgentConfig,
    base_dir: Option<&Path>,
) -> Result<HarnessAgentOptions>
Expand description

Maps a portable config onto HarnessAgentOptions.

Directory options (session.dir, memory.dir, local skills, .cedar interventions, MCP cwd) resolve against base_dir (the project root; the current directory when None), ~ against the home directory. A file-backed mcpServers is read here and ${VAR} or ${env:VAR} placeholders are expanded. Values equal to the harness defaults are left unset so the factory’s own defaults apply.

use strands_harness::{DEFAULT_HARNESS_AGENT_CONFIG, harness_agent_options_from_config};

let options = harness_agent_options_from_config(&DEFAULT_HARNESS_AGENT_CONFIG, None)?;
assert_eq!(options.name.as_deref(), Some("Strands harness"));
assert!(options.builtin_tools.is_none());

§Errors

The config fails validation; it holds a module reference (module references are not supported in Rust yet, plus (language "typescript") when the reference names one); the MCP file cannot be read; or an MCP placeholder names an unset variable.