[Bug] Embedding pipeline does not chunk oversized files — files exceeding embedding model ctx-size fail silently
Bug Description
When OV's embedding pipeline encounters a file that exceeds the embedding model's context window, it does not chunk the file. Instead, it attempts single-shot embedding, which fails with a 400/500 error from the embedding server. The file is then never vectorized — it becomes a "dead memory" that exists on disk but is never searchable via viking_search.
Issue #731 reported the error symptom ("Input sequence length exceeds max input length") and was closed, and issues #530/#531 discussed chunking strategy. However, in the current release (0.4.5+), files exceeding the embedding model's context window still fail silently — there is no automatic chunking for memory file vectorization.
Impact
In our deployment with Qwen3-Embedding-4B (ctx=2560):
- 22+ memory files exceed 2560 tokens at time of writing
- Each of these files triggers embedding 400/500 errors
- Errors accumulate in
.failed.jsonfiles - The files are permanently unsearchable unless manually chunked
There is a time gap problem too: new large memory files are written by session extraction at any time, but our chunking cron runs only once daily at 04:00. Files written at other times remain broken for hours.
Reproduction
- Configure OV with a local embedding model that has a limited context window (e.g., ctx=2560)
- Have a session that produces a large memory file (>2560 tokens)
- Observe embedding errors in OV logs:
Input sequence length exceeds the max input length - Try
viking_searchfor content from that file — it will not return
Workaround Applied
We wrote ov-memory-chunker.py (runs daily via cron at 04:00) to:
- Scan all memory files for oversized entries
- Split them using paragraph-then-line strategy
- Each fragment gets a
_c01,_c02suffix - OV then re-embeds the fragments
This produces 509+ chunk fragments in our deployment — 40% of all memory files. The fragments lack standalone semantic completeness.
Expected Behavior
OV should either:
- Chunk automatically: Split files exceeding the embedding model's context window before vectorization, similar to how resources are handled
- Truncate with warning: If chunking is not feasible, truncate the input and log a warning instead of failing silently
- Expose config: Allow
embedding.max_input_tokensinov.confto control chunking behavior
Environment
- OpenViking: 0.4.5+
- Embedding: Qwen3-Embedding-4B Q6_K GGUF (local, ctx=2560)
- 22+ oversized files, 509+ chunk fragments from manual chunking
Thanks for reporting this!
This path goes through the main embedding queue, and current OpenViking bounds provider-facing embedding input via embedding.max_input_tokens. For a local model with ctx=2560, please set this below the model context window, for example:
{
"embedding": {
"max_input_tokens": 2048
}
}
This is a truncation guard, not automatic chunking. After updating the config, please reindex or retry the affected memory files so previously failed entries can be embedded again.