[Bug] Inconsistent abstract size limits: _enforce_size_limits caps at 256 chars but _truncate_abstract_bytes caps at 50,000 bytes
Bug Description
OpenViking has two different abstract truncation limits that apply at different points in the pipeline, creating an inconsistency:
-
SemanticProcessor._enforce_size_limits(insemantic_processor.pyline 1172-1178): Caps directory-level abstracts atabstract_max_chars = 256characters for.abstract.mdfiles. -
_truncate_abstract_bytes(inembedding_utils.pyline 32-40): Caps theabstractscalar field at_ABSTRACT_MAX_BYTES = 50,000bytes (≈16,000 Chinese characters) when vectorizing individual files.
The first limit (256 chars) applies only to L0 directory abstracts. The second limit (50KB) applies to all abstracts persisted to the vector store, including L2 file summaries. There is no intermediate limit for L1 overview-level abstracts (overview_max_chars = 4000).
Impact
The 256-char limit works correctly for L0 directory abstracts — they are short summaries and stay well under 256 chars. However, L2 file abstracts (stored as the abstract scalar in the vector index) can be up to 50,000 bytes.
When these L2 abstracts are retrieved in search results and passed to a reranker (see issue #3004), they far exceed the reranker's context window. The 256-char vs 50KB gap means:
- L0 abstract: ≤256 chars → reranker handles fine
- L1 overview: ≤4000 chars → reranker handles fine (within ctx=2560 for Chinese)
- L2 file abstract: up to 50,000 bytes → reranker cannot process, gets skipped or causes 500 errors
The hierarchy was designed so that rerankers only see L0/L1 abstracts (short summaries). But the vector store's abstract field for L2 files is effectively unbounded.
Steps to Reproduce
- Create a memory file with a large summary (>5KB)
- Observe that
_truncate_abstract_bytesallows up to 50KB - Trigger a search that retrieves this file
- The file's
abstractfield (up to 50KB) is returned inRETRIEVAL_OUTPUT_FIELDS - If this abstract reaches a reranker, it exceeds the context limit
Expected Behavior
The abstract size limits should be consistent across the hierarchy:
- L0: 256 chars (current — correct)
- L1: ~2000 chars (reasonable for a directory overview summary)
- L2: Should be capped at a size appropriate for retrieval/reranking, not 50KB
Or alternatively, RETRIEVAL_OUTPUT_FIELDS should truncate the abstract field at retrieval time before sending to the reranker.
Actual Behavior
L2 file abstracts can be up to 50,000 bytes in the vector store, while the L0 abstract limit is 256 chars — a 200x inconsistency.
Environment
- OpenViking: latest from PyPI (installed 2026-07-02)
- Storage: Local VikingFS
- ~1,365 memory files, of which 121 files are >5KB and 554 are chunker-generated fragments
Current-main triage confirms the underlying boundary mismatch, but the safe fix target is narrower than the issue title suggests.
Evidence on main (32acc6a3):
_truncate_abstract_byteskeeps up to 50,000 bytes because that is a vector-store encoding guard, not a reranker quality budget.HierarchicalRetriever._rerank_scoresforwards every non-empty abstract unchanged to the selected reranker. A deterministic probe with a 60KB abstract produced a 50,000-byte persisted value and a 50,000-byte reranker input.- The maintainer decision on related #3004 says L2 terminal results must still be reranked; skipping L2 would weaken ranking quality.
So I would keep this issue as a reranker-boundary problem rather than reducing the persisted abstract limit globally. A bounded implementation should define a provider-neutral rerank input budget (preferably token-aware, with a documented fallback), preserve L2 participation, and validate both ranking quality and fallback/error rate on oversized L2 abstracts. The existing rerank test suite passes on current main, but it currently has no oversized-input acceptance case.
I am not proposing a patch yet because the truncation policy needs a small representative benchmark first; otherwise an edge-case cap could silently trade away retrieval quality.