Skip to main content

Memory Management & Optimization

Codebolt exposes the full memory stack as a programmable API surface. Agents, action blocks, and hooks can read and rewrite every part of the memory system at runtime — the ingestion pipelines that write data, the persistent memory definitions that retrieve it, the context rules that govern what reaches the LLM, and the raw storage in the vector store, knowledge graph, and KV store.

This section is for builders who need to go beyond the default behaviour — tuning how their agents learn, what they remember, and how efficiently context is assembled.

Architecture

The memory system has two main data paths — a write path that ingests and stores information, and a read path that retrieves and assembles it into LLM context. Both paths share a common set of storage layers.

The write path accepts events from application code, agent actions, or hooks. Each event flows through a configurable ingestion pipeline whose processors — chunker, vector_embed, llm_extract, parser, normalizer, or custom — transform the data before routing it to one or more storage layers.

The read path starts with a query and a set of scope variables. The context rule engine evaluates which persistent memory pipelines to activate (vector_search, graph_view_read, kv_get, log_search), executes them against the storage layers, and feeds the results into context assembly. The assembled context is what ultimately reaches the LLM.

The Memory Stack

Codebolt's memory system comprises nine components grouped into three categories: storage layers, a write path, and a read path.

Storage Layers

ComponentPurposeSDK ModuleUI PanelREST Base Path
Vector DBSemantic search over embeddingscodebolt.vectordbVector DB/vectorDB
KnowledgeDocument chunking and managementKnowledge/knowledge
Knowledge GraphTyped nodes, edges, and Cypher-like viewscodebolt.knowledgeGraphKnowledge Graph/kg
KV StoreFast namespaced key-value storagecodebolt.kvStoreKV Store/kvstore
Event LogImmutable event timelinecodebolt.eventLogEvent Log/eventlog
Episodic MemoryThread-based append-only event loggingcodebolt.episodicMemoryEpisodic Memory/memories/episodic
MemoryHuman-readable notes and recordscodebolt.memoryMemory/memories

Write Path

ComponentPurposeSDK ModuleUI PanelREST Base Path
Memory IngestionEvent-driven pipelines that transform and route data into storagecodebolt.memoryIngestionMemory Ingestion/memory-ingestion

Read Path

ComponentPurposeSDK ModuleUI PanelREST Base Path
Persistent MemoryDeclarative retrieval pipeline definitionscodebolt.persistentMemoryPersistent Memory/persistent-memory
Context AssemblyRule engine + multi-source context orchestrationcodebolt.contextAssemblyContext Assembly/context-assembly

What you can do at runtime

OperationAPI surface
Create or reconfigure an ingestion pipelinecodebolt.memoryIngestion
Add, update, or remove entries in any storage layercodebolt.kvStore · codebolt.vectordb · codebolt.knowledgeGraph · codebolt.memory
Modify persistent memory retrieval pipelinescodebolt.persistentMemory
Update context rules dynamicallycodebolt.contextRuleEngine
Assemble context on demand for any querycodebolt.contextAssembly
Record structured events to episodic memorycodebolt.episodicMemory
Trigger memory processing via lifecycle hooksHook system (.codebolt/hooks/)
Run arbitrary code in the ingestion pipelineCustom processors / action blocks
Measure and improve memory qualityEval & optimization system

Why agents modify their own memory

Static memory configurations work for predictable workflows. For agents that operate in varied or evolving environments, self-modifying memory is a better fit:

  • An agent learns a user's naming conventions mid-conversation and writes them to KV so future runs respect them without prompting.
  • An orchestrator discovers a sub-agent repeatedly failing on a class of task and writes a corrective heuristic to a persistent memory pipeline.
  • A long-running agent compresses its episodic history into vector embeddings after each session so context stays lean.
  • A quality-monitoring agent evaluates its own retrieval results and adjusts the topK and minScore of its vector search steps.

All of this is done through the same SDK that external code uses — agents are not privileged. The boundary is the storage layer, not the caller.

In this section

Component deep-dives:

  • Vector DB — SQLite + sqlite-vec, hybrid search, AST-aware chunking
  • Knowledge — document management, 6 chunking strategies
  • Knowledge Graph — Kuzu DB, schema templates, Cypher-like views
  • Persistent Memory — declarative retrieval pipelines, 21 step types
  • KV Store — namespaced key-value storage, query DSL
  • Memory Ingestion — event-driven write pipelines, 8 processors, 5 destinations
  • Context Assembly — rule engine, parallel retrieval, token budgeting

SDK & automation:

Quality & optimization:

Visual management: