Overview
Session Lifecycle: Create → Interact → Commit1
Create Session
Initialize a new conversation session with unique ID
2
Add Messages
Record user and assistant messages with multimodal content
3
Track Usage
Record which contexts and skills were used
4
Commit
Trigger compression and memory extraction
5
Compress
Archive older messages, keep recent N rounds
6
Extract Memories
Extract 6-category memories from conversation
7
Update Index
Vectorize and index extracted memories
Core API
Session Creation
add_message
Add conversation messages with multimodal content:used
Record context and skill usage:commit
Trigger compression and memory extraction:Message Structure
Message
Part Types
- TextPart
- ContextPart
- ToolPart
- ImagePart
Compression Strategy
Sessions automatically compress when the message count exceeds a threshold, keeping recent rounds while archiving older history.
Archive Flow
Auto-archive triggered bycommit():
1
Increment compression_index
Track which compression cycle this is
2
Copy messages to archive
Move older messages to archive directory
3
Generate structured summary
LLM generates summary of archived segment
4
Write L0/L1 for archive
Create abstract and overview for archived history
5
Clear current messages
Keep only recent N rounds in active session
Summary Format
Memory Extraction
OpenViking automatically extracts 6 categories of memories from conversations, updating user and agent knowledge bases.
6 Memory Categories
- User Memories
- Agent Memories
Extraction Flow
1
LLM Extract
Extract candidate memories from conversation
2
Vector Pre-filter
Find similar existing memories using vector search
3
LLM Dedup Decision
LLM decides: skip, create, or merge
4
Write to AGFS
Execute dedup decision
5
Vectorize
Index new/updated memories
Dedup Decisions
Candidate Decisions
Candidate Decisions
Item Decisions (Per-existing memory)
Item Decisions (Per-existing memory)
Example: Dedup Decision
Storage Structure
Session Directory
Memory Directories
Complete Example
Related Concepts
Architecture
System architecture and data flow
Context Types
6 memory categories explained
Extraction
Memory extraction pipeline
Retrieval
How memories are searched
