Skip to main content
Session manages the complete conversation lifecycle: message recording, context tracking, compression, and automatic memory extraction.

Overview

Session Lifecycle: Create → Interact → Commit
1

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

Compression Strategy

Sessions automatically compress when the message count exceeds a threshold, keeping recent rounds while archiving older history.

Archive Flow

Auto-archive triggered by commit():
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

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

Example: Dedup Decision

Storage Structure

Session Directory

Memory Directories

Complete Example

Architecture

System architecture and data flow

Context Types

6 memory categories explained

Extraction

Memory extraction pipeline

Retrieval

How memories are searched