Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(subagent_host): split ops tests into focused modules

Steven Enamakela43dfe068711
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests.rs
index ee882b4ab6..6d202ee738 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests.rs
@@ -72,7 +72,6 @@ fn stub(name: &'static str) -> Box<dyn Tool> {
// ── End-to-end runner tests with mock provider ────────────────────────
-use crate::agent::harness::fork_context::with_parent_context;
use parking_lot::Mutex;
use std::sync::Arc;
use tinyagents_harness::run_queue::{QueueLane, RunQueue};
@@ -248,6 +247,13 @@ fn tool_response(name: &str, args: &str) -> ModelResponse {
/// Build a minimal `ParentExecutionContext` suitable for runner tests.
/// Uses a no-op memory backend so we don't have to spin up a real one.
+/// `options` with `parent` bound as the run's explicit parent execution
+/// context, the way a spawning tool or orchestration surface supplies it.
+fn with_parent(parent: ParentExecutionContext, mut options: SubagentRunOptions) -> SubagentRunOptions {
+ options.run_context.parent = Some(parent);
+ options
+}
+
fn make_parent(
provider: Arc<dyn ChatModel<()>>,
tools: Vec<Box<dyn Tool>>,
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.rs
index 3f3f2926bf..95911af3c4 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
@@ -8,13 +8,13 @@ async fn runner_rejects_spawn_beyond_max_depth() {
let parent = make_parent(provider.clone(), vec![]);
let def = make_def_named_tools(&[]);
- let result = with_parent_context(parent, async {
+ let result = (async {
with_run_depth(
RunDepth {
depth: MAX_SPAWN_DEPTH,
max_depth: MAX_SPAWN_DEPTH,
},
- async { run_subagent(&def, "x", SubagentRunOptions::default()).await },
+ async { run_subagent(&def, "x", with_parent(parent.clone(), SubagentRunOptions::default())).await },
)
.await
})
@@ -48,14 +48,14 @@ async fn typed_mode_model_override_pins_exact_model_for_spawn() {
let mut def = make_def_named_tools(&[]);
def.model = ModelSpec::Inherit;
- let _ = with_parent_context(parent, async {
+ let _ = (async {
run_subagent(
&def,
"use the pinned model",
- SubagentRunOptions {
+ with_parent(parent.clone(), SubagentRunOptions {
model_override: Some("deepseek/deepseek-r2".into()),
..Default::default()
- },
+ }),
)
.await
})
@@ -89,8 +89,8 @@ async fn typed_mode_emits_child_progress_events_when_sink_attached() {
parent.on_progress = Some(tx);
let def = make_def_named_tools(&["file_read"]);
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "read x", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "read x", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("runner should succeed");
@@ -164,8 +164,8 @@ async fn typed_mode_forwards_child_text_and_thinking_deltas() {
parent.on_progress = Some(tx);
let def = make_def_named_tools(&[]);
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "answer me", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "answer me", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("runner should succeed");
@@ -237,8 +237,8 @@ async fn typed_mode_progress_emission_is_a_noop_without_sink() {
let parent = make_parent(provider, vec![]);
assert!(parent.on_progress.is_none());
let def = make_def_named_tools(&[]);
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "x", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "x", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("runner should succeed");
@@ -583,8 +583,8 @@ fn nested_subagent_dispatch_runs_on_a_constrained_worker_stack() {
);
let outer_def = make_def_named_tools(&["delegate_inner"]);
- with_parent_context(parent, async {
- run_subagent(&outer_def, "outer go", SubagentRunOptions::default()).await
+ (async {
+ run_subagent(&outer_def, "outer go", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
});
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs
index 2614b02570..015125988f 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_slug_filter_typed_mode_tests.rs
@@ -98,11 +98,11 @@ async fn typed_mode_injects_current_date_and_time_into_user_message() {
let parent = make_parent(provider.clone(), vec![stub("file_read")]);
let def = make_def_named_tools(&[]);
- let _ = with_parent_context(parent, async {
+ let _ = (async {
run_subagent(
&def,
"the actual task prompt",
- SubagentRunOptions::default(),
+ with_parent(parent.clone(), SubagentRunOptions::default()),
)
.await
})
@@ -128,11 +128,11 @@ async fn typed_mode_system_prompt_includes_subagent_role_contract() {
let parent = make_parent(provider.clone(), vec![stub("file_read")]);
let def = make_def_named_tools(&[]);
- let _ = with_parent_context(parent, async {
+ let _ = (async {
run_subagent(
&def,
"the actual task prompt",
- SubagentRunOptions::default(),
+ with_parent(parent.clone(), SubagentRunOptions::default()),
)
.await
})
@@ -160,11 +160,11 @@ async fn typed_mode_returns_text_through_runner() {
let parent = make_parent(provider.clone(), vec![stub("file_read")]);
let def = make_def_named_tools(&[]);
- let outcome = with_parent_context(parent, async {
+ let outcome = (async {
run_subagent(
&def,
"summarise X",
- SubagentRunOptions {
+ with_parent(parent.clone(), SubagentRunOptions {
workspace_descriptor: None,
skill_filter_override: None,
context: None,
@@ -177,7 +177,7 @@ async fn typed_mode_returns_text_through_runner() {
checkpoint_dir: None,
worktree_action_dir: None,
run_queue: None,
- },
+ }),
)
.await
})
@@ -212,8 +212,8 @@ async fn capped_no_progress_subagent_returns_incomplete_status() {
let mut def = make_def_named_tools(&["file_read"]);
def.max_iterations = 2;
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "read the file", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "read the file", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("a cap halt is still Ok (not Err)");
@@ -261,15 +261,15 @@ async fn run_queue_steer_lands_in_subagent_history() {
)
.await;
- let outcome = with_parent_context(parent, async {
+ let outcome = (async {
run_subagent(
&def,
"investigate the bug",
- SubagentRunOptions {
+ with_parent(parent.clone(), SubagentRunOptions {
task_id: Some("t-steer".into()),
run_queue: Some(run_queue),
..Default::default()
- },
+ }),
)
.await
})
@@ -303,11 +303,11 @@ async fn typed_mode_no_memory_context_in_user_message() {
let parent = make_parent(provider.clone(), vec![stub("file_read")]);
let def = make_def_named_tools(&[]);
- let _ = with_parent_context(parent, async {
+ let _ = (async {
run_subagent(
&def,
"the actual task prompt",
- SubagentRunOptions::default(),
+ with_parent(parent.clone(), SubagentRunOptions::default()),
)
.await
})
@@ -339,11 +339,11 @@ async fn typed_mode_includes_memory_context_when_definition_allows_it() {
let mut def = make_def_named_tools(&[]);
def.extensions.omit_memory_context = false;
- let _ = with_parent_context(parent, async {
+ let _ = (async {
run_subagent(
&def,
"the actual task prompt",
- SubagentRunOptions::default(),
+ with_parent(parent.clone(), SubagentRunOptions::default()),
)
.await
})
@@ -379,11 +379,11 @@ async fn typed_mode_filters_tools_by_skill_filter() {
let mut def = make_def_named_tools(&[]);
def.tools = ToolScope::Wildcard;
- let _ = with_parent_context(parent, async {
+ let _ = (async {
run_subagent(
&def,
"lookup",
- SubagentRunOptions {
+ with_parent(parent.clone(), SubagentRunOptions {
workspace_descriptor: None,
skill_filter_override: Some("notion".into()),
context: None,
@@ -396,7 +396,7 @@ async fn typed_mode_filters_tools_by_skill_filter() {
checkpoint_dir: None,
worktree_action_dir: None,
run_queue: None,
- },
+ }),
)
.await
})
@@ -436,8 +436,8 @@ async fn typed_mode_executes_one_tool_then_returns() {
// Allow the runner to call file_read.
let def = make_def_named_tools(&["file_read"]);
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "read x", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "read x", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("runner should succeed");
@@ -472,8 +472,8 @@ async fn typed_mode_blocks_unallowed_tool_calls() {
// Definition only allows file_read.
let def = make_def_named_tools(&["file_read"]);
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "do thing", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "do thing", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("runner should succeed");
@@ -528,8 +528,8 @@ async fn subagent_emits_checkpoint_at_iteration_cap_instead_of_erroring() {
let mut def = make_def_named_tools(&["file_read"]);
def.max_iterations = 2;
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "keep reading forever", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "keep reading forever", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("hitting the iteration cap should return a checkpoint, not error");
@@ -555,8 +555,8 @@ async fn subagent_checkpoint_falls_back_to_deterministic_when_summary_empty() {
let mut def = make_def_named_tools(&["file_read"]);
def.max_iterations = 2;
- let outcome = with_parent_context(parent, async {
- run_subagent(&def, "keep reading forever", SubagentRunOptions::default()).await
+ let outcome = (async {
+ run_subagent(&def, "keep reading forever", with_parent(parent.clone(), SubagentRunOptions::default())).await
})
.await
.expect("empty summary should fall back, not error");
@@ -579,13 +579,13 @@ async fn runner_allows_spawn_at_max_depth() {
let parent = make_parent(provider.clone(), vec![]);
let def = make_def_named_tools(&[]);
- let outcome = with_parent_context(parent, async {
+ let outcome = (async {
with_run_depth(
RunDepth {
depth: MAX_SPAWN_DEPTH - 1,
max_depth: MAX_SPAWN_DEPTH,
},
- async { run_subagent(&def, "x", SubagentRunOptions::default()).await },
+ async { run_subagent(&def, "x", with_parent(parent.clone(), SubagentRunOptions::default())).await },
)
.await
})