The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(agent): drive the team spawn-depth cap through run_subagent
M3gA-Mindd8b5a61b1342
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rsindex 8949bad5e2..995e734133 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs@@ -79,29 +79,78 @@ async fn runner_rejects_spawn_beyond_max_depth() {);}-#[test]-fn a_team_depth_cap_below_the_product_limit_is_enforced() {- // The runner's depth gate is `checked_child_depth(parent, budget::depth(ctx))`.- // A team that caps its tree at one level admits a child and refuses a- // grandchild, and a cap above the product limit cannot widen it.- use crate::agent::tinyagents::budget::{depth, MAX_SPAWN_DEPTH};- use tinyagents_harness::context::RunConfig;-- let mut team = crate::agent::tinyagents::host::OpenHumanRunContext::new();- team.max_spawn_depth = Some(1);- assert_eq!(depth(&team), 1);- assert_eq!(- RunConfig::checked_child_depth(0, depth(&team)).ok(),- Some(1)+#[tokio::test]+async fn a_team_depth_cap_below_the_product_limit_is_enforced() {+ // Driven through `run_subagent`, so the runner's own gate must honour the+ // team's cap (not the budget helper alone): a team capped at one level runs+ // a child and refuses a grandchild before any provider dispatch, and a cap+ // above the product limit cannot widen it.+ use crate::agent::tinyagents::budget::MAX_SPAWN_DEPTH;+ let def = make_def_named_tools(&[]);++ let provider = ScriptedProvider::new(vec![text_response("ok")]);+ let mut options = with_parent(+ make_parent(provider.clone(), vec![]),+ SubagentRunOptions::default(),);+ options.run_context.max_spawn_depth = Some(1);+ let child = run_subagent(&def, "x", options).await;assert!(- RunConfig::checked_child_depth(1, depth(&team)).is_err(),- "a grandchild of a one-level team is refused"+ !matches!(child, Err(SubagentRunError::SpawnDepthExceeded { .. })),+ "a one-level team must admit its child: {child:?}"+ );+ assert!(+ !provider.captured.lock().is_empty(),+ "the admitted child reaches the provider: {child:?}");- let mut wide = crate::agent::tinyagents::host::OpenHumanRunContext::new();- wide.max_spawn_depth = Some(MAX_SPAWN_DEPTH + 3);- assert_eq!(depth(&wide), MAX_SPAWN_DEPTH);+ let provider = ScriptedProvider::new(vec![text_response("should not be called")]);+ let mut options = with_parent(+ make_parent(provider.clone(), vec![]),+ SubagentRunOptions::default(),+ );+ options.run_context.max_spawn_depth = Some(1);+ let grandchild = with_run_depth(+ RunDepth {+ depth: 1,+ max_depth: MAX_SPAWN_DEPTH,+ },+ async { run_subagent(&def, "x", options).await },+ )+ .await;+ assert!(+ matches!(+ grandchild,+ Err(SubagentRunError::SpawnDepthExceeded {+ attempted_depth: 2,+ max_depth: 1+ })+ ),+ "a grandchild of a one-level team is refused: {grandchild:?}"+ );+ assert!(+ provider.captured.lock().is_empty(),+ "the refused grandchild never reaches the provider"+ );++ let provider = ScriptedProvider::new(vec![text_response("should not be called")]);+ let mut options = with_parent(+ make_parent(provider.clone(), vec![]),+ SubagentRunOptions::default(),+ );+ options.run_context.max_spawn_depth = Some(MAX_SPAWN_DEPTH + 3);+ let beyond = with_run_depth(+ RunDepth {+ depth: MAX_SPAWN_DEPTH,+ max_depth: MAX_SPAWN_DEPTH,+ },+ async { run_subagent(&def, "x", options).await },+ )+ .await;+ let Err(SubagentRunError::SpawnDepthExceeded { max_depth, .. }) = &beyond else {+ panic!("a cap above the product limit cannot widen it: {beyond:?}");+ };+ assert_eq!(*max_depth, MAX_SPAWN_DEPTH);}#[tokio::test]