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(memory): token-AND keyword search instead of whole-phrase LIKE
Nocturnal6e4162461ccb
diff --git a/src/openhuman/mcp/server/tools/specs.rs b/src/openhuman/mcp/server/tools/specs.rsindex 2958356f09..044da417ef 100644--- a/src/openhuman/mcp/server/tools/specs.rs+++ b/src/openhuman/mcp/server/tools/specs.rs@@ -71,9 +71,17 @@ pub fn base_tool_specs() -> Vec<McpToolSpec> {McpToolSpec {name: "memory.search",title: "Search Memory",- description: "Keyword-search OpenHuman's local memory tree and return matching chunks ordered by recency.",+ 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.",rpc_method: Some("openhuman.memory_tree_search"),- input_schema: query_schema("Substring to match against stored memory chunks."),+ 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.",+ ),annotations: read_only_local_annotations(),},McpToolSpec {diff --git a/src/openhuman/memory/read_rpc/chunks.rs b/src/openhuman/memory/read_rpc/chunks.rsindex 9869230be2..999a308aa4 100644--- a/src/openhuman/memory/read_rpc/chunks.rs+++ b/src/openhuman/memory/read_rpc/chunks.rs@@ -93,8 +93,17 @@ pub(super) fn list_chunks_blocking(if let Some(query) = &filter.query {let q = query.trim();if !q.is_empty() {- where_clauses.push("c.content LIKE ?".into());- params_owned.push(Box::new(format!("%{}%", q)));+ // Tokenized AND-matching: every whitespace-separated token must+ // appear somewhere in the chunk, in any order. A literal phrase+ // still matches (all of its tokens appear), so this is a strict+ // superset of the old whole-phrase LIKE — which punctuation+ // could silently defeat: querying "Grade 4 Week 1" against a+ // chunk containing "Grade 4: Week 1" returned nothing, and an+ // agent concluded the email was never ingested.+ for token in q.split_whitespace() {+ where_clauses.push("c.content LIKE ?".into());+ params_owned.push(Box::new(format!("%{}%", token)));+ }}}diff --git a/src/openhuman/memory/read_rpc_tests.rs b/src/openhuman/memory/read_rpc_tests.rsindex a2d5590166..94d19e9e09 100644--- a/src/openhuman/memory/read_rpc_tests.rs+++ b/src/openhuman/memory/read_rpc_tests.rs@@ -190,6 +190,61 @@ async fn list_chunks_query_substring_works() {}));}+/// Regression: whole-phrase LIKE let punctuation defeat the search — querying+/// "Grade 4 Week 1" against a chunk containing "Grade 4: Week 1 Update"+/// returned nothing, and an agent concluded the content was never ingested.+/// Tokens now AND-match individually, in any order.+#[tokio::test]+async fn list_chunks_query_tokens_match_across_punctuation_and_order() {+ let (_tmp, cfg) = test_config();+ seed_chat_chunk(+ &cfg,+ "gmail-sync:ca_1",+ "Subject: School announcement: Grade 4: Week 1 Update",+ )+ .await;+ seed_chat_chunk(&cfg, "gmail-sync:ca_1", "different unrelated text").await;++ // The exact query that used to return zero hits.+ let punctuated = list_chunks_rpc(+ &cfg,+ ChunkFilter {+ query: Some("Grade 4 Week 1".into()),+ ..ChunkFilter::default()+ },+ )+ .await+ .unwrap()+ .value;+ assert_eq!(punctuated.chunks.len(), 1, "tokens must match through punctuation");++ // Order-independent: same tokens shuffled still hit.+ let shuffled = list_chunks_rpc(+ &cfg,+ ChunkFilter {+ query: Some("Week Grade Update".into()),+ ..ChunkFilter::default()+ },+ )+ .await+ .unwrap()+ .value;+ assert_eq!(shuffled.chunks.len(), 1, "token order must not matter");++ // AND semantics: an absent token still excludes the chunk.+ let miss = list_chunks_rpc(+ &cfg,+ ChunkFilter {+ query: Some("Grade 4 zeppelin".into()),+ ..ChunkFilter::default()+ },+ )+ .await+ .unwrap()+ .value;+ assert!(miss.chunks.is_empty(), "every token must be required");+}+#[tokio::test]async fn list_chunks_filters_by_source_kind_and_applies_limit_offset() {let (_tmp, cfg) = test_config();diff --git a/src/openhuman/memory/schema/definitions.rs b/src/openhuman/memory/schema/definitions.rsindex 4f50e356db..6b0572ab2e 100644--- a/src/openhuman/memory/schema/definitions.rs+++ b/src/openhuman/memory/schema/definitions.rs@@ -197,13 +197,16 @@ pub fn schemas(function: &str) -> ControllerSchema {"search" => ControllerSchema {namespace: NAMESPACE,function: "search",- description: "Keyword LIKE-search over chunk bodies. Cheap, deterministic; useful as a \- fallback when semantic recall is unavailable.",+ description: "Keyword search over chunk bodies: every whitespace-separated token must \+ appear in the chunk (case-insensitive, any order — punctuation between tokens \+ does not matter). Cheap, deterministic; useful as a fallback when semantic \+ recall is unavailable.",inputs: vec![FieldSchema {name: "query",ty: TypeSchema::String,- comment: "Substring to match against chunk content.",+ comment: "Space-separated keywords; each must appear in the chunk (any order). \+ Prefer a few short, distinctive tokens over long exact phrases.",required: true,},FieldSchema {