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(tools): restore the collapsed memory tool and wildcard exposure enforcement
M3gA-Mind36e58a9578d0
diff --git a/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rs b/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rsindex db4c774209..ae6734a650 100644--- a/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rs+++ b/crates/openhuman-core/src/agent/harness/session/builder/builder_build.rs@@ -59,7 +59,10 @@ impl AgentBuilder {// tools stay in the registry below and stay executable — only the// advertised surface shrinks. Applied here, before the policy filter,// so the visible set and the policy session cannot disagree.- if visible_names.is_empty() {+ // An empty set here is a wildcard belt; anything else was written down+ // by an agent author (or synthesised for one) and is left alone below.+ let belt_is_wildcard = visible_names.is_empty();+ if belt_is_wildcard {visible_names = tools.iter().chain(synthesized_tools.iter())@@ -70,6 +73,40 @@ impl AgentBuilder {&mut visible_names,&agent_definition_name,);+ // Per-tool exposure: `Hidden` members of a collapsed tool (`memory_*`,+ // `todo_*`) and `Deferred` tools leave the wire; they stay registered+ // and dispatchable. Only for a wildcard belt — a hand-written `[tools]+ // named` list is already the answer to "what should this agent see".+ //+ // Only the DURABLE registry is passed, never `synthesized_tools`: every+ // `ArchetypeDelegationTool` reports `Hidden`, and on a wildcard belt the+ // synthesised delegates are the agent's only hand-off routes. Stripping+ // them would delete every `research`/`run_code`/… route.+ // `strip_deferred_from_visible` only looks at the tools it is given.+ //+ // This is the one site that turns the "all visible" sentinel into a+ // concrete set for a session, so the refresh paths never re-admit a+ // durable Hidden tool: `refresh_delegation_tools` (turn/tools.rs) only+ // swaps synthesised names, and `Agent::hide_tools` only seeds a set+ // that is still empty — see the matching strip there.+ let deferred = if belt_is_wildcard {+ crate::tools::implementations::meta::strip_deferred_from_visible(+ &mut visible_names,+ tools.as_slice(),+ )+ } else {+ Vec::new()+ };+ if !deferred.is_empty() {+ tracing::info!(+ agent = %agent_definition_name,+ deferred = deferred.len(),+ "[tools] withheld deferred tool schemas; reachable via tool_search"+ );+ }+ // Index them where the model can find them again. Done here rather than+ // at registration because which tools are deferred depends on the belt.+ crate::tools::implementations::meta::bind_tool_search_index(tools.as_slice(), deferred);let config = self.config.clone().unwrap_or_default();let event_session_id = self.event_session_iddiff --git a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests.rs b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests.rsindex d3df944742..b3633352fb 100644--- a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests.rs+++ b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests.rs@@ -69,6 +69,8 @@ mod memory_write_instruction_tests;mod profile_soul_prompt_tests;#[path = "builder_tests_session_agent_profile_tests.rs"]mod session_agent_profile_tests;+#[path = "builder_tests_tool_exposure_tests.rs"]+mod tool_exposure_tests;#[path = "builder_tests_tool_spec_views_tests.rs"]mod tool_spec_views_tests;diff --git a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_tool_exposure_tests.rs b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_tool_exposure_tests.rsnew file mode 100644index 0000000000..c4bd929eff--- /dev/null+++ b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_tool_exposure_tests.rs@@ -0,0 +1,65 @@+use super::*;++fn visible_names(agent_id: &str) -> std::collections::HashSet<String> {+ crate::agent::harness::AgentDefinitionRegistry::init_global_builtins().unwrap();+ let tmp = tempfile::TempDir::new().unwrap();+ let config = test_config(&tmp);+ let agent = crate::agent::Agent::from_config_for_agent(&config, agent_id)+ .unwrap_or_else(|e| panic!("{agent_id} session build: {e}"));+ agent+ .visible_tool_specs_arc()+ .iter()+ .map(|spec| spec.name.clone())+ .collect()+}++/// A wildcard belt advertises the collapsed tool, never its `Hidden` members.+///+/// Both halves are asserted: the members gone AND the replacement present. A+/// belt that lost the memory surface entirely would pass a members-only check.+/// Regressed silently once already — `4efbea728` unregistered `memory` and+/// dropped the only production call to `strip_deferred_from_visible`, so every+/// wildcard agent shipped all eleven `memory_*` schemas plus `todo` beside the+/// eight `todo_*` tools it replaces.+#[test]+fn wildcard_belt_advertises_collapsed_tools_not_their_hidden_members() {+ let visible = visible_names("tools_agent");++ for collapsed in [+ crate::memory::tools::MEMORY_TOOL_NAME,+ "todo",+ crate::tools::implementations::meta::TOOL_SEARCH_NAME,+ ] {+ assert!(+ visible.contains(collapsed),+ "wildcard belt must advertise `{collapsed}`; got {visible:?}"+ );+ }+ let leaked: Vec<&String> = visible+ .iter()+ .filter(|name| {+ (name.starts_with("memory_") && name.as_str() != "memory_tree")+ || name.starts_with("todo_")+ })+ .collect();+ assert!(+ leaked.is_empty(),+ "Hidden members of `memory`/`todo` must not ship beside them: {leaked:?}"+ );+}++/// A hand-written `[tools] named` belt is left exactly as written: exposure is+/// only for the wildcard belt. `flow_memory_agent` names three read-only+/// `memory_*` tools; swapping them for `memory` would hand it `store`/`forget`.+#[test]+fn named_belt_keeps_its_legacy_members() {+ let visible = visible_names("flow_memory_agent");+ assert!(+ visible.contains("memory_recall"),+ "named belt must keep the members it lists; got {visible:?}"+ );+ assert!(+ !visible.contains(crate::memory::tools::MEMORY_TOOL_NAME),+ "named belt must not gain the collapsed tool; got {visible:?}"+ );+}diff --git a/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rs b/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rsindex f732908631..547cbcc7c8 100644--- a/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rs+++ b/crates/openhuman-core/src/agent/harness/session/runtime/accessors.rs@@ -423,6 +423,15 @@ impl Agent {.iter().map(|spec| spec.name.clone()).collect();+ // Seeding a wildcard belt re-admits the durable Hidden/Deferred+ // tools the builder withheld; drop them again. Durable registry+ // only — the synthesised delegates report `Hidden` too and are+ // this belt's hand-off routes (see `AgentBuilder::build`). The+ // deferred specs were already indexed at build time.+ let _ = crate::tools::implementations::meta::strip_deferred_from_visible(+ &mut self.visible_tool_names,+ self.tools.as_slice(),+ );}for name in names {self.visible_tool_names.remove(*name);diff --git a/crates/openhuman-core/src/tools/impl/meta/tool_search_tests.rs b/crates/openhuman-core/src/tools/impl/meta/tool_search_tests.rsindex ac4497d595..d40f5999ba 100644--- a/crates/openhuman-core/src/tools/impl/meta/tool_search_tests.rs+++ b/crates/openhuman-core/src/tools/impl/meta/tool_search_tests.rs@@ -83,3 +83,90 @@ fn ranking_is_stable_across_identical_queries() {.collect();assert_eq!(first, second);}++// ── strip + bind: a deferred tool leaves the wire and stays findable ─────────++struct ExposureTestTool {+ name: &'static str,+ description: &'static str,+ exposure: crate::tools::ToolExposure,+}++#[async_trait::async_trait]+impl Tool for ExposureTestTool {+ fn name(&self) -> &str {+ self.name+ }++ fn description(&self) -> &str {+ self.description+ }++ fn parameters_schema(&self) -> Value {+ json!({"type": "object"})+ }++ fn exposure(&self) -> crate::tools::ToolExposure {+ self.exposure+ }++ async fn execute(&self, _args: Value) -> Result<ToolResult> {+ Ok(ToolResult::success("ok"))+ }+}++/// The two halves the session builder runs back to back. A Deferred tool must+/// come off the advertised set AND be findable through `tool_search`; a Hidden+/// one comes off and is not searchable; `tool_search` itself always stays.+/// Stripping without the index would make every deferred tool unreachable.+#[test]+fn a_deferred_tool_leaves_the_wire_and_is_found_by_tool_search() {+ use crate::tools::ToolExposure;+ let tools: Vec<Box<dyn Tool>> = vec![+ Box::new(ToolSearchTool::new()),+ Box::new(ExposureTestTool {+ name: "stock_quote",+ description: "Get the latest price for a stock ticker",+ exposure: ToolExposure::Deferred,+ }),+ Box::new(ExposureTestTool {+ name: "memory_store",+ description: "Store a memory",+ exposure: ToolExposure::Hidden,+ }),+ Box::new(ExposureTestTool {+ name: "memory",+ description: "Store and search memories",+ exposure: ToolExposure::Direct,+ }),+ ];+ let mut visible: std::collections::HashSet<String> =+ tools.iter().map(|t| t.name().to_string()).collect();++ let deferred = strip_deferred_from_visible(&mut visible, &tools);+ assert!(bind_tool_search_index(&tools, deferred));++ let mut advertised: Vec<&str> = visible.iter().map(String::as_str).collect();+ advertised.sort_unstable();+ assert_eq!(advertised, vec!["memory", TOOL_SEARCH_NAME]);++ let handle = tools[0]+ .host_extension()+ .and_then(|any| any.downcast_ref::<ToolSearchHandle>())+ .expect("tool_search exposes its index handle");+ let index = handle.read().unwrap();+ let hits: Vec<&str> = index+ .search("stock price", 5)+ .iter()+ .map(|t| t.name.as_str())+ .collect();+ assert_eq!(+ hits,+ vec!["stock_quote"],+ "the deferred tool must be searchable"+ );+ assert!(+ index.search("store memory", 5).is_empty(),+ "a Hidden tool is not searchable"+ );+}diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rsindex 15807b298e..9a28e788e6 100644--- a/crates/openhuman-core/src/tools/ops.rs+++ b/crates/openhuman-core/src/tools/ops.rs@@ -422,6 +422,14 @@ pub fn all_tools_with_runtime(Box::new(WalletTxReceiptTool::new()),#[cfg(feature = "web3")]Box::new(WalletLookupTxTool::new()),+ // The memory surface the model sees. The eleven per-operation tools it+ // dispatches to stay registered as `ToolExposure::Hidden` so a+ // replayed transcript or a saved skill naming `memory_*` still works —+ // see `memory::tools::collapsed`.+ Box::new(crate::memory::tools::MemoryTool::new(+ config.clone(),+ security.clone(),+ )),Box::new(MemoryStoreTool::new(security.clone())),Box::new(MemoryRecallTool::new()),Box::new(MemoryForgetTool::new(security.clone())),@@ -1156,6 +1164,17 @@ pub fn all_tools_with_runtime(// `orchestrator_tools::collect_orchestrator_tools` — which never pass// through this function.crate::tools::toolpacks::append_pack_tools(&mut tools);++ // The lookup half of `ToolExposure::Deferred`. Always registered, for the+ // same reason `use_skill` is: whether anything is actually deferred depends+ // on the agent's belt, which is resolved later in the session builder, and+ // a search tool that arrived *after* the tools it searches were hidden+ // would be one release of silently unreachable capabilities. Its index+ // starts empty and costs one small schema; the builder fills it via+ // `bind_tool_search_index`.+ tools.push(Box::new(+ crate::tools::implementations::meta::ToolSearchTool::new(),+ ));tools}@@ -1293,7 +1312,16 @@ fn tool_group(name: &str) -> crate::core::all::DomainGroup {return DomainGroup::Voice;}// Memory family (harness-kept): memory_* store/search/etc + goals_* + extras.- if name.starts_with("memory_") || name.starts_with("goals_") || MEMORY_EXTRA.contains(&name) {+ //+ // The bare `memory` name is matched explicitly: the collapsed tool drops+ // the `memory_` prefix its members carry, so prefix matching alone would+ // land it in `Platform` and leave the whole memory surface callable under+ // a `DomainSet { platform: true, memory: false }`.+ if name == crate::memory::tools::MEMORY_TOOL_NAME+ || name.starts_with("memory_")+ || name.starts_with("goals_")+ || MEMORY_EXTRA.contains(&name)+ {return DomainGroup::Memory;}// Threads family (harness-kept): thread_* + todo_* + per-thread goal + search.@@ -1451,7 +1479,11 @@ pub(crate) fn tool_capability(name: &str) -> Option<tinymemory_api::capabilitieslet capability = match name {// ── Mandatory families: always advertised, listed for the record ──- "memory_store" | "memory_forget" | "remember_preference" | "save_preference" => {+ // The collapsed `memory` tool is `Core` because `store` and `forget`+ // are: it must stay registered whenever the mandatory family is, and+ // it filters its own action list by capability so an unavailable+ // action is never advertised. See `memory::tools::collapsed`.+ "memory" | "memory_store" | "memory_forget" | "remember_preference" | "save_preference" => {Capability::Core}// Chunk/recall retrieval surface. NOT `Tree` — these read chunk