Skip to content

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

test: assert spawn_async_subagent is scoped per session

Steven Enamakel54bbc1187558
diff --git a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs
index 1130c77396..83b725941c 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/builder_tests_tool_spec_views_tests.rs
@@ -59,6 +59,7 @@ fn the_three_spec_views_share_their_leaf_schemas() {
// exclusion-only test.
let use_skill = crate::tools::toolpacks::USE_SKILL;
let mut saw_scoped_use_skill = false;
+ let mut saw_scoped_spawn = false;
for spec in visible.iter() {
let shared = all
@@ -73,6 +74,29 @@ fn the_three_spec_views_share_their_leaf_schemas() {
saw_scoped_use_skill = true;
continue;
}
+ // Same exception, same reason: the spawn enum is narrowed to this
+ // agent's `[subagents]` allowlist, so it is a per-session copy.
+ if spec.name == "spawn_async_subagent" {
+ assert!(
+ !shared,
+ "`spawn_async_subagent` must be scoped into its own allocation"
+ );
+ let ids = spec
+ .parameters
+ .pointer("/properties/agent_id/enum")
+ .and_then(|v| v.as_array())
+ .expect("agent_id enum");
+ assert!(
+ ids.iter().all(|id| id.as_str() != Some("orchestrator")),
+ "the orchestrator cannot spawn itself: {ids:?}"
+ );
+ assert!(
+ ids.iter().any(|id| id.as_str() == Some("researcher")),
+ "an allowlisted id survives: {ids:?}"
+ );
+ saw_scoped_spawn = true;
+ continue;
+ }
assert!(
shared,
"visible spec `{}` must point at the full view's allocation, not a deep copy",
@@ -85,6 +109,10 @@ fn the_three_spec_views_share_their_leaf_schemas() {
"the orchestrator advertises `{use_skill}`, so the scoped-copy exception above \
must actually have been exercised rather than vacuously skipped"
);
+ assert!(
+ saw_scoped_spawn,
+ "the orchestrator advertises `spawn_async_subagent`, so its enum must have been narrowed"
+ );
}
/// Failure path: a duplicate name must not smuggle a *different* allocation