Skip to content

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

Merge upstream/main into fix/6145-delegation-tools-arc-refresh

Shanu957ad9613e38
diff --cc src/openhuman/agent/harness/session/session_tests.rs
index f8f8f9a687,5e5142fdbb..e74237a312
--- a/src/openhuman/agent/harness/session/session_tests.rs
+++ b/src/openhuman/agent/harness/session/session_tests.rs
@@@ -176,19 -176,8 +176,18 @@@ fn _assert_builder_is_exported() -> Age
/// built `Agent` so individual tests can assert against the
/// [`Agent::agent_definition_name`] accessor.
fn build_minimal_agent_with_definition_name(definition_name: Option<&str>) -> Agent {
+ build_minimal_agent_with_tool_sets(vec![Box::new(MockTool)], Vec::new(), definition_name)
+}
+
+/// [`build_minimal_agent_with_definition_name`] with caller-chosen durable and
+/// synthesised tool sets, for the tests that pin how the two sets relate.
+fn build_minimal_agent_with_tool_sets(
+ tools: Vec<Box<dyn Tool>>,
+ synthesized_tools: Vec<Box<dyn Tool>>,
+ definition_name: Option<&str>,
+) -> 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();
let workspace = tempfile::TempDir::new().expect("temp workspace");
let workspace_path = workspace.path().to_path_buf();
diff --cc src/openhuman/agent/harness/session/turn_tests.rs
index b941be91cf,683d4fcbaa..03fab9f629
--- a/src/openhuman/agent/harness/session/turn_tests.rs
+++ b/src/openhuman/agent/harness/session/turn_tests.rs
@@@ -380,18 -380,8 +380,17 @@@ 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();
let workspace = tempfile::TempDir::new().expect("temp workspace");
let workspace_path = workspace.path().to_path_buf();
std::mem::forget(workspace);
diff --cc src/openhuman/agent/harness/session/turn_tests_part_01_tests.rs
index 7f9cd30f60,3be2a10e7b..f84565e17e
--- 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,164 -152,6 +152,68 @@@ fn build_parent_context_has_no_descript
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 the
- // store tuple into the `NamespaceSummary` the prompt renderer stamps.
- //
- // Asserted over a **profile** subtree since #5560: the mapping is the same
- // one both arms share, and the profile arm is the one that still scans a
- // caller-named workspace. The shared `"memory"` arm now answers from the
- // bound driver, which has no way to be pointed at this temp directory.
- use crate::openhuman::config::Config;
- use tinycortex::memory::tree::runtime::{
- derive_parent_id, estimate_tokens, level_from_node_id, TreeNode,
- };
- use tinymemory_core::tree::tree_runtime::store::write_node;
-
- let tmp = tempfile::TempDir::new().unwrap();
- let workspace = tmp.path().join("workspace");
- std::fs::create_dir_all(&workspace).unwrap();
- let config = Config {
- workspace_dir: workspace.clone(),
- ..Config::default()
- };
-
- let updated_at = chrono::DateTime::parse_from_rfc3339("2026-05-25T09:00:00Z")
- .unwrap()
- .with_timezone(&chrono::Utc);
- let summary = "Distilled activities summary.";
- let node = TreeNode {
- node_id: "root".to_string(),
- namespace: "activities".to_string(),
- level: level_from_node_id("root"),
- parent_id: derive_parent_id("root"),
- summary: summary.to_string(),
- token_count: estimate_tokens(summary),
- child_count: 0,
- created_at: updated_at,
- updated_at,
- metadata: None,
- };
- write_node(&config, &node).unwrap();
- // `write_node` only knows `<workspace>/memory`; rename it into the profile
- // layout the host-local arm reads.
- std::fs::rename(workspace.join("memory"), workspace.join("memory-alice")).unwrap();
-
- let summaries = collect_tree_root_summaries(&workspace, "memory-alice", 8_000, 32_000).await;
- assert_eq!(summaries.len(), 1);
- assert_eq!(summaries[0].namespace, "activities");
- assert_eq!(summaries[0].body, summary);
- assert_eq!(summaries[0].updated_at, updated_at);
- }
-
- #[tokio::test]
- async fn collect_tree_root_summaries_reads_only_profile_memory_subtree() {
- use crate::openhuman::config::Config;
- use tinycortex::memory::tree::runtime::{
- derive_parent_id, estimate_tokens, level_from_node_id, TreeNode,
- };
- use tinymemory_core::tree::tree_runtime::store::write_node;
-
- let tmp = tempfile::TempDir::new().unwrap();
- let workspace = tmp.path().join("workspace");
- std::fs::create_dir_all(&workspace).unwrap();
- let config = Config {
- workspace_dir: workspace.clone(),
- ..Config::default()
- };
- let now = chrono::Utc::now();
- let node = TreeNode {
- node_id: "root".into(),
- namespace: "private".into(),
- level: level_from_node_id("root"),
- parent_id: derive_parent_id("root"),
- summary: "Alice-only context".into(),
- token_count: estimate_tokens("Alice-only context"),
- child_count: 0,
- created_at: now,
- updated_at: now,
- metadata: None,
- };
- write_node(&config, &node).unwrap();
- std::fs::rename(workspace.join("memory"), workspace.join("memory-alice")).unwrap();
-
- // A *different* profile's subtree, not `"memory"`: since #5560 the shared
- // arm answers from the bound driver rather than from this temp workspace,
- // so asking it here would be asserting about a store this test never
- // wrote. Bob is the isolation the assertion is actually about.
- assert!(
- collect_tree_root_summaries(&workspace, "memory-bob", 8_000, 32_000)
- .await
- .is_empty()
- );
- let summaries = collect_tree_root_summaries(&workspace, "memory-alice", 8_000, 32_000).await;
- assert_eq!(summaries.len(), 1);
- assert_eq!(summaries[0].body, "Alice-only context");
- }
-
#[tokio::test]
async fn transcript_roundtrip_work() {
let mut agent = make_agent(None);