Skip to content

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

fix(read_rpc): return empty result for symbol-only queries

Steven Enamakelfa1b28bfdef8
diff --git a/src/openhuman/memory/read_rpc/chunks.rs b/src/openhuman/memory/read_rpc/chunks.rs
index e8d5efc773..d260bcef33 100644
--- a/src/openhuman/memory/read_rpc/chunks.rs
+++ b/src/openhuman/memory/read_rpc/chunks.rs
@@ -162,7 +162,15 @@ fn chunk_query_from_filter(filter: &ChunkFilter, limit: u32, offset: u32) -> Opt
}
}
- let content_contains = query_tokens(filter.query.as_deref()).first().cloned();
+ let tokens = query_tokens(filter.query.as_deref());
+ if filter
+ .query
+ .as_deref()
+ .is_some_and(|query| !query.trim().is_empty() && tokens.is_empty())
+ {
+ return None;
+ }
+ let content_contains = tokens.first().cloned();
Some(ChunkQuery {
source_ids: filter.source_ids.clone().unwrap_or_default(),
@@ -384,6 +392,12 @@ pub async fn search_rpc(
) -> Result<RpcOutcome<Vec<ChunkRow>>, String> {
let limit = k.clamp(1, MAX_LIST_LIMIT);
let tokens = query_tokens(Some(&query));
+ if !query.trim().is_empty() && tokens.is_empty() {
+ return Ok(RpcOutcome::single_log(
+ Vec::new(),
+ format!("memory_tree::read: search query_len={} n=0", query.len()),
+ ));
+ }
let content_contains = if tokens.len() > 1 {
None
} else {
diff --git a/src/openhuman/memory/read_rpc/chunks_tests.rs b/src/openhuman/memory/read_rpc/chunks_tests.rs
index 23ddc66e48..da8fd5d3f1 100644
--- a/src/openhuman/memory/read_rpc/chunks_tests.rs
+++ b/src/openhuman/memory/read_rpc/chunks_tests.rs
@@ -193,6 +193,15 @@ fn single_token_filter_uses_normalized_token() {
assert_eq!(query.content_contains.as_deref(), Some("phoenix"));
}
+#[test]
+fn symbol_only_filter_matches_nothing() {
+ let filter = ChunkFilter {
+ query: Some("++".into()),
+ ..ChunkFilter::default()
+ };
+ assert!(chunk_query_from_filter(&filter, 10, 0).is_none());
+}
+
// ── the wire shape ───────────────────────────────────────────────────────
/// `ChunkListRow` carries no body, and nothing is lost: the preview has always