Skip to content

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

feat(mcp): replace memory.search/tree.tag with memory.recall/memory.forget

Steven Enamakel8d6053f953f3
diff --git a/crates/openhuman-core/src/mcp/server/handler_tests.rs b/crates/openhuman-core/src/mcp/server/handler_tests.rs
index b6b8daeb82..dff5327b76 100644
--- a/crates/openhuman-core/src/mcp/server/handler_tests.rs
+++ b/crates/openhuman-core/src/mcp/server/handler_tests.rs
@@ -34,8 +34,8 @@ async fn list_tools_advertises_the_base_catalog_with_annotations() {
for expected in [
"core.list_tools",
"agent.run_subagent",
- "memory.search",
- "tree.tag",
+ "memory.recall",
+ "memory.forget",
] {
assert!(names.contains(&expected), "missing {expected}: {names:?}");
}
@@ -108,6 +108,6 @@ async fn the_http_client_round_trips_against_the_openhuman_handler() {
let init = client.initialize().await.expect("initialize");
assert_eq!(init.server_info["name"], "openhuman-core");
let tools = client.list_tools().await.expect("tools/list");
- assert!(tools.iter().any(|tool| tool.name == "memory.search"));
+ assert!(tools.iter().any(|tool| tool.name == "memory.recall"));
client.close_session().await.expect("DELETE session");
}
diff --git a/crates/openhuman-core/src/mcp/server/tools_tests_dispatch_tests.rs b/crates/openhuman-core/src/mcp/server/tools_tests_dispatch_tests.rs
index c131a49343..96deab1261 100644
--- a/crates/openhuman-core/src/mcp/server/tools_tests_dispatch_tests.rs
+++ b/crates/openhuman-core/src/mcp/server/tools_tests_dispatch_tests.rs
@@ -51,3 +51,25 @@ async fn call_tool_records_write_argument_rejection() {
std::env::remove_var("OPENHUMAN_WORKSPACE");
}
}
+
+#[tokio::test]
+async fn call_tool_rejects_v1_memory_tools_as_unknown() {
+ for name in ["memory.search", "memory.store", "memory.note", "tree.tag"] {
+ let err = call_tool(name, json!({}), "mcp:test")
+ .await
+ .expect_err("removed tool");
+ assert!(err.message().contains("unknown MCP tool"), "{name}");
+ }
+}
+
+#[tokio::test]
+async fn call_tool_validates_memory_arguments_before_dispatch() {
+ let err = call_tool("memory.forget", json!({ "ids": [] }), "mcp:test")
+ .await
+ .expect_err("empty ids rejected before any RPC");
+ assert!(err.message().contains("`ids`"), "got: {}", err.message());
+ let err = call_tool("memory.recall", json!({ "question": "q", "filter": { "x": 1 } }), "mcp:test")
+ .await
+ .expect_err("unknown filter field");
+ assert!(err.message().contains("unexpected filter field"));
+}
diff --git a/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs b/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs
index aed8a8443c..29dacabd20 100644
--- a/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs
+++ b/crates/openhuman-core/src/mcp/server/wire_golden_tests.rs
@@ -153,43 +153,43 @@ const LINE_CASES: &[(&str, Option<&str>)] = &[
),
),
(
- r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":[1,2]}}"#,
+ r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.recall","arguments":[1,2]}}"#,
Some(
r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not an array","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
),
),
(
- r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":"not json"}}"#,
+ r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.recall","arguments":"not json"}}"#,
Some(
r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not a string that is not JSON","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
),
),
(
- r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":7}}"#,
+ r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.recall","arguments":7}}"#,
Some(
r#"{"error":{"code":-32602,"data":"tools/call params.arguments: tool arguments must be a JSON object, not a number","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
),
),
(
- r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":{}}}"#,
+ r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.recall","arguments":{}}}"#,
Some(
- r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ r#"{"error":{"code":-32602,"data":"missing required argument `question`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
),
),
(
- r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":"{}"}}"#,
+ r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.recall","arguments":"{}"}}"#,
Some(
- r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ r#"{"error":{"code":-32602,"data":"missing required argument `question`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
),
),
(
- r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search"}}"#,
+ r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.recall"}}"#,
Some(
- r#"{"error":{"code":-32602,"data":"missing required argument `query`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
+ r#"{"error":{"code":-32602,"data":"missing required argument `question`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
),
),
(
- r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.search","arguments":{"query":"x","bogus":1}}}"#,
+ r#"{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"memory.recall","arguments":{"question":"x","bogus":1}}}"#,
Some(
r#"{"error":{"code":-32602,"data":"unexpected argument `bogus`","message":"Invalid params"},"id":1,"jsonrpc":"2.0"}"#,
),
@@ -234,7 +234,7 @@ const LINE_CASES: &[(&str, Option<&str>)] = &[
),
];
-const TOOLS_LIST_BASE: &str = r#"{"id":2,"jsonrpc":"2.0","result":{"tools":[{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List the live core agent tool catalog that OpenHuman exposes to its orchestrator session.","inputSchema":{"additionalProperties":false,"properties":{},"type":"object"},"name":"core.list_tools","title":"List Core Tools"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Emit the markdown tool-use instructions block that OpenHuman injects into prompt-guided agents.","inputSchema":{"additionalProperties":false,"properties":{},"type":"object"},"name":"core.tool_instructions","title":"Get Tool Instructions"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List registered sub-agent definitions that the core can dispatch for specialized work.","inputSchema":{"additionalProperties":false,"properties":{},"type":"object"},"name":"agent.list_subagents","title":"List Subagents"},{"annotations":{"destructiveHint":true,"idempotentHint":false,"openWorldHint":true,"readOnlyHint":false},"description":"Run a registered OpenHuman sub-agent directly from the core and return its final response.","inputSchema":{"additionalProperties":false,"properties":{"agent_id":{"description":"Registered sub-agent id (for example `planner`, `code_executor`, `critic`).","type":"string"},"prompt":{"description":"Task prompt for the sub-agent. Include the context it needs because this is a fresh session.","type":"string"}},"required":["agent_id","prompt"],"type":"object"},"name":"agent.run_subagent","title":"Run Subagent"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Keyword-search OpenHuman's local memory tree and return matching chunks ordered by recency. Every token in the query must appear in the stored chunk preview (ASCII case-insensitive, any order); punctuation between tokens does not matter. Results are preview-based, so zero hits do not prove that content is absent; try fewer/shorter tokens or `memory.recall` (semantic).","inputSchema":{"additionalProperties":false,"properties":{"k":{"description":"Maximum chunks to return. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"query":{"description":"Keywords; each must appear in the stored chunk preview (any order). Prefer a few short, distinctive tokens over long exact phrases; zero hits do not prove absence.","minLength":1,"type":"string"}},"required":["query"],"type":"object"},"name":"memory.search","title":"Search Memory"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Semantically recall local memory-tree chunks relevant to a natural-language query.","inputSchema":{"additionalProperties":false,"properties":{"k":{"description":"Maximum chunks to return. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"query":{"description":"Natural-language query to embed and rerank against memory summaries.","minLength":1,"type":"string"}},"required":["query"],"type":"object"},"name":"memory.recall","title":"Recall Memory"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Read one memory-tree chunk by id. Use this to inspect the source text behind search or recall results.","inputSchema":{"additionalProperties":false,"properties":{"chunk_id":{"description":"Chunk id returned by memory.search or memory.recall.","type":"string"}},"required":["chunk_id"],"type":"object"},"name":"tree.read_chunk","title":"Read Memory Chunk"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Paginated listing of memory-tree chunks in reverse-chronological order, with optional filters by source kind, source id, entity id, time window, and token-AND keyword. Every token must appear in the stored chunk preview (ASCII case-insensitive, any order; punctuation does not matter). Use this when the user wants to enumerate (\"what's recent in my Gmail\", \"show me everything from last week about Alice\") rather than search by query. Returns chunks plus a total match count for pagination.","inputSchema":{"additionalProperties":false,"properties":{"entity_ids":{"description":"Restrict to chunks referencing any of these canonical entity ids (e.g. `person:Alice`, `email:[email protected]`). Use `tree.top_entities` to discover these.","items":{"type":"string"},"type":"array"},"k":{"description":"Maximum chunks per page. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"offset":{"description":"Pagination offset (number of rows to skip). Defaults to 0.","minimum":0,"type":"integer"},"query":{"description":"Keywords matched against the stored chunk preview; every token must appear (ASCII case-insensitive, any order; punctuation does not matter). Zero hits do not prove absence.","minLength":1,"type":"string"},"since_ms":{"description":"Inclusive lower bound on chunk timestamp, in milliseconds since Unix epoch.","minimum":0,"type":"integer"},"source_ids":{"description":"Restrict to specific logical source ids (e.g. a Slack channel id). Use `tree.list_sources` to discover these.","items":{"type":"string"},"type":"array"},"source_kinds":{"description":"Restrict to one or more source kinds (e.g. `email`, `chat`, `document`). Omit to include all kinds.","items":{"type":"string"},"type":"array"},"until_ms":{"description":"Inclusive upper bound on chunk timestamp, in milliseconds since Unix epoch.","minimum":0,"type":"integer"}},"required":[],"type":"object"},"name":"tree.browse","title":"Browse Memory"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List the most-referenced canonical entities (people, organizations, topics, emails) across the local memory tree. Call this for entity discovery before drilling in with `tree.browse` (passing `entity_ids`) or `memory.search`. Returns entities ordered by reference count.","inputSchema":{"additionalProperties":false,"properties":{"k":{"description":"Maximum entities to return. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"kind":{"description":"Restrict to a single entity kind (`person`, `email`, `topic`, `org`, …). Omit to span all kinds.","minLength":1,"type":"string"}},"required":[],"type":"object"},"name":"tree.top_entities","title":"Top Memory Entities"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List every distinct ingest source (Gmail account, Slack channel, Notion workspace, email thread, …) that has data in the memory tree, with chunk counts and last-activity timestamps. Use this when the user asks \"what data sources do I have\" or to discover source ids to pass into `tree.browse`.","inputSchema":{"additionalProperties":false,"properties":{"user_email_hint":{"description":"When provided, the user's own email is stripped from email-thread display names so the other party shows up instead. Optional.","minLength":1,"type":"string"}},"required":[],"type":"object"},"name":"tree.list_sources","title":"List Memory Sources"},{"annotations":{"destructiveHint":true,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":false},"description":"Create a new memory document from content. The document is stored in the specified namespace (default `mcp`) and can be retrieved via `memory.search` or `memory.recall`.","inputSchema":{"additionalProperties":false,"properties":{"content":{"description":"The text content to store as a memory document.","minLength":1,"type":"string"},"namespace":{"description":"Namespace to store the document in. Defaults to `mcp` when omitted.","minLength":1,"type":"string"},"tags":{"description":"Optional tags for categorisation and filtering.","items":{"type":"string"},"type":"array"},"title":{"description":"Human-readable title for the memory document.","minLength":1,"type":"string"}},"required":["title","content"],"type":"object"},"name":"memory.store","title":"Store Memory"},{"annotations":{"destructiveHint":true,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":false},"description":"Append a note to an existing memory chunk by storing a linked annotation document. The note references the original chunk_id for provenance and can be retrieved alongside it.","inputSchema":{"additionalProperties":false,"properties":{"chunk_id":{"description":"ID of the memory chunk to annotate. Use an ID from memory.search or memory.recall results.","minLength":1,"type":"string"},"note_text":{"description":"The note text to attach to the chunk.","minLength":1,"type":"string"}},"required":["chunk_id","note_text"],"type":"object"},"name":"memory.note","title":"Annotate Memory Chunk"},{"annotations":{"destructiveHint":true,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":false},"description":"Apply one or more category tags to an existing memory chunk. Stored as an upsertable tag-record document linked to the target chunk_id, so re-tagging the same chunk replaces the prior tag set rather than accumulating duplicate annotations. Differs from `memory.note` in that the payload is a categorical label list — queryable via the document `tags` field — rather than free-form text.","inputSchema":{"additionalProperties":false,"properties":{"chunk_id":{"description":"ID of the memory chunk to tag. Use an ID from `memory.search`, `memory.recall`, or `tree.browse` results.","minLength":1,"type":"string"},"tags":{"description":"One or more category labels to attach (e.g. `[\"todo\", \"q3-planning\"]`). Re-tagging the same chunk replaces the prior tag set; supply the complete desired set on each call.","items":{"minLength":1,"type":"string"},"minItems":1,"type":"array"}},"required":["chunk_id","tags"],"type":"object"},"name":"tree.tag","title":"Tag Memory Chunk"}]}}"#;
+const TOOLS_LIST_BASE: &str = r#"{"id":2,"jsonrpc":"2.0","result":{"tools":[{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List the live core agent tool catalog that OpenHuman exposes to its orchestrator session.","inputSchema":{"additionalProperties":false,"properties":{},"type":"object"},"name":"core.list_tools","title":"List Core Tools"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Emit the markdown tool-use instructions block that OpenHuman injects into prompt-guided agents.","inputSchema":{"additionalProperties":false,"properties":{},"type":"object"},"name":"core.tool_instructions","title":"Get Tool Instructions"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List registered sub-agent definitions that the core can dispatch for specialized work.","inputSchema":{"additionalProperties":false,"properties":{},"type":"object"},"name":"agent.list_subagents","title":"List Subagents"},{"annotations":{"destructiveHint":true,"idempotentHint":false,"openWorldHint":true,"readOnlyHint":false},"description":"Run a registered OpenHuman sub-agent directly from the core and return its final response.","inputSchema":{"additionalProperties":false,"properties":{"agent_id":{"description":"Registered sub-agent id (for example `planner`, `code_executor`, `critic`).","type":"string"},"prompt":{"description":"Task prompt for the sub-agent. Include the context it needs because this is a fresh session.","type":"string"}},"required":["agent_id","prompt"],"type":"object"},"name":"agent.run_subagent","title":"Run Subagent"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Keyword-search OpenHuman's local memory tree and return matching chunks ordered by recency. Every token in the query must appear in the stored chunk preview (ASCII case-insensitive, any order); punctuation between tokens does not matter. Results are preview-based, so zero hits do not prove that content is absent; try fewer/shorter tokens or `memory.recall` (semantic).","inputSchema":{"additionalProperties":false,"properties":{"k":{"description":"Maximum chunks to return. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"query":{"description":"Keywords; each must appear in the stored chunk preview (any order). Prefer a few short, distinctive tokens over long exact phrases; zero hits do not prove absence.","minLength":1,"type":"string"}},"required":["query"],"type":"object"},"name":"memory.recall","title":"Search Memory"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Semantically recall local memory-tree chunks relevant to a natural-language query.","inputSchema":{"additionalProperties":false,"properties":{"k":{"description":"Maximum chunks to return. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"query":{"description":"Natural-language query to embed and rerank against memory summaries.","minLength":1,"type":"string"}},"required":["query"],"type":"object"},"name":"memory.recall","title":"Recall Memory"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Read one memory-tree chunk by id. Use this to inspect the source text behind search or recall results.","inputSchema":{"additionalProperties":false,"properties":{"chunk_id":{"description":"Chunk id returned by memory.search or memory.recall.","type":"string"}},"required":["chunk_id"],"type":"object"},"name":"tree.read_chunk","title":"Read Memory Chunk"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"Paginated listing of memory-tree chunks in reverse-chronological order, with optional filters by source kind, source id, entity id, time window, and token-AND keyword. Every token must appear in the stored chunk preview (ASCII case-insensitive, any order; punctuation does not matter). Use this when the user wants to enumerate (\"what's recent in my Gmail\", \"show me everything from last week about Alice\") rather than search by query. Returns chunks plus a total match count for pagination.","inputSchema":{"additionalProperties":false,"properties":{"entity_ids":{"description":"Restrict to chunks referencing any of these canonical entity ids (e.g. `person:Alice`, `email:[email protected]`). Use `tree.top_entities` to discover these.","items":{"type":"string"},"type":"array"},"k":{"description":"Maximum chunks per page. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"offset":{"description":"Pagination offset (number of rows to skip). Defaults to 0.","minimum":0,"type":"integer"},"query":{"description":"Keywords matched against the stored chunk preview; every token must appear (ASCII case-insensitive, any order; punctuation does not matter). Zero hits do not prove absence.","minLength":1,"type":"string"},"since_ms":{"description":"Inclusive lower bound on chunk timestamp, in milliseconds since Unix epoch.","minimum":0,"type":"integer"},"source_ids":{"description":"Restrict to specific logical source ids (e.g. a Slack channel id). Use `tree.list_sources` to discover these.","items":{"type":"string"},"type":"array"},"source_kinds":{"description":"Restrict to one or more source kinds (e.g. `email`, `chat`, `document`). Omit to include all kinds.","items":{"type":"string"},"type":"array"},"until_ms":{"description":"Inclusive upper bound on chunk timestamp, in milliseconds since Unix epoch.","minimum":0,"type":"integer"}},"required":[],"type":"object"},"name":"tree.browse","title":"Browse Memory"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List the most-referenced canonical entities (people, organizations, topics, emails) across the local memory tree. Call this for entity discovery before drilling in with `tree.browse` (passing `entity_ids`) or `memory.search`. Returns entities ordered by reference count.","inputSchema":{"additionalProperties":false,"properties":{"k":{"description":"Maximum entities to return. Defaults to 10; capped at 50.","maximum":50,"minimum":1,"type":"integer"},"kind":{"description":"Restrict to a single entity kind (`person`, `email`, `topic`, `org`, …). Omit to span all kinds.","minLength":1,"type":"string"}},"required":[],"type":"object"},"name":"tree.top_entities","title":"Top Memory Entities"},{"annotations":{"openWorldHint":false,"readOnlyHint":true},"description":"List every distinct ingest source (Gmail account, Slack channel, Notion workspace, email thread, …) that has data in the memory tree, with chunk counts and last-activity timestamps. Use this when the user asks \"what data sources do I have\" or to discover source ids to pass into `tree.browse`.","inputSchema":{"additionalProperties":false,"properties":{"user_email_hint":{"description":"When provided, the user's own email is stripped from email-thread display names so the other party shows up instead. Optional.","minLength":1,"type":"string"}},"required":[],"type":"object"},"name":"tree.list_sources","title":"List Memory Sources"},{"annotations":{"destructiveHint":true,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":false},"description":"Create a new memory document from content. The document is stored in the specified namespace (default `mcp`) and can be retrieved via `memory.search` or `memory.recall`.","inputSchema":{"additionalProperties":false,"properties":{"content":{"description":"The text content to store as a memory document.","minLength":1,"type":"string"},"namespace":{"description":"Namespace to store the document in. Defaults to `mcp` when omitted.","minLength":1,"type":"string"},"tags":{"description":"Optional tags for categorisation and filtering.","items":{"type":"string"},"type":"array"},"title":{"description":"Human-readable title for the memory document.","minLength":1,"type":"string"}},"required":["title","content"],"type":"object"},"name":"memory.store","title":"Store Memory"},{"annotations":{"destructiveHint":true,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":false},"description":"Append a note to an existing memory chunk by storing a linked annotation document. The note references the original chunk_id for provenance and can be retrieved alongside it.","inputSchema":{"additionalProperties":false,"properties":{"chunk_id":{"description":"ID of the memory chunk to annotate. Use an ID from memory.search or memory.recall results.","minLength":1,"type":"string"},"note_text":{"description":"The note text to attach to the chunk.","minLength":1,"type":"string"}},"required":["chunk_id","note_text"],"type":"object"},"name":"memory.note","title":"Annotate Memory Chunk"},{"annotations":{"destructiveHint":true,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":false},"description":"Apply one or more category tags to an existing memory chunk. Stored as an upsertable tag-record document linked to the target chunk_id, so re-tagging the same chunk replaces the prior tag set rather than accumulating duplicate annotations. Differs from `memory.note` in that the payload is a categorical label list — queryable via the document `tags` field — rather than free-form text.","inputSchema":{"additionalProperties":false,"properties":{"chunk_id":{"description":"ID of the memory chunk to tag. Use an ID from `memory.search`, `memory.recall`, or `tree.browse` results.","minLength":1,"type":"string"},"tags":{"description":"One or more category labels to attach (e.g. `[\"todo\", \"q3-planning\"]`). Re-tagging the same chunk replaces the prior tag set; supply the complete desired set on each call.","items":{"minLength":1,"type":"string"},"minItems":1,"type":"array"}},"required":["chunk_id","tags"],"type":"object"},"name":"tree.tag","title":"Tag Memory Chunk"}]}}"#;
/// The resource catalog's ungated head. The tail depends on the `flows` and
/// `skills` features, so it is checked by shape rather than by bytes.
diff --git a/crates/openhuman-core/src/mcp/server/write_dispatch_tests.rs b/crates/openhuman-core/src/mcp/server/write_dispatch_tests.rs
index beb94628b3..e847ced768 100644
--- a/crates/openhuman-core/src/mcp/server/write_dispatch_tests.rs
+++ b/crates/openhuman-core/src/mcp/server/write_dispatch_tests.rs
@@ -1,64 +1,42 @@
use super::*;
#[test]
-fn summarize_write_args_omits_memory_store_content() {
+fn summarize_write_args_omits_memory_learn_text() {
let summary = summarize_write_args(
- "memory.store",
- &json!({
- "title": "A".repeat(140),
- "content": "private body",
- "namespace": "work",
- "tags": ["project", "planning"]
- }),
+ "memory.learn",
+ &json!({ "text": "private preference", "kind": "preference", "confidence": 0.9 }),
);
- assert_eq!(summary["title"].as_str().unwrap().chars().count(), 128);
- assert_eq!(summary["namespace"], "work");
- assert_eq!(summary["tag_count"], 2);
- assert!(summary.get("content").is_none());
-}
-
-#[test]
-fn summarize_write_args_omits_memory_note_text() {
- let summary = summarize_write_args(
- "memory.note",
- &json!({ "chunk_id": "chunk-42", "note_text": "Important context" }),
- );
- assert_eq!(summary["chunk_id"], "chunk-42");
assert_eq!(
- summary["note_text_length"].as_u64(),
- Some("Important context".chars().count() as u64)
+ summary["text_length"].as_u64(),
+ Some("private preference".chars().count() as u64)
);
- assert!(summary.get("note_text").is_none());
+ assert_eq!(summary["kind"], "preference");
+ assert!(summary.get("text").is_none());
+ let default_kind = summarize_write_args("memory.learn", &json!({ "text": "t" }));
+ assert_eq!(default_kind["kind"], "fact");
}
#[test]
-fn summarize_write_args_keeps_tree_tag_labels() {
- let summary = summarize_write_args(
- "tree.tag",
- &json!({ "chunk_id": "chunk-42", "tags": ["todo", "q3"] }),
- );
- assert_eq!(summary["chunk_id"], "chunk-42");
- assert_eq!(summary["tags"], json!(["todo", "q3"]));
+fn summarize_write_args_counts_forget_ids_without_listing_them() {
+ let summary = summarize_write_args("memory.forget", &json!({ "ids": ["a", "b", "c"] }));
+ assert_eq!(summary["id_count"], 3);
+ assert!(summary.get("ids").is_none());
}
#[test]
fn summarize_rejected_write_args_includes_param_keys_only() {
let mut params = Map::new();
- params.insert("content".into(), Value::String("private body".into()));
- params.insert("source_type".into(), Value::String("mcp:test".into()));
- params.insert("title".into(), Value::String("T".into()));
+ params.insert("text".into(), Value::String("private body".into()));
+ params.insert("kind".into(), Value::String("fact".into()));
let summary = summarize_rejected_write_args(
- "memory.store",
- &json!({ "title": "T", "content": "private body" }),
+ "memory.learn",
+ &json!({ "text": "private body", "kind": "fact" }),
Some(&params),
);
- assert_eq!(
- summary["param_keys"],
- json!(["content", "source_type", "title"])
- );
- assert!(summary.get("content").is_none());
+ assert_eq!(summary["param_keys"], json!(["kind", "text"]));
+ assert!(summary.get("text").is_none());
}
#[test]
@@ -70,7 +48,7 @@ fn write_policy_logs_and_returns_denial() {
config.autonomy.enabled = true;
config.autonomy.level = crate::security::AutonomyLevel::ReadOnly;
- let err = enforce_write_policy_for_config("memory.store", &config)
+ let err = enforce_write_policy_for_config("memory.forget", &config)
.expect_err("read-only mode should deny writes");
assert!(err.message().contains("read-only mode"));
}
@@ -85,8 +63,8 @@ async fn audit_write_rejection_records_failure_row() {
let err = ToolCallError::InvalidParams("bad write request".into());
audit_write_rejection(
&config,
- "memory.store",
- &json!({ "title": "T", "content": "private body" }),
+ "memory.learn",
+ &json!({ "text": "private body" }),
None,
"mcp:test",
&err,
@@ -107,30 +85,32 @@ async fn audit_write_rejection_records_failure_row() {
assert_eq!(rows.len(), 1);
assert!(!rows[0].success);
- assert_eq!(rows[0].tool_name, "memory.store");
+ assert_eq!(rows[0].tool_name, "memory.learn");
assert_eq!(rows[0].client_info, "mcp:test");
assert_eq!(rows[0].error_message.as_deref(), Some("bad write request"));
- assert!(rows[0].args_summary.get("content").is_none());
+ assert!(rows[0].args_summary.get("text").is_none());
}
#[test]
-fn extract_document_id_reads_rpc_outcome_envelope() {
+fn extract_item_id_reads_rpc_outcome_envelope() {
assert_eq!(
- extract_document_id(&json!({"result": {"document_id": "doc-123"}, "logs": []})).as_deref(),
- Some("doc-123")
+ extract_item_id(&json!({"result": {"id": "item-123"}, "logs": []})).as_deref(),
+ Some("item-123")
);
assert_eq!(
- extract_document_id(&json!({"document_id": "doc-456"})).as_deref(),
- Some("doc-456")
+ extract_item_id(&json!({"id": "item-456"})).as_deref(),
+ Some("item-456")
);
}
#[test]
fn test_is_write_tool_recognizes_write_tools() {
- assert!(is_write_tool("memory.store"));
- assert!(is_write_tool("memory.note"));
- assert!(is_write_tool("tree.tag"));
- assert!(!is_write_tool("memory.search"));
+ assert!(is_write_tool("memory.learn"));
+ assert!(is_write_tool("memory.forget"));
+ assert!(!is_write_tool("memory.recall"));
+ assert!(!is_write_tool("memory.fetch"));
+ assert!(!is_write_tool("memory.list"));
+ assert!(!is_write_tool("memory.learn"));
assert!(!is_write_tool("core.list_tools"));
assert!(!is_write_tool("unknown"));
}
@@ -145,13 +125,6 @@ fn test_now_ms_returns_recent_timestamp() {
assert!((now - t).abs() < 5_000);
}
-#[test]
-fn test_first_chars_truncates_at_boundary() {
- assert_eq!(first_chars("hello world", 5), "hello");
- assert_eq!(first_chars("hi", 10), "hi");
- assert_eq!(first_chars("", 5), "");
-}
-
#[test]
fn test_summarize_write_args_unknown_tool_returns_empty_object() {
let result = summarize_write_args("unknown.tool", &json!({"foo": "bar"}));
@@ -160,19 +133,19 @@ fn test_summarize_write_args_unknown_tool_returns_empty_object() {
#[test]
fn test_summarize_write_args_non_object_returns_empty_object() {
- let result = summarize_write_args("memory.store", &json!("not an object"));
+ let result = summarize_write_args("memory.learn", &json!("not an object"));
assert_eq!(result, json!({}));
}
#[test]
-fn test_extract_document_id_returns_none_for_missing() {
- assert!(extract_document_id(&json!({"other": "field"})).is_none());
- assert!(extract_document_id(&json!({})).is_none());
+fn test_extract_item_id_returns_none_for_missing() {
+ assert!(extract_item_id(&json!({"forgotten": 2})).is_none());
+ assert!(extract_item_id(&json!({})).is_none());
}
#[test]
fn test_summarize_rejected_write_args_without_params() {
- let result = summarize_rejected_write_args("memory.store", &json!({"title": "T"}), None);
+ let result = summarize_rejected_write_args("memory.learn", &json!({"text": "T"}), None);
// When params is None, no "param_keys" field should appear
assert!(result.get("param_keys").is_none());
}
@@ -186,11 +159,20 @@ async fn test_dispatch_write_tool_rpc_error_records_audit_and_returns_tool_error
config.workspace_dir = tmp.path().join("workspace");
std::fs::create_dir_all(&config.workspace_dir).unwrap();
- // Intentionally omit required fields so the handler returns Some(Err(...))
+ // Omit the required `text` so the handler (or the missing registration)
+ // yields a failure instead of a stored item.
let params = serde_json::Map::new();
let result =
- dispatch_write_tool("memory.store", &params, &json!({}), "mcp:test", &config).await;
+ dispatch_write_tool(
+ "memory.learn",
+ "openhuman.memory_learn",
+ &params,
+ &json!({}),
+ "mcp:test",
+ &config,
+ )
+ .await;
// Returns Ok(tool_error_value) — not an Err
assert!(result.is_ok());
@@ -213,7 +195,7 @@ async fn test_dispatch_write_tool_rpc_error_records_audit_and_returns_tool_error
}
assert_eq!(rows.len(), 1);
assert!(!rows[0].success);
- assert_eq!(rows[0].tool_name, "memory.store");
+ assert_eq!(rows[0].tool_name, "memory.learn");
assert!(rows[0].error_message.is_some());
}
@@ -229,8 +211,8 @@ async fn test_audit_write_success_path() {
NewMcpWriteRecord {
timestamp_ms: now_ms(),
client_info: "mcp:test".to_string(),
- tool_name: "memory.store".to_string(),
- args_summary: json!({"title": "Test", "namespace": "mcp", "tag_count": 0}),
+ tool_name: "memory.learn".to_string(),
+ args_summary: json!({"text_length": 4, "kind": "fact"}),
resulting_chunk_id: Some("doc-success-1".to_string()),
success: true,
error_message: None,
@@ -252,8 +234,32 @@ async fn test_audit_write_success_path() {
assert_eq!(rows.len(), 1);
assert!(rows[0].success);
- assert_eq!(rows[0].tool_name, "memory.store");
+ assert_eq!(rows[0].tool_name, "memory.learn");
assert_eq!(rows[0].client_info, "mcp:test");
assert!(rows[0].error_message.is_none());
assert_eq!(rows[0].resulting_chunk_id.as_deref(), Some("doc-success-1"));
}
+
+#[tokio::test]
+async fn test_dispatch_write_tool_unregistered_rpc_is_a_tool_error() {
+ let tmp = tempfile::TempDir::new().unwrap();
+ let mut config = Config::default();
+ config.workspace_dir = tmp.path().join("workspace");
+ std::fs::create_dir_all(&config.workspace_dir).unwrap();
+
+ let val = dispatch_write_tool(
+ "memory.forget",
+ "openhuman.memory_no_such_method",
+ &Map::new(),
+ &json!({ "ids": ["a"] }),
+ "mcp:test",
+ &config,
+ )
+ .await
+ .expect("tool error, not a protocol error");
+ assert_eq!(val.get("isError"), Some(&json!(true)));
+ assert!(val["content"][0]["text"]
+ .as_str()
+ .unwrap()
+ .contains("is not registered"));
+}