Skip to content

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

fix(session_host): gate delegation tools on the same rule at turn time

Steven Enamakel1975f0c725e4
diff --git a/crates/openhuman-core/src/agent/session_host/builder/mod.rs b/crates/openhuman-core/src/agent/session_host/builder/mod.rs
index 9e7712013b..74da5d845f 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/mod.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/mod.rs
@@ -258,7 +258,7 @@ pub(super) fn summarizes_tool_output(agent_id: &str, config: &crate::config::Con
crate::inference::tokenjuice::summarizes_tool_output(agent_id, config)
}
-pub(super) fn should_synthesize_delegation_tools(def: &AgentDefinition) -> bool {
+pub(crate) fn should_synthesize_delegation_tools(def: &AgentDefinition) -> bool {
match &def.tools {
ToolScope::Wildcard => !def.subagents.is_empty(),
ToolScope::Named(names) => names.iter().any(|name| {
diff --git a/crates/openhuman-core/src/agent/session_host/turn/tools.rs b/crates/openhuman-core/src/agent/session_host/turn/tools.rs
index 5e3a0948b0..cf2679a70b 100644
--- a/crates/openhuman-core/src/agent/session_host/turn/tools.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn/tools.rs
@@ -116,7 +116,12 @@ impl OpenHumanSessionHost {
);
return;
};
- if def.subagents.is_empty() {
+ // The same rule as at build time: a named scope delegates only when it
+ // names a spawn tool, so the definition's roster never widens an
+ // explicit allowlist on a later turn.
+ if def.subagents.is_empty()
+ || !super::super::builder::should_synthesize_delegation_tools(&def)
+ {
return;
}