Skip to content

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

fix(memory): clarify case-insensitive matching is ASCII-only and fix multi-token pagination

Steven Enamakelaa9cccf5f71f
diff --git a/src/openhuman/mcp/server/tools/specs.rs b/src/openhuman/mcp/server/tools/specs.rs
index 86c95b8aa2..fac5bb793d 100644
--- a/src/openhuman/mcp/server/tools/specs.rs
+++ b/src/openhuman/mcp/server/tools/specs.rs
@@ -73,7 +73,7 @@ pub fn base_tool_specs() -> Vec<McpToolSpec> {
title: "Search Memory",
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 (case-insensitive, any order); punctuation between tokens \
+ 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).",
rpc_method: Some("openhuman.memory_tree_search"),
@@ -115,7 +115,7 @@ pub fn base_tool_specs() -> Vec<McpToolSpec> {
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 \
- (case-insensitive, any order; punctuation does not matter). Use this \
+ (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 \
@@ -318,7 +318,7 @@ fn tree_browse_schema() -> Value {
"query": {
"type": "string",
"minLength": 1,
- "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."
+ "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."
},
"k": {
"type": "integer",
diff --git a/src/openhuman/memory/read_rpc/chunks.rs b/src/openhuman/memory/read_rpc/chunks.rs
index e67527cc6e..340c89ccbe 100644
--- a/src/openhuman/memory/read_rpc/chunks.rs
+++ b/src/openhuman/memory/read_rpc/chunks.rs
@@ -92,8 +92,9 @@ async fn list_chunks_page(
let (rows, total) = if tokens.len() > 1 {
let mut unpaged = query.clone();
unpaged.content_contains = None;
- // Keep every provider scan bounded before intersecting the results.
- unpaged.limit = Some(limit as usize);
+ // Intersect the complete match sets before applying pagination. A
+ // provider page can otherwise hide rows that match every token.
+ unpaged.limit = None;
unpaged.offset = None;
let rows = token_and_details(chunks, &unpaged, &tokens, "list_chunks").await?;
let total = rows.len() as u64;
@@ -382,7 +383,13 @@ pub async fn search_rpc(
k: u32,
) -> Result<RpcOutcome<Vec<ChunkRow>>, String> {
let limit = k.clamp(1, MAX_LIST_LIMIT);
- let content_contains = query_tokens(Some(&query)).first().cloned();
+ let tokens = query_tokens(Some(&query));
+ let content_contains = if tokens.len() > 1 {
+ None
+ } else {
+ let trimmed = query.trim();
+ (!trimmed.is_empty()).then(|| trimmed.to_string())
+ };
// Captured before `query` is shadowed by the `ChunkQuery` below. The log
// line reports the length of the search TEXT, never of the built query, and
// it is deliberately the length rather than the text itself — a search term
@@ -404,10 +411,9 @@ pub async fn search_rpc(
// `content_contains` and a limit, and nothing else: no source predicate, no
// time window, no offset. `scope` is `None` for the same reason the listing
// passes `None` — the SQL this replaces carried no allowlist clause.
- let tokens = query_tokens(Some(&query));
let rows = if tokens.len() > 1 {
let query = ChunkQuery {
- limit: Some(limit as usize),
+ limit: None,
..Default::default()
};
token_and_details(chunks, &query, &tokens, "search")
diff --git a/src/openhuman/memory/schema/schema_schema_part_01.rs b/src/openhuman/memory/schema/schema_schema_part_01.rs
index 7eb8bcae6c..35baf23819 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: "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.",
+ comment: "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.",
required: false,
},
FieldSchema {
@@ -194,7 +194,7 @@ pub(super) fn lookup(function: &str) -> Option<ControllerSchema> {
FieldSchema {
name: "query",
ty: TypeSchema::String,
- 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.",
+ comment: "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.",
required: true,
},
FieldSchema {