Skip to content

Memory sections

A KAOS agent’s SessionMemory is divided into typed sections, each with its own token budget, priority, and eviction policy. Each turn, assemble_context() packs the highest-value content within budget — see memory as context assembly for the why.

SectionHoldsNotes
ROLEThe agent’s role/instructionsSnapshot
MESSAGESConversation turnsStreaming (JSONL); BM25 above threshold
ACTIONSTool calls and resultsStreaming; searchable
DOCUMENTSThe working corpusUnbounded; retrieval selects what enters context
FINDINGSVerified claims with citationsGrounded Cited[T] provenance
PLAYBOOKSLoaded recipesSnapshot
PLANThe current planFor plan-execute pattern
GRAPHA per-session RDF knowledge graphPROV-O + citations; Turtle-persisted
…and moreIntents, usage, scratch, summaries14 sections total

Each section declares:

  • budget_tokens — its share of the context window (0 = unbounded, e.g. DOCUMENTS).
  • priority — what’s trimmed first when the total budget is tight.
  • eviction_policyFIFO, LRU, LFU, PRIORITY, REFUSE, or NONE.

Below retrieval_threshold items (default 20), a section returns everything (FIFO). Above it, the agent switches to BM25 retrieval to select the most relevant items for the query — the production default (see why plain BM25).

Streaming sections append to JSONL; snapshot sections checkpoint as JSON; the GRAPH persists as Turtle. Memory hydrates from the VFS at turn start and persists at turn end — which is why a stateless agent feels continuous (and why tests must use KaosRuntime.test_mode()).