Documentation menu / searchSearch documentation →

Start here

Quick startConnect through MCPOpenCode native memoryOpenCode memory controllerMemory API & local models

Use the service

Memory & compactionMemory lifecycle controllerLocal agents & swarmsCLI referenceHTTP reference

Run a node

ConfigurationOperations & backupsLocal memory & ARM

Evidence

Performance & device targetsFull retrieval reportBenchmark methodologyEvaluation policyMemory benchmark notes

Build with us

Architecture & schemaTechnology & learning mapRepository maintenanceContributingSecurityWebsite & deploymentSearch & agent discoveryPrivate product measurementEngineering references

Project

Cleanup & release planRoadmapLocal AI memory: when instantKV fitsFeaturesChangelog

History

Verification history

Proposals

Distributed memory proposal

Use the service / single-node · source MVP

Memory & compaction

What to save before compaction and how to load it afterward.

View the diagram
Checkpoint, compaction and restoreFour stages: store reusable facts, commit a checkpoint with the goal and next step, clear the context, then restore the capsule and fetch the records it points to. The checkpoint identifier is held outside the context window so compaction cannot erase it.01 / CHECKPOINT LIFECYCLENO MODEL CALLS TO STORE OR RESTORECONTEXT WINDOWworking notestool output, draftsworking notesgoal · constraints · next stepclearedcapsule + recordsrestoredHELD OUTSIDE THE PROMPTcheckpoint idalpha/session/latest · revision · fetched by exact key after restart01 / STORESave what matters.facts, decisions and sourcesunder descriptive keys02 / CHECKPOINTSave the next step.goal, constraints, unfinishedwork, one transaction03 / COMPACTFree the context.wait until the save succeeds,keep the id outside the prompt04 / RESTORECarry on.load the capsule, fetch thedetails, pick up the task
capsule + latest pointer commit togetherrestore reports missing or changed references

This guide defines checkpoint saves and restores for HTTP and MCP clients. An agent stores facts as records and task state as a checkpoint. The API calls the checkpoint’s short context note a capsule. The runtime keeps the checkpoint locator outside the prompt so compaction cannot erase it. The source MVP also supports structured memory with topics, tags and event time.

Memory record

Store small, independently useful JSON values under descriptive keys, for example projects/instantkv/decisions/storage-engine. A suggested value:

{
  "schema_version": 1,
  "kind": "decision",
  "content": "Use redb for the first single-node durable backend.",
  "source": { "type": "file", "locator": "docs/architecture.md" },
  "observed_at": "2026-10-01T08:00:00Z",
  "tags": ["instantkv", "storage"]
}

Suggested kinds are fact, decision, constraint, task and reference. The server adds a revision, write time and optional expiry. It validates JSON syntax, not factual accuracy. Ordinary records accept app-defined fields. Checkpoints use a defined schema.

Checkpoint → compact → restore

  1. Agent writes reusable knowledge as it works.
  2. Before compaction, agent creates a checkpoint with goal, summary, constraints, decisions, open_tasks, next_action, and optional references.
  3. Server validates the entire bundle and atomically commits it with the session’s latest pointer. It returns checkpoint ID, revision, and stable locator.
  4. Runtime keeps {namespace, agent_id, session_id, checkpoint_id} in its own durable session metadata. Credentials stay in its secret configuration.
  5. After compaction, runtime restores that checkpoint, injects the short capsule, and lets the agent recall detailed records on demand.

Essential task context stays in the checkpoint bundle. References contain a namespace, key and expected revision. Restore reports missing, expired or changed references. Ordinary keys are mutable; v1 does not retain historical values. Checkpoint bundles remain immutable until deletion.

Deletion removes retry history. Never reuse a deleted checkpoint ID.

The complete restore response must fit the caller’s byte budget. An insufficient budget returns an error; essential constraints are not silently removed. Optional details stay in references. The runtime uses its model tokenizer to set token budgets.

SettingLimit or default
Capsule16 KiB; at most 64 references
Complete bundleDefault cap 1 MiB; configurable downward
Restore responseDefault 32 KiB; accepted range 512 bytes–1 MiB

The local profile has a smaller 64 KiB HTTP body limit. Byte limits are not model token counts.

Operations

HTTP route under /v1/namespaces/{ns}MCP toolPermission
PUT /records/{encoded_key} with raw JSON + optional TTL, conditional ETagmemory_putput
GET /records/{encoded_key}memory_getget
GET /records?prefix=...&limit=...&cursor=...memory_listlist
DELETE /records/{encoded_key}memory_deletedelete
POST /checkpoints with bundle + expected latest revisionmemory_checkpointput
GET /checkpoints/{id} or /sessions/{agent}/{session}/latestmemory_restoreget
DELETE /checkpoints/{id}memory_delete_checkpointdelete

Encode a UTF-8 record key as one percent-encoded path segment. Key limits apply after decoding. Generic routes cannot change reserved checkpoint records. The current latest checkpoint cannot be deleted until a newer checkpoint exists.

Checkpoint namespaces require durable storage, no TTL and no eviction. Record lists return metadata: 100 items by default, at most 1,000. Cursor pages do not form a stable snapshot during writes.

MCP provides model-callable tools with input schemas. The adapter uses the official Rust SDK and tools specification. Not all runtimes provide a pre-compaction hook. Explicit tools and save/restore instructions provide the fallback.

Success criteria

After compaction and a server restart, the agent must recover the state needed to continue. That state includes the goal, constraints, decisions, pending work and source references. Tests must verify capsule content as well as retrieval latency. Storage tests do not establish real-model task success.