The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(agent): hand sub-agents the durable registry's own specs
Shanu1080bfc3afb0
diff --git a/src/openhuman/agent/harness/fork_context.rs b/src/openhuman/agent/harness/fork_context.rsindex 1b7e9d1d84..c0ce14e190 100644--- a/src/openhuman/agent/harness/fork_context.rs+++ b/src/openhuman/agent/harness/fork_context.rs@@ -49,13 +49,11 @@ pub struct ParentExecutionContext {/// per-archetype before handing it to the sub-agent's tool loop.pub all_tools: Arc<Vec<Box<dyn Tool>>>,- /// Pre-serialised tool specs. Captured at turn-start so sub-agents can- /// pass byte-identical schemas to the provider for prefix-cache reuse.- ///- /// `all_tool_specs[i]` describes `all_tools[i]` for every durable index;- /// the parent's synthesised delegation specs follow at the tail with no- /// instance here, since a sub-agent is never handed a `delegate_*` tool- /// (#4452). Index into this only with indices taken from `all_tools`.+ /// Pre-serialised tool specs matching `all_tools` index for index.+ /// Captured at turn-start so sub-agents can pass byte-identical schemas to+ /// the provider for prefix-cache reuse. The parent's synthesised+ /// delegation specs are deliberately absent: a sub-agent is never handed a+ /// `delegate_*` tool (#4452), so there is no instance here for one.pub all_tool_specs: Arc<Vec<ToolSpec>>,/// Names of the tools the parent actually advertises and will execute thisdiff --git a/src/openhuman/agent/harness/session/builder/builder_tests_part_01_tests.rs b/src/openhuman/agent/harness/session/builder/builder_tests_part_01_tests.rsindex da19eea8ad..9d534e9c87 100644--- a/src/openhuman/agent/harness/session/builder/builder_tests_part_01_tests.rs+++ b/src/openhuman/agent/harness/session/builder/builder_tests_part_01_tests.rs@@ -695,4 +695,15 @@ fn from_config_keeps_build_time_delegation_tools_out_of_the_durable_registry() {agent.synthesized_tool_names, expected_mask,"the refresh mask must be seeded with exactly the synthesised names");+ // What a sub-agent is handed: the durable registry and its specs, index+ // for index, with no synthesised delegate among them.+ let durable_specs = agent.durable_tool_specs_arc();+ assert_eq!(durable_specs.len(), agent.tools().len());+ for (tool, spec) in agent.tools().iter().zip(durable_specs.iter()) {+ assert_eq!(+ tool.name(),+ spec.name,+ "durable specs must track the registry index for index"+ );+ }}diff --git a/src/openhuman/agent/harness/session/builder/setters.rs b/src/openhuman/agent/harness/session/builder/setters.rsindex 8d7e7ba5d9..b2754cd8bc 100644--- a/src/openhuman/agent/harness/session/builder/setters.rs+++ b/src/openhuman/agent/harness/session/builder/setters.rs@@ -479,12 +479,12 @@ impl AgentBuilder {.iter().map(|tool| tool.name().to_string()).collect();- // Durable specs first, synthesised after: the order every reader of- // the two sets enumerates them in (`Agent::all_tool_refs`, dispatch).- let tool_specs: Vec<ToolSpec> = tools+ // Durable specs first, synthesised after — every reader's order.+ let durable_tool_specs: Vec<ToolSpec> = tools.iter().map(|tool| tool.spec()).collect();+ let tool_specs: Vec<ToolSpec> = durable_tool_specs.iter()- .chain(synthesized_tools.iter())- .map(|tool| tool.spec())+ .cloned()+ .chain(synthesized_tools.iter().map(|tool| tool.spec())).collect();let mut visible_names = self.visible_tool_names.unwrap_or_default();@@ -642,6 +642,7 @@ impl AgentBuilder {tools,synthesized_tools: Arc::new(synthesized_tools),tool_specs: Arc::new(tool_specs),+ durable_tool_specs: Arc::new(durable_tool_specs),visible_tool_specs: Arc::new(visible_tool_specs),visible_tool_names: visible_names,subagent_tool_ceiling_names,diff --git a/src/openhuman/agent/harness/session/runtime_impl_01_part_01.rs b/src/openhuman/agent/harness/session/runtime_impl_01_part_01.rsindex 55b829f2e3..6bb4a1661c 100644--- a/src/openhuman/agent/harness/session/runtime_impl_01_part_01.rs+++ b/src/openhuman/agent/harness/session/runtime_impl_01_part_01.rs@@ -92,11 +92,18 @@ impl Agent {self.tool_specs.as_slice()}- /// Clone the agent's tool specs `Arc` for sharing with sub-agents.+ /// Clone the agent's full tool specs `Arc` (durable and synthesised).pub fn tool_specs_arc(&self) -> Arc<Vec<ToolSpec>> {Arc::clone(&self.tool_specs)}+ /// Clone the specs of the durable registry alone, index for index with+ /// [`Self::tools_arc`] — the pair a sub-agent is handed, so a child never+ /// sees a spec for a synthesised delegate it holds no instance for.+ pub fn durable_tool_specs_arc(&self) -> Arc<Vec<ToolSpec>> {+ Arc::clone(&self.durable_tool_specs)+ }+#[cfg(test)]pub(crate) fn visible_tool_names_for_test(&self) -> &std::collections::HashSet<String> {&self.visible_tool_namesdiff --git a/src/openhuman/agent/harness/session/session_tests_part_02_tests.rs b/src/openhuman/agent/harness/session/session_tests_part_02_tests.rsindex 75cff4eb32..5a84d401bd 100644--- a/src/openhuman/agent/harness/session/session_tests_part_02_tests.rs+++ b/src/openhuman/agent/harness/session/session_tests_part_02_tests.rs@@ -510,18 +510,22 @@ struct NamedTool(&'static str);#[async_trait]impl Tool for NamedTool {+ /// The caller-chosen name.fn name(&self) -> &str {self.0}+ /// Fixed marker text, so a test can tell it from a synthesised delegate.fn description(&self) -> &str {"durable"}+ /// A schema no synthesised delegate produces, so a spec can be attributed.fn parameters_schema(&self) -> serde_json::Value {serde_json::json!({"type": "object", "properties": {"durable": {"type": "boolean"}}})}+ /// Returns a fixed success; dispatch itself is not under test here.async fn execute(&self,_args: serde_json::Value,@@ -530,6 +534,7 @@ impl Tool for NamedTool {}}+/// A connected Composio toolkit with the given slug, for driving refreshes.fn connected(slug: &str) -> crate::openhuman::agent::context::prompt::ConnectedIntegration {crate::openhuman::agent::context::prompt::ConnectedIntegration {toolkit: slug.into(),diff --git a/src/openhuman/agent/harness/session/turn/tools.rs b/src/openhuman/agent/harness/session/turn/tools.rsindex 3e3014825b..fffe05bf60 100644--- a/src/openhuman/agent/harness/session/turn/tools.rs+++ b/src/openhuman/agent/harness/session/turn/tools.rs@@ -68,7 +68,10 @@ impl Agent {allowed_subagent_ids,turn_model_source: self.turn_model_source.clone(),all_tools: Arc::clone(&self.tools),- all_tool_specs: Arc::clone(&self.tool_specs),+ // The durable registry's own specs, index for index with+ // `all_tools` — never the synthesised delegation specs, which a+ // child holds no instance for and must not see (#4452).+ all_tool_specs: Arc::clone(&self.durable_tool_specs),visible_tool_names: self.visible_tool_specs.iter()diff --git a/src/openhuman/agent/harness/session/turn_tests.rs b/src/openhuman/agent/harness/session/turn_tests.rsindex 3983078a9e..b941be91cf 100644--- a/src/openhuman/agent/harness/session/turn_tests.rs+++ b/src/openhuman/agent/harness/session/turn_tests.rs@@ -380,6 +380,15 @@ impl Drop for WorkspaceEnvGuard {}fn make_agent(visible_tool_names: Option<HashSet<String>>) -> Agent {+ make_agent_with_tool_sets(vec![Box::new(EchoTool)], Vec::new(), visible_tool_names)+}++/// [`make_agent`] with caller-chosen durable and synthesised tool sets.+fn make_agent_with_tool_sets(+ tools: Vec<Box<dyn Tool>>,+ synthesized_tools: Vec<Box<dyn Tool>>,+ visible_tool_names: Option<HashSet<String>>,+) -> Agent {// The embedding seam fails loudly when unwired; before the memory// extraction this was a direct call and needed no setup.crate::openhuman::memory::host_impls::install_for_tests();@@ -402,7 +411,8 @@ fn make_agent(visible_tool_names: Option<HashSet<String>>) -> Agent {let mut builder = Agent::builder().chat_model(Arc::new(DummyProvider))- .tools(vec![Box::new(EchoTool)])+ .tools(tools)+ .synthesized_tools(synthesized_tools).memory(mem).tool_dispatcher(Box::new(XmlToolDispatcher)).workspace_dir(workspace_path)diff --git a/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rs b/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rsindex 68a596af7e..7f9cd30f60 100644--- a/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rs+++ b/src/openhuman/agent/harness/session/turn_tests_part_01_tests.rs@@ -152,6 +152,68 @@ fn build_parent_context_has_no_descriptor_without_profile_or_parent() {assert!(parent.workspace_descriptor.is_none());}+/// Stands in for a synthesised `delegate_*` tool in the parent's own surface.+struct ProbeDelegateTool;++#[async_trait]+impl Tool for ProbeDelegateTool {+ /// A `delegate_*` name, like every synthesised delegation tool.+ fn name(&self) -> &str {+ "delegate_probe"+ }++ /// Marker text only; the description is never asserted on.+ fn description(&self) -> &str {+ "probe delegate"+ }++ /// An empty object schema, like a parameterless delegate.+ fn parameters_schema(&self) -> serde_json::Value {+ serde_json::json!({"type": "object"})+ }++ /// Never dispatched by these tests.+ async fn execute(&self, _args: serde_json::Value) -> Result<ToolResult> {+ Ok(ToolResult::success("probe"))+ }+}++/// What a child is handed: the durable registry and its specs, index for+/// index — never the parent's synthesised delegation specs, which have no+/// instance in `all_tools` and which a sub-agent must not see (#4452).+#[test]+fn build_parent_context_passes_durable_specs_matching_all_tools() {+ let agent = make_agent_with_tool_sets(+ vec![Box::new(EchoTool), Box::new(CronAddProbeTool)],+ vec![Box::new(ProbeDelegateTool)],+ None,+ );+ assert!(+ agent+ .tool_specs()+ .iter()+ .any(|spec| spec.name == "delegate_probe"),+ "sanity: the parent itself advertises the synthesised delegate"+ );++ let parent = agent.build_parent_execution_context();+ assert_eq!(parent.all_tool_specs.len(), parent.all_tools.len());+ for (tool, spec) in parent.all_tools.iter().zip(parent.all_tool_specs.iter()) {+ assert_eq!(+ tool.name(),+ spec.name,+ "a child's specs must track its tools index for index"+ );+ }+ assert!(+ !parent+ .all_tool_specs+ .iter()+ .any(|spec| spec.name == "delegate_probe"),+ "a synthesised delegate spec must never reach a child"+ );+}+#[tokio::test]async fn collect_tree_root_summaries_maps_namespace_body_and_timestamp() {// #2944: the wrapper must carry the root node's `updated_at` from thediff --git a/src/openhuman/agent/harness/session/types.rs b/src/openhuman/agent/harness/session/types.rsindex 3f7dce0cf3..8bfc05bcef 100644--- a/src/openhuman/agent/harness/session/types.rs+++ b/src/openhuman/agent/harness/session/types.rs@@ -113,9 +113,15 @@ pub struct Agent {/// so a name resolves in the same order everywhere. Empty for agents that/// do not delegate.pub(super) synthesized_tools: Arc<Vec<Box<dyn Tool>>>,- /// Full tool specs — sub-agents receive these via- /// [`ParentExecutionContext::all_tool_specs`].+ /// Full tool specs: [`Self::tools`]' specs first, then the synthesised+ /// half, which [`Agent::refresh_delegation_tools`] swaps in place.pub(super) tool_specs: Arc<Vec<ToolSpec>>,+ /// The specs of [`Self::tools`] alone, index for index. Sub-agents receive+ /// these via [`ParentExecutionContext::all_tool_specs`] beside+ /// [`Self::tools`], so a child's spec list can never name a synthesised+ /// delegate it holds no instance for (#4452). Fixed for the life of the+ /// agent, like the registry it describes.+ pub(super) durable_tool_specs: Arc<Vec<ToolSpec>>,/// Tool specs filtered by the visible-tool allowlist and session/// permission policy. These are the specs actually sent to the/// provider in the main agent's chat requests.diff --git a/src/openhuman/agent/orchestration/parent_context/builder.rs b/src/openhuman/agent/orchestration/parent_context/builder.rsindex dbdb323b66..6bf5f35aef 100644--- a/src/openhuman/agent/orchestration/parent_context/builder.rs+++ b/src/openhuman/agent/orchestration/parent_context/builder.rs@@ -95,7 +95,7 @@ pub(crate) async fn build_root_parent(allowed_subagent_ids: HashSet::new(),turn_model_source: agent.turn_model_source(),all_tools: agent.tools_arc(),- all_tool_specs: agent.tool_specs_arc(),+ all_tool_specs: agent.durable_tool_specs_arc(),// No visibility filter for this spawned/background builder — empty means// "unknown" and callers fall back to the full registry (see field doc).visible_tool_names: HashSet::new(),