openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Memory tree keyword search is defeated by punctuation — whole-query LIKE with no tool-description warning

Open nocstah opened this issue 3 months ago • 0 comments

Summary

memory_tree keyword search matches the whole query as one literal substring, so ordinary punctuation defeats it — and the MCP memory.search tool description gives an agent no hint of that, leading it to a confidently wrong "content was never ingested" conclusion.

Problem

What happened vs expected: a Gmail sync ingested an email titled "School announcement: Grade 4: Week 1 Update" (fully stored, 63 embedded chunks). The assistant, asked about it, ran memory.search with the natural query Grade 4 Week 1 — zero hits, because the stored text has a colon (Grade 4: Week 1) and the query became a single content LIKE '%Grade 4 Week 1%'. The agent then reported the email "was never ingested and I can't fetch it live." Expected: a keyword query of ordinary words matches text containing those words regardless of intervening punctuation — or at minimum, the tool description warns that matching is exact-substring so the agent tries shorter needles or semantic recall before concluding absence.

Steps to reproduce:

  1. Ingest any content whose text contains A: B (e.g. Grade 4: Week 1).
  2. Call openhuman.memory_tree_search (or the MCP memory.search tool) with query A B (Grade 4 Week 1).
  3. Zero results, despite the content being present and embedded.

Version/platform: v0.63.x, all platforms (the LIKE construction in src/openhuman/memory/read_rpc/chunks.rs).

Solution (optional)

Tokenize on whitespace and AND the tokens as independent LIKE clauses (any order). This is a strict superset of current matching — a literal phrase still matches, since all of its tokens appear — so no existing query loses results. Also make the tool/schema descriptions state the semantics and steer agents toward short tokens or memory.recall before concluding content is missing. PR attached.

Acceptance criteria

  • [ ] Repro gone — Grade 4 Week 1 matches a chunk containing Grade 4: Week 1 Update; shuffled token order also matches; a query containing an absent token still returns nothing.
  • [ ] Regression safety — tests pin punctuation-crossing, order independence, and AND semantics.
  • [ ] Diff coverage ≥ 80% — the fix PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/ci-lite.yml).

Related

Fix PR to follow (same author). Sibling report: the MCP agent.run_subagent toolkit-binding gap that the same investigation surfaced.

nocstah avatar Aug 24 '26 13:08 nocstah