[Bug] VLM memory extraction copies verbatim content instead of distilling facts — 74KB skill definitions stored as single memory entries
Bug Description
When OV extracts memories from committed sessions, the VLM is supposed to distill conversation content into short, structured facts. In practice, the VLM often copies verbatim — entire skill definitions (74KB), experience reports (42KB), and empty template files (30KB) are written into memories/ as-is, without any summarization or distillation.
This was acknowledged in issues #530 and #531 (both now closed), but the underlying behavior persists in production.
Impact
-
Embedding failures: Files exceeding the embedding model's context window (e.g., >2560 tokens with local Qwen3-Embedding-4B) fail to vectorize entirely — they become "dead memories" that exist on disk but are never searchable.
-
Memory pollution: Skill definitions, full conversation logs, and template files dilute the memory space, making semantic search less precise for actual facts.
-
Manual maintenance burden: We had to write a custom chunking script (
ov-memory-chunker.py) to split oversized memory files, running daily via cron, just to keep the embedding pipeline functional.
Observed Files (examples)
| File | Size | Content |
|---|---|---|
skills/customs-wiki-review.md |
74KB | Full skill definition copied verbatim |
experiences/class_note_wiki_compilation.md |
42KB | Complete experience report with chat logs |
events/品目注释编译规范终稿确立.md |
31KB | Full document with no distillation |
profile.md |
30KB | Profile template, mostly empty |
Out of 1,365 memory files, 121 files are >5KB and 8 files are >9KB — far larger than what a memory entry should be.
Expected Behavior
The VLM extraction should produce short, structured memory entries (a few hundred bytes to ~2KB), distilling conversations into facts like:
- User preferences
- Configuration decisions
- Operational outcomes
- Key learnings
Not verbatim copies of entire documents.
Workaround Applied
We run ov-memory-chunker.py daily (cron at 04:00) to split files exceeding 2400 tokens. This is a workaround, not a fix — it produces semantic fragments that lose cross-file context.
Environment
- OpenViking: latest from PyPI (0.4.5+)
- VLM: GLM-4.7 via coding endpoint
- Embedding: Qwen3-Embedding-4B Q6_K GGUF (local, ctx=2560)
- ~1,365 memory files, 121 >5KB
Hi @wyl1988 Just to confirm, the main issue right now is that if certain memory files exceed 2560 tokens, it causes the embedding model to throw an error, right? Would truncating the input before embedding also solve this problem? Because strictly constraining the output size from the LLM tends to hurt the quality of the results.
@chenjw I rechecked this against current main (4847ffa3) and the embedding path already has a configurable input guard (embedding.max_input_tokens, included in v0.4.5 via #2266).
For the reported Qwen context limit of 2560, the current default of 4096 is still too high. A bounded reproduction gives:
- 3000 estimated tokens + default
max_input_tokens=4096: provider-limit failure - the same input +
max_input_tokens=2400: truncated before the provider call and succeeds (the suffix/estimator leaves the prepared input at about 2408 tokens, still below 2560) - preparing a 75 KiB input costs about 7.6 ms p95 in this local guard-only benchmark
So @wyl1988, could you try setting the top-level embedding config to leave headroom for the local model, for example:
{
"embedding": {
"max_input_tokens": 2400
}
}
This should address the immediate “file exists but cannot be embedded” failure for newly embedded/re-enqueued memories. It does not resolve the broader extraction-quality report: the current fallback is head truncation, and a fact near the tail can be lost. For that reason I do not think we should treat truncation as a complete fix or close this issue yet, and I am not proposing to restore the per-operation LLM repair logic from closed PR #3235.
If the 2400 setting removes the embedding errors, we can keep this issue focused on the remaining verbatim-copy / memory-pollution behavior and evaluate a smaller extraction-side change with quality evidence.
Thanks @chenjw @huangruiteng — sorry for the late reply, and yes, your confirmation is correct. Answers to both questions, with our current production config:
1. Truncating input before embedding solves it — we run exactly that, via a sidecar. Our deployment: OV → local truncating proxy (:8081) → llama-server (:8080) serving Qwen3-Embedding-4B-Q6_K locally. The proxy rejects/clips any request above the model context before it reaches llama-server, so oversized L2 files no longer 500 the embedding path. Since adding it, zero provider-limit failures.
2. We had NOT set embedding.max_input_tokens — we upgraded to 0.4.14+ and did not know the built-in guard had landed (the sidecar made the symptom invisible, so we never looked for an upstream fix). Just verified: our ov.conf has no embedding.max_input_tokens key. Given the default is 4096 and our local Qwen3-Embedding-4B context is 2560, the default would still be too high for us — we'll set it to 2400 (the same value huangruiteng validated above) and retire the sidecar if it holds.
One data point that may be useful for the docs: a max_input_tokens default of 4096 silently exceeds the 2560 context of the very model family your own examples use, so the failure only shows up as an opaque provider error. Either defaulting the guard to the model's declared context when available, or a startup warning when max_input_tokens > model context, would have saved us the whole debugging cycle.
We'll report back after switching to the built-in guard. Either way, feel free to close this as covered by #2266 if the guard is considered the fix — thanks for the clear triage.
Following up as promised in my last comment: the built-in guard is now enabled in our production deployment.
Config: "embedding": { "dense": { ... }, "max_input_tokens": 2400 } (top-level key next to dense), backing a locally served Qwen3-Embedding-4B (2560-token context).
Verified:
- The guard is present and wired in our current install —
models/embedder/base.pyresolvesmax_input_tokensfrom config and routes both the content-parts path and the plain-text path throughtruncate_embedding_input. - The config parses cleanly (
EmbeddingConfigaccepts the key;extra=forbidwould reject a misplaced one) and the server restarted on it without errors. - Zero provider-limit failures since enabling.
The truncating sidecar we ran in front of the embedding endpoint is still in the request path as a belt-and-braces layer; we plan to retire it after a soak window and will confirm here once it's out.
Reiterating the doc/UX point from my last comment, since it cost us a full debugging cycle: a startup warning (or provider-context-aware default) when max_input_tokens exceeds the model's declared context would surface this misconfiguration immediately. Thanks again @chenjw @huangruiteng for the confirmation and the validated value.
Follow-up on our 2026-09-30 report (local mitigation via embedding.max_input_tokens=2400): the guard has now run for a full week (2026-09-30 → 2026-10-09) with zero exceed_context_size errors on OpenViking 0.4.7 + local llama.cpp embedding server (Qwen3-Embedding-4B, ctx=2560). Based on this stable window we have retired our temporary truncation sidecar (a separate :8081 proxy) and pointed embedding.dense.api_base directly at the upstream embedding server. Health check, queue, and retrieval all verified green after the switch. Thanks for the kernel tag — happy to provide more data if useful.