OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug] Inconsistent abstract size limits: _enforce_size_limits caps at 256 chars but _truncate_abstract_bytes caps at 50,000 bytes

Open wyl1988 opened this issue 4 months ago • 1 comments

Bug Description

OpenViking has two different abstract truncation limits that apply at different points in the pipeline, creating an inconsistency:

  1. SemanticProcessor._enforce_size_limits (in semantic_processor.py line 1172-1178): Caps directory-level abstracts at abstract_max_chars = 256 characters for .abstract.md files.

  2. _truncate_abstract_bytes (in embedding_utils.py line 32-40): Caps the abstract scalar field at _ABSTRACT_MAX_BYTES = 50,000 bytes (≈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

  1. Create a memory file with a large summary (>5KB)
  2. Observe that _truncate_abstract_bytes allows up to 50KB
  3. Trigger a search that retrieves this file
  4. The file's abstract field (up to 50KB) is returned in RETRIEVAL_OUTPUT_FIELDS
  5. 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

wyl1988 avatar Jul 04 '26 04:07 wyl1988

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_bytes keeps up to 50,000 bytes because that is a vector-store encoding guard, not a reranker quality budget.
  • HierarchicalRetriever._rerank_scores forwards 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.

huangruiteng avatar Jul 15 '26 07:07 huangruiteng