Skip to content

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

refactor(agent): update subagent tool identification logic

Steven Enamakel1f843f23b477
diff --git a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
index bedf8df677..45519d2d6f 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
@@ -43,17 +43,17 @@ pub(crate) fn subagent_prompt_protocol(
/// The shared static names stay aligned with TinyAgents; registry lookup is
/// needed only for host-defined, unprefixed `delegate_name` overrides.
pub(super) fn is_subagent_spawn_tool(name: &str) -> bool {
+ if crate::agent::tinyagents::turn_policy::is_subagent_spawn_or_delegate_tool(name) {
+ return true;
+ }
let registry = crate::agent_registry::host_definition::AgentDefinitionRegistry::current();
- is_subagent_spawn_tool_with_registry(name, registry.as_deref())
+ is_registered_delegate_alias(name, registry.as_deref())
}
-fn is_subagent_spawn_tool_with_registry(
+fn is_registered_delegate_alias(
name: &str,
registry: Option<&crate::agent_registry::host_definition::AgentDefinitionRegistry>,
) -> bool {
- if crate::agent::tinyagents::turn_policy::is_subagent_spawn_or_delegate_tool(name) {
- return true;
- }
// Synthesised delegation tools are named by the target agent's
// `delegate_name` override, which mostly does NOT carry the `delegate_`
// prefix (`manage_tasks`, `create_image`, `setup_skills`,
diff --git a/crates/openhuman-core/src/agent/subagent_host/tool_prep_tests.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep_tests.rs
index 8219cc6f8a..b5a9bc056d 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep_tests.rs
@@ -61,7 +61,9 @@ fn unprefixed_delegate_name_overrides_are_treated_as_spawn_tools() {
"plan",
"manage_tasks",
"create_image",
+ #[cfg(feature = "flows")]
"build_workflow",
+ #[cfg(feature = "flows")]
"discover_workflows",
// `make_presentation` is `presentation_agent`'s `delegate_name`; the agent —
// and therefore this delegate tool — is compiled out with the
@@ -70,7 +72,7 @@ fn unprefixed_delegate_name_overrides_are_treated_as_spawn_tools() {
"make_presentation",
] {
assert!(
- super::is_subagent_spawn_tool_with_registry(delegate, Some(&registry)),
+ super::is_registered_delegate_alias(delegate, Some(&registry)),
"`{delegate}` is a synthesised delegation tool and must be \
stripped from sub-agent tool surfaces"
);
@@ -78,7 +80,7 @@ fn unprefixed_delegate_name_overrides_are_treated_as_spawn_tools() {
// Ordinary worker tools stay visible.
for plain in ["shell", "file_read", "web_fetch", "todo"] {
assert!(
- !super::is_subagent_spawn_tool_with_registry(plain, Some(&registry)),
+ !super::is_registered_delegate_alias(plain, Some(&registry)),
"`{plain}` must not be classified as a spawn tool"
);
}
diff --git a/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs b/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs
index 1e3b18303b..2e4a2c4231 100644
--- a/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_save_and_edit_tests.rs
@@ -377,7 +377,7 @@ async fn save_workflow_accepts_correctly_schemad_graph() {
"nodes": [
{ "id": "t", "kind": "trigger", "name": "Manual" },
{ "id": "summarize", "kind": "agent", "name": "Summarize",
- "config": { "agent_ref": "planner", "prompt": "summarize",
+ "config": { "agent_ref": "workflow_builder", "prompt": "summarize",
"output_parser": { "schema": { "type": "object",
"required": ["channel"],
"properties": { "channel": { "type": "string" } } } } } },
diff --git a/crates/openhuman-embed/src/agent/build_tests.rs b/crates/openhuman-embed/src/agent/build_tests.rs
index 76bace8723..6e2eeeb19a 100644
--- a/crates/openhuman-embed/src/agent/build_tests.rs
+++ b/crates/openhuman-embed/src/agent/build_tests.rs
@@ -84,9 +84,9 @@ fn sub_agent_ids_are_checked_like_agent_ids() {
&catalogue,
"lead",
&mut definition,
- vec![("planner".to_string(), spec())],
+ vec![("vision_agent".to_string(), spec())],
);
- assert!(matches!(reserved, Err(AgentError::ReservedId(id)) if id == "planner"));
+ assert!(matches!(reserved, Err(AgentError::ReservedId(id)) if id == "vision_agent"));
let invalid = own_catalogue(
&catalogue,
diff --git a/crates/openhuman-embed/src/agent/definition_tests.rs b/crates/openhuman-embed/src/agent/definition_tests.rs
index 737c969664..dc9c01b641 100644
--- a/crates/openhuman-embed/src/agent/definition_tests.rs
+++ b/crates/openhuman-embed/src/agent/definition_tests.rs
@@ -132,11 +132,11 @@ fn template_overrides_are_independent_and_keep_restrictions() {
#[test]
fn base_can_be_named_or_custom_and_unknown_names_are_typed() {
let original = AgentDefinitionRegistry::builtins_only()
- .get("planner")
+ .get("vision_agent")
.unwrap()
.clone();
- let named = AgentDefinitionSpec::from_base("planner")
- .into_core("my-planner")
+ let named = AgentDefinitionSpec::from_base("vision_agent")
+ .into_core("my-vision-agent")
.unwrap();
assert_eq!(named.agent_tier, original.agent_tier);
let custom = AgentDefinitionSpec::from_base(original.clone())
diff --git a/crates/openhuman-embed/tests/isolation_subagents.rs b/crates/openhuman-embed/tests/isolation_subagents.rs
index bbce9ea0f1..ebc030ba09 100644
--- a/crates/openhuman-embed/tests/isolation_subagents.rs
+++ b/crates/openhuman-embed/tests/isolation_subagents.rs
@@ -32,7 +32,7 @@ fn sub_agents_stay_with_the_agent_that_declared_them() {
.expect("runtime builds");
// ── reserved ids ──
- for reserved in ["orchestrator", "planner", "summarizer"] {
+ for reserved in ["orchestrator", "vision_agent", "summarizer"] {
let refused = runtime.agent(AgentSpec::new(reserved));
assert!(
matches!(refused, Err(AgentError::ReservedId(ref id)) if id == reserved),
@@ -40,7 +40,7 @@ fn sub_agents_stay_with_the_agent_that_declared_them() {
);
}
let refused = runtime.agent(
- AgentSpec::new("lead-x").subagents([("critic", AgentDefinitionSpec::new())]),
+ AgentSpec::new("lead-x").subagents([("vision_agent", AgentDefinitionSpec::new())]),
);
assert!(matches!(refused, Err(AgentError::ReservedId(_))));