Skip to content

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

fix(memory): clarify that keyword search matches stored preview, not raw content

Steven Enamakel90b1a16c000c
diff --git a/src/openhuman/mcp/server/tools/specs.rs b/src/openhuman/mcp/server/tools/specs.rs
index b204aefc70..86c95b8aa2 100644
--- a/src/openhuman/mcp/server/tools/specs.rs
+++ b/src/openhuman/mcp/server/tools/specs.rs
@@ -72,15 +72,14 @@ pub fn base_tool_specs() -> Vec<McpToolSpec> {
name: "memory.search",
title: "Search Memory",
description: "Keyword-search OpenHuman's local memory tree and return matching chunks \
- ordered by recency. Every whitespace-separated token in the query must \
- appear in a chunk (case-insensitive, any order); punctuation between \
- tokens does not matter. Zero hits means those tokens are absent — try \
- fewer/shorter tokens or `memory.recall` (semantic) before concluding \
- content is missing.",
+ ordered by recency. Every token in the query must appear in the stored \
+ chunk preview (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).",
rpc_method: Some("openhuman.memory_tree_search"),
input_schema: query_schema(
- "Space-separated keywords; each must appear in the chunk (any order). Prefer a few \
- short, distinctive tokens over long exact phrases.",
+ "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.",
),
annotations: read_only_local_annotations(),
},
@@ -115,8 +114,8 @@ pub fn base_tool_specs() -> Vec<McpToolSpec> {
title: "Browse Memory",
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 whitespace-separated token must appear in the \
- chunk (case-insensitive, any order; punctuation does not matter). Use this \
+ and token-AND keyword. Every token must appear in the stored chunk preview \
+ (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 \
@@ -319,7 +318,7 @@ fn tree_browse_schema() -> Value {
"query": {
"type": "string",
"minLength": 1,
- "description": "Space-separated keywords; every token must appear in the chunk (case-insensitive, any order; punctuation does not matter)."
+ "description": "Keywords matched against the stored chunk preview; every token must appear (case-insensitive, any order; punctuation does not matter). Zero hits do not prove absence."
},
"k": {
"type": "integer",
diff --git a/src/openhuman/memory/read_rpc/chunks.rs b/src/openhuman/memory/read_rpc/chunks.rs
index 2fece97d58..e67527cc6e 100644
--- a/src/openhuman/memory/read_rpc/chunks.rs
+++ b/src/openhuman/memory/read_rpc/chunks.rs
@@ -92,9 +92,10 @@ async fn list_chunks_page(
let (rows, total) = if tokens.len() > 1 {
let mut unpaged = query.clone();
unpaged.content_contains = None;
- unpaged.limit = None;
+ // Keep every provider scan bounded before intersecting the results.
+ unpaged.limit = Some(limit as usize);
unpaged.offset = None;
- let rows = token_and_details(chunks, &unpaged, &tokens).await?;
+ let rows = token_and_details(chunks, &unpaged, &tokens, "list_chunks").await?;
let total = rows.len() as u64;
let page = rows
.into_iter()
@@ -191,7 +192,12 @@ async fn token_and_details(
chunks: &dyn MemoryChunks,
query: &ChunkQuery,
tokens: &[String],
+ operation: &str,
) -> Result<Vec<ChunkListRow>, String> {
+ log::debug!(
+ "[memory_tree::read] {operation}: token-and provider calls={}",
+ tokens.len()
+ );
let mut matches: Option<Vec<ChunkListRow>> = None;
for token in tokens {
let mut token_query = query.clone();
@@ -401,10 +407,10 @@ pub async fn search_rpc(
let tokens = query_tokens(Some(&query));
let rows = if tokens.len() > 1 {
let query = ChunkQuery {
- limit: None,
+ limit: Some(limit as usize),
..Default::default()
};
- token_and_details(chunks, &query, &tokens)
+ token_and_details(chunks, &query, &tokens, "search")
.await?
.into_iter()
.take(limit as usize)
diff --git a/src/openhuman/memory/read_rpc/chunks_tests.rs b/src/openhuman/memory/read_rpc/chunks_tests.rs
index e4ec87fa80..e628c2cb4f 100644
--- a/src/openhuman/memory/read_rpc/chunks_tests.rs
+++ b/src/openhuman/memory/read_rpc/chunks_tests.rs
@@ -18,8 +18,8 @@
//! they were asked, unlike the destructive handlers in `admin_tests.rs`.
use super::{
- chunk_query_from_filter, chunk_row_from_list_row, content_predicate, list_chunks_rpc,
- list_sources_rpc, pair_leaves_with_rows, search_rpc,
+ chunk_query_from_filter, chunk_row_from_list_row, list_chunks_rpc, list_sources_rpc,
+ pair_leaves_with_rows, search_rpc,
};
use chrono::TimeZone;
@@ -172,16 +172,15 @@ fn the_page_bounds_and_predicates_ride_one_query() {
assert!(!query.exclude_dropped);
}
-/// The substring travels bare. Wrapping it in `%…%` host-side would double the
-/// driver's own wrapping and match nothing.
+/// Queries are split on punctuation so punctuation in either the stored
+/// content or the query cannot prevent a token match.
#[test]
-fn the_content_predicate_is_trimmed_and_unwrapped() {
- assert_eq!(content_predicate(" phoenix ").as_deref(), Some("phoenix"));
- assert_eq!(content_predicate(" "), None);
- assert_eq!(content_predicate(""), None);
- // `%` and `_` are the user's text; escaping them is the driver's job, so
- // they must arrive intact rather than pre-mangled here.
- assert_eq!(content_predicate("50%_off").as_deref(), Some("50%_off"));
+fn query_tokens_ignore_punctuation() {
+ assert_eq!(
+ super::query_tokens(Some(" phoenix, migration! ")),
+ ["phoenix", "migration"]
+ );
+ assert!(super::query_tokens(Some(" ")).is_empty());
}
// ── the wire shape ───────────────────────────────────────────────────────
diff --git a/src/openhuman/memory/schema/schema_schema_part_01.rs b/src/openhuman/memory/schema/schema_schema_part_01.rs
index 8a03847e14..7eb8bcae6c 100644
--- a/src/openhuman/memory/schema/schema_schema_part_01.rs
+++ b/src/openhuman/memory/schema/schema_schema_part_01.rs
@@ -118,7 +118,7 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
FieldSchema {
name: "query",
ty: TypeSchema::Option(Box::new(TypeSchema::String)),
- comment: "Space-separated keywords; every token must appear in the chunk (case-insensitive, any order; punctuation does not matter).",
+ comment: "Keywords matched against the stored chunk preview; every token must appear (case-insensitive, any order; punctuation does not matter). Zero hits do not prove absence.",
required: false,
},
FieldSchema {
@@ -194,7 +194,7 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
FieldSchema {
name: "query",
ty: TypeSchema::String,
- comment: "Space-separated keywords; every token must appear in the chunk (case-insensitive, any order; punctuation does not matter).",
+ comment: "Keywords matched against the stored chunk preview; every token must appear (case-insensitive, any order; punctuation does not matter). Zero hits do not prove absence.",
required: true,
},
FieldSchema {