[Bug] v0.4.7 search/find and search/search rank raw messages.jsonl above real memory
[Bug] v0.4.7 search/find and search/search rank raw messages.jsonl above real memory
Summary
After upgrading from OpenViking v0.4.5 → v0.4.7 (skipping v0.4.6), the search/find and search/search endpoints return raw session messages.jsonl files (which should be internal transaction logs, not searchable content) as the top-1 results, pushing the actually-relevant memory items down to rank 2-5.
In v0.4.5, the same query returns the relevant memory items at rank 1 with no messages.jsonl entries in the top results.
Steps to Reproduce
Environment
- v0.4.5 (works correctly) —
pip install openviking==0.4.5 - v0.4.7 (broken) —
pip install openviking==0.4.7 --upgrade - Plugin:
2026.6.18(zip-installed client, unchanged across versions) - 797 points in
default__contextQdrant collection - 301 memories, 240 events, 25 entities, 23 preferences
- API mode:
auth_mode=trustedwithX-OpenViking-Account: default+X-OpenViking-User: mainheaders
Reproducer
API_KEY="ovmig-1781681967-31160" # from ~/.openviking/ov.conf
H="Authorization: Bearer $API_KEY
X-OpenViking-Account: default
X-OpenViking-User: main
Content-Type: application/json"
curl -s -X POST http://127.0.0.1:1933/api/v1/search/find \
-H "$H" -d '{"query":"OV upgrade","limit":5,"score_threshold":0.0}'
Expected (v0.4.5 output, correct)
1. [0.9958] OV升级补丁重打_20260703080837.md (trajectories)
2. [0.9813] OV 服务端 0.4.5→0.4.7 升级计划制定.md (events)
3. [0.9659] 升级后双重检查_20260701102236.md (trajectories)
4. [0.9365] OV多组件升级前盘点.md (events)
5. [0.9341] OpenClaw 升级到 6.9-beta.1.md (events)
All 5 results are relevant memory files (*.md). No raw session logs in the top-5.
Actual (v0.4.7 output, broken)
1. [0.9985] messages.jsonl (raw session transcript — internal log, NOT content)
2. [0.9978] events/.../PR 2619... (the actually relevant item, demoted to rank 2)
3. [0.9901] messages.jsonl (another raw log fragment)
4. [0.9876] trajectories/... (another relevant item)
5. [0.9851] profile.md
The first result is a messages.jsonl file from ~/.openviking/data/viking/... — these are internal session transaction logs, not curated memory.
Root Cause Analysis
Where the bug lives
The score-bucketing happens somewhere in the search pipeline between the vector store and the final ranking. v0.4.5 and v0.4.7 rerank code (openviking/models/rerank/openai_rerank.py) is byte-identical (4888 B, diff shows no changes), so the bug is not in the rerank client. It is in either:
- The retriever/hierarchical search that produces the initial candidate set, or
- The
storage/viking_fs.pydirectory walker (the file listing / scoring logic).
Why raw messages.jsonl gets surfaced
messages.jsonl is the raw session transcript file. It contains lots of repeated short tokens (system prompts, tool names, JSON blobs), so a vector embedding of the file as a whole document ends up with high cosine similarity to almost any natural-language query — but it is not a memory, it is a log. Treating it as a first-class content unit pollutes the top of the result list.
What changed in 0.4.7 (confirmed via diff v0.4.5 v0.4.7)
storage/viking_fs.pywas heavily refactored: 110,339 B → 160,081 B (+45% size, +1,427 diff lines)- New imports added:
time,ContextLevel,GrepEngine,TypeVar,GrepConfig - The directory walker / file enumeration logic was rewritten (multiple
excluded_prefix/excluded_pathpatterns were added in different functions) - The
read_batchoperation was changed fromasyncio.gather(concurrent) back to sequential read (regression of PR 2619) - The PR 2619 "empty documents filter" logic was removed from the rerank path
Hypothesis
The 0.4.7 vfs refactor changed the URI ↔ file path resolution such that:
messages.jsonlfiles inviking://user/main/memories/.../sessions/<sid>/messages.jsonlare no longer filtered out from the searchable file set- Or the abstract/embedding pipeline now embeds the raw JSONL blob as a single chunk with very high baseline similarity
Why this matters
- Auto-recall of OpenClaw plugin: The
auto-recall search timeoutin 0.4.7 happens becausemessages.jsonlreturns at the top means the model receives a raw JSON blob (potentially 50KB+ of system prompts + tool calls) as "context" instead of a real memory. The result is either a context-window blowup (timeout) or a model that hallucinates from the raw transcript. - No way to exclude: There is no
excluded_uri/exclude_prefixparameter onsearch/findorsearch/searchthat lets the caller filter out session internals (the underlying vfs code gained theexcluded_prefixparameter internally, but the API doesn't expose it).
Suggested Fix
- Exclude
messages.jsonland other internal session files from the searchable URI set inviking_fs.py's directory walker. The leaf filemessages.jsonlis referenced invfs.py:1943as part of an iteration that already implies these are not first-class content units. Add a filter at the URI-emission layer to skip them. - Or expose the
excluded_prefixparameter that 0.4.7 added to the internal vfs API on the publicsearch/findandsearch/searchendpoints, so callers can filter outviking://user/main/memories/.../sessions/at query time. - Re-apply PR 2619 — the empty-docs filter and concurrent
read_batchchanges are both still valuable, and 0.4.7 removed them. We are running the PR 2619 patch locally on 0.4.5 to work around the regression; the cleanest fix is to merge PR 2619 and rebase 0.4.7's vfs refactor on top of it.
Workaround (what we did)
Stayed on v0.4.5 with the PR 2619 patches re-applied locally:
# Patch 1: openai_rerank.py — empty docs filter (11 hunks)
# Patch 2: viking_fs.py — Tuple import + read_batch asyncio.gather
# 0.4.5 has asyncio.gather already in 2 places (line 1054, 1540) so patch 2 is mostly a no-op
cd /usr/local/lib/python3.12/dist-packages/openviking/
patch -p2 < /tmp/rerank.patch # 6 hunks, all clean apply
This restores the correct ranking. We will wait for a 0.4.8 release that includes the fix above before re-attempting 0.4.7.
System info
- OpenViking: 0.4.5 (working) / 0.4.7 (broken)
- OpenClaw: 2026.6.11 (e085fa1)
- OpenViking plugin: 2026.6.18
- Qdrant: 127.0.0.1:6333, default__context = 797 points
- OS: Linux 6.8.0-124-generic (Ubuntu 24.04 LTS) on VM100
- Vector store: Qdrant, dashscope
text-embedding-v4(2048-dim),Cosinedistance - Reproduced: 2026-07-03 16:08-16:21 CST
Update: narrowed down — NOT a rerank bug
刚跑了 0.4.5 vs 0.4.7 openviking/models/rerank/openai_rerank.py 的 diff,两个版本文件字节完全相同(都是 4888 B,一行没改)。所以问题不在 rerank 客户端,PR 2619 的 rerank 修复(non_empty_docs 过滤)在 0.4.5 / 0.4.7 都是缺失状态,但它不是 messages.jsonl 顶到 top-1 的元凶。
真正的重灾区在 openviking/storage/viking_fs.py:
- 体积 0.4.5: 110,339 B → 0.4.7: 160,081 B(+45%)
diff输出 1427 行(含 directory walker /excluded_prefix/excluded_path多处重构)- PR 2619 的
asyncio.gather并发read_batch被回退成顺序读 - 0.4.7 内部加了
excluded_prefix参数,但没暴露到search/find和search/search的 public API
我的新猜想:vfs 重构时,directory walker 列出 viking://user/main/memories/.../sessions/<sid>/ 子树时,没把 messages.jsonl 这类内部 session log 排除在可搜索 URI 集合外。messages.jsonl 全文嵌入后是个 50KB+ 的 JSONL 块,em 出来跟任意 query 余弦相似度都很高(重复 token 太多),就把真相关 memory 压到 rank 2+ 了。
如果维护者愿意查,建议直接看 viking_fs.py 里列出 viking://user/.../sessions/ 子目录时,过滤 leaf 文件(messages.jsonl / events.jsonl / tools/ / tool-results/)的那段循环——0.4.5 不知道为啥这套过滤是工作的,0.4.7 抽出来重了之后漏了一个 case。
我先按 issue 原 body 的 workaround 在本地 0.4.5 + PR 2619 patch 跑着,等 0.4.8 再试。