Skip to main content
OpenViking uses a three-stage async architecture for document parsing and context extraction, separating fast parsing from slow semantic generation for optimal performance.

Overview

Design Principle: Parsing and semantics are separated. Parser doesn’t call LLM; semantic generation is async.
1

Parser

Parse documents, create file and directory structure (no LLM calls)
2

TreeBuilder

Move temp directory to AGFS, queue for semantic processing
3

SemanticQueue

Async bottom-up L0/L1 generation (uses VLM)
4

Vector Index

Index generated L0/L1 for semantic search

Stage 1: Parser

Parser handles document format conversion and structuring, creating file structure in temp directory.

Supported Formats

Core Flow

Smart Splitting

Parser automatically splits documents based on size:
This ensures each file is appropriately sized for LLM processing while maintaining document structure.

Example: Markdown Parsing

Input:
Output structure:

ParseResult

Stage 2: TreeBuilder

TreeBuilder moves temp directory to AGFS and queues semantic processing.

5-Phase Processing

1

Find document root

Ensure exactly 1 subdirectory in temp (the parsed document)
2

Determine target URI

Map base URI by scope
3

Recursively move directory tree

Copy all files from temp to AGFS
4

Clean up temp directory

Delete temp files
5

Queue semantic generation

Submit SemanticMsg to queue

Usage Example

Stage 3: SemanticQueue

SemanticQueue handles async L0/L1 generation and vectorization using VLM.

Processing Flow (Bottom-up)

Processing starts from leaf files and moves upward, aggregating child abstracts into parent overviews.

Single Directory Processing Steps

1

Concurrent file summary generation

Generate summaries for all files in directory (max 10 concurrent)
2

Collect child directory abstracts

Read generated .abstract.md from subdirectories
3

Generate .overview.md

LLM generates L1 overview from file summaries + child abstracts
4

Extract .abstract.md

Extract L0 from overview (first 1-2 sentences)
5

Write files and vectorize

Save to AGFS and create vector index entries

Configuration Parameters

SemanticMsg Structure

Code Skeleton Extraction (AST Mode)

For code files, OpenViking supports AST-based skeleton extraction via tree-sitter as a lightweight alternative to LLM summarization.
AST mode significantly reduces processing cost by extracting structural information without LLM calls.

Modes

Controlled by code_summary_mode in ov.conf:

What AST Extracts

Extracted skeleton:

Fallback Behavior

AST extraction automatically falls back to LLM when:
  • Language not in supported list
  • File has fewer than 100 lines
  • AST parse error occurs
  • Extraction produces empty skeleton
Fallback is automatic and logged. The overall pipeline continues without interruption.

Three Context Types Extraction

Different context types follow the same pipeline with different target URIs:

Complete Example

Architecture

System architecture and data flow

Context Layers

L0/L1/L2 model details

Storage

AGFS and vector index

Session

Memory extraction details