Skip to content

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

fix(memory): filter collapsed actions by capability

Steven Enamakel0bb1c6bd0582
diff --git a/src/openhuman/memory/tools/collapsed.rs b/src/openhuman/memory/tools/collapsed.rs
index e7a644cb95..c12dbc4ca5 100644
--- a/src/openhuman/memory/tools/collapsed.rs
+++ b/src/openhuman/memory/tools/collapsed.rs
@@ -88,7 +88,28 @@ impl MemoryTool {
///
/// Ordered by how often a turn needs it — `recall` and `store` first — so
/// the enum reads as a recommendation as well as a list.
+ ///
+ /// **Filtered by memory capability.** The eleven members span five of them
+ /// (`Core`, `Recall`, `Tree`, `Entities`, `Maintenance`), and the registry
+ /// drops a tool whose capability the active memory driver does not serve —
+ /// on the stated principle that absence beats a registered tool that
+ /// fails. Collapsing would have quietly broken that: one tool cannot be
+ /// dropped for one capability, so an unavailable action would sit in the
+ /// enum inviting a call that always errors. Filtering here keeps the
+ /// original behaviour, one action at a time.
fn actions(&self) -> Vec<CollapsedAction<'_>> {
+ self.all_actions()
+ .into_iter()
+ .filter(|entry| {
+ crate::core::all::capability_allowed(
+ crate::openhuman::tools::ops::tool_capability(entry.tool.name()),
+ )
+ })
+ .collect()
+ }
+
+ /// Every action this tool can serve, before capability filtering.
+ fn all_actions(&self) -> Vec<CollapsedAction<'_>> {
vec![
CollapsedAction { action: "recall", tool: &self.recall },
CollapsedAction { action: "store", tool: &self.store },
diff --git a/src/openhuman/tools/ops.rs b/src/openhuman/tools/ops.rs
index 51f8d16454..49855a3422 100644
--- a/src/openhuman/tools/ops.rs
+++ b/src/openhuman/tools/ops.rs
@@ -1335,7 +1335,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::openhuman::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.
@@ -1492,7 +1501,7 @@ fn tool_group(name: &str) -> crate::core::all::DomainGroup {
/// about what the *model is told exists*, and the later re-point onto
/// `MemoryGuard` must not change the advertised surface. Assigning them `None`
/// to dodge the mismatch would bake the wrong contract in.
-fn tool_capability(name: &str) -> Option<tinymemory_api::capabilities::Capability> {
+pub(crate) fn tool_capability(name: &str) -> Option<tinymemory_api::capabilities::Capability> {
use tinymemory_api::capabilities::Capability;
// Not driver-backed. Each entry is an argued exception, not a fallthrough.
@@ -1506,9 +1515,15 @@ fn tool_capability(name: &str) -> Option<tinymemory_api::capabilities::Capabilit
let capability = match name {
// ── Mandatory families: always advertised, listed for the record ──
- "memory_store" | "memory_forget" | "remember_preference" | "save_preference" => {
- Capability::Core
- }
+ // 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
// embeddings and chunk rows, never the summary tree.
"memory_recall"