Skip to content

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

test(orchestration): align subagent policy tests with spawn_subagent routing

Steven Enamakel5d28e77d8083
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_async_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_async_tests.rs
index 9b4d6b7e76..85ddb23173 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_async_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_async_tests.rs
@@ -370,7 +370,7 @@ async fn headless_spawn_is_async_and_reports_its_result_to_the_run_log() {
assert_eq!(finished.output.as_deref(), Some("done"));
}
-fn headless_core_backed_parent(
+pub(super) fn headless_core_backed_parent(
workspace: &Path,
mut parent: ParentExecutionContext,
) -> (
@@ -406,7 +406,7 @@ fn headless_core_backed_parent(
)
}
-fn parent_context(workspace_dir: &Path) -> ParentExecutionContext {
+pub(super) fn parent_context(workspace_dir: &Path) -> ParentExecutionContext {
ParentExecutionContext {
workspace_descriptor: None,
agent_definition_id: "orchestrator".into(),
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs
index 23948e1295..146f23c0cd 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tests.rs
@@ -78,13 +78,10 @@ async fn unknown_agent_id_lists_available() {
// Drive the real lookup under a detached parent and its scoped registry;
// the ordinary Tool::execute path refuses earlier because it has no turn.
let workspace = tempfile::tempdir().expect("workspace");
- let parent = super::tests::parent_context(workspace.path());
- let (live, core) = super::tests::core_backed_live_parent(
- workspace.path(),
- parent,
- "unknown-agent-session",
- "unknown-agent-thread",
- );
+ let mut parent = super::tests::parent_context(workspace.path());
+ parent.session_id = "unknown-agent-session".into();
+ let (live, core) =
+ super::tests::headless_core_backed_parent(workspace.path(), parent);
let result = crate::core::runtime::CoreContext::scope(core, async {
let detached = crate::agent::subagent_host::detached_subagent_parent(
&live,
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs
index 47a413fa85..1956dec952 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_tool_policy_tests.rs
@@ -29,7 +29,11 @@ impl tinytools::Tool for RoutingFakeTool {
"fake"
}
fn parameters_schema(&self) -> serde_json::Value {
- json!({ "type": "object" })
+ if self.0 == "spawn_subagent" {
+ json!({"type":"object","properties":{"agent_id":{"type":"string","enum":["workflow_builder","flow_discovery"]}}})
+ } else {
+ json!({ "type": "object" })
+ }
}
async fn execute(&self, _args: serde_json::Value) -> anyhow::Result<ToolResult> {
Ok(ToolResult::success("ok"))
@@ -52,8 +56,7 @@ fn allow(name: &str) -> (String, ToolPolicyDecision) {
}
/// A non-owner session: it holds the whole `workflows` pack in its registry and
-/// a `build_workflow` route, but may only call that route and the pack
-/// tool — exactly the orchestrator's shape. Anything not named here is denied,
+/// the canonical `spawn_subagent` route to its owners. Anything not named here is denied,
/// because `decision_for` defaults to `Deny`.
fn non_owner_middleware() -> ToolPolicyMiddleware {
non_owner_middleware_at(PermissionLevel::Dangerous)
@@ -64,7 +67,7 @@ fn non_owner_middleware() -> ToolPolicyMiddleware {
/// for an inner name it cannot resolve (#6302).
fn non_owner_middleware_at(allowed: PermissionLevel) -> ToolPolicyMiddleware {
let mut tools: Vec<Box<dyn tinytools::Tool>> = vec![
- Box::new(RoutingFakeTool("build_workflow")),
+ Box::new(RoutingFakeTool("spawn_subagent")),
Box::new(RoutingFakeTool("propose_workflow")),
];
append_pack_tools(&mut tools);
@@ -80,10 +83,10 @@ fn non_owner_middleware_at(allowed: PermissionLevel) -> ToolPolicyMiddleware {
allowed_permission: allowed,
},
capabilities: vec![ToolCapability {
- name: "build_workflow".to_string(),
+ name: "spawn_subagent".to_string(),
required_permission: PermissionLevel::ReadOnly,
}],
- allowed_tool_names: ["build_workflow", USE_SKILL]
+ allowed_tool_names: ["spawn_subagent", USE_SKILL]
.into_iter()
.map(str::to_string)
.collect(),
@@ -92,7 +95,7 @@ fn non_owner_middleware_at(allowed: PermissionLevel) -> ToolPolicyMiddleware {
.map(str::to_string)
.collect(),
hidden_tool_names: Default::default(),
- decisions: [allow("build_workflow"), allow(USE_SKILL)]
+ decisions: [allow("spawn_subagent"), allow(USE_SKILL)]
.into_iter()
.collect(),
};