Skip to content

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

fix(memory): normalize punctuated single-token searches

Steven Enamakel353b028c19d0
diff --git a/src/openhuman/memory/read_rpc/chunks.rs b/src/openhuman/memory/read_rpc/chunks.rs
index 340c89ccbe..e8d5efc773 100644
--- a/src/openhuman/memory/read_rpc/chunks.rs
+++ b/src/openhuman/memory/read_rpc/chunks.rs
@@ -387,8 +387,7 @@ pub async fn search_rpc(
let content_contains = if tokens.len() > 1 {
None
} else {
- let trimmed = query.trim();
- (!trimmed.is_empty()).then(|| trimmed.to_string())
+ tokens.first().cloned()
};
// 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
diff --git a/src/openhuman/memory/read_rpc/chunks_tests.rs b/src/openhuman/memory/read_rpc/chunks_tests.rs
index e628c2cb4f..23ddc66e48 100644
--- a/src/openhuman/memory/read_rpc/chunks_tests.rs
+++ b/src/openhuman/memory/read_rpc/chunks_tests.rs
@@ -183,6 +183,16 @@ fn query_tokens_ignore_punctuation() {
assert!(super::query_tokens(Some(" ")).is_empty());
}
+#[test]
+fn single_token_filter_uses_normalized_token() {
+ let filter = ChunkFilter {
+ query: Some(" phoenix: ".into()),
+ ..ChunkFilter::default()
+ };
+ let query = chunk_query_from_filter(&filter, 10, 0).expect("a query");
+ assert_eq!(query.content_contains.as_deref(), Some("phoenix"));
+}
+
// ── the wire shape ───────────────────────────────────────────────────────
/// `ChunkListRow` carries no body, and nothing is lost: the preview has always