TOOL WIKI · MEMORY & STATE

SQLite

Stores structured records in an application-local database file.

Download example files Code + setup + checks in a ZIP
Jump to a section 10 sections

EXAMPLE USE CASE

Resume a local run from a stored checkpoint

A returning user’s preference or an unfinished run needs an explicit owner, storage lifetime and recall rule.

Input
Tenant a, run-104, step 2 and a packed-status payload.
Expected output
The same checkpoint after reopening the database.
  • Success check: A second run reopens the same database and reads step 2 with the packed payload.
  • Try a failure: The other tenant must have no row for this run ID.

Example scope: Actual file-backed persistence; a checkpoint is execution state, not a long-term inferred preference.

Official reference · SQLite

WHAT IT ISEmbedded database
WHERE IT FITSMemory & state
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
candidateretainqueryrecordscontextmaintainInteractionSubject + evidenceWrite policySelect and verifySQLiteEmbedded databaseRecall requestAuthenticated scopeContext builderRelevant selected factsLifecycle controlsCorrect, expire, delete
  1. Separate working conversation state from candidate long-term facts.

  2. Retain only permitted information and preserve where it came from.

  3. Local prototypes, desktop agents, and small persistent workflows. Plan for concurrency, backups, and the limits of the deployment environment.

  4. Use verified tenant and subject identifiers when retrieving memory.

  5. Choose useful records within the current context budget.

  6. Apply corrections and deletion to records, derived indexes, and caches.

SQLite

Local prototypes, desktop agents, and small persistent workflows. Plan for concurrency, backups, and the limits of the deployment environment.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

When to consider it

  • Local prototypes, desktop agents, and small persistent workflows.

A design decision to make

  • Plan for concurrency, backups, and the limits of the deployment environment.

Prerequisites and setup

  • Python 3.11+; sqlite3 is included in the standard library.
Shell
python3 -m venv .venv
source .venv/bin/activate

Try a small integration

memory.py

Python · memory.py
import sqlite3

con = sqlite3.connect("state.sqlite")
con.execute("CREATE TABLE IF NOT EXISTS checkpoints (tenant TEXT, run TEXT, step INTEGER, payload TEXT, PRIMARY KEY (tenant,run))")
with con:
    con.execute("INSERT INTO checkpoints VALUES (?,?,?,?) ON CONFLICT(tenant,run) DO UPDATE SET step=excluded.step,payload=excluded.payload",
        ("a","run-104",2,'{"status":"packed"}'))
row = con.execute("SELECT step,payload FROM checkpoints WHERE tenant=? AND run=?",("a","run-104")).fetchone()
assert row[0] == 2
assert con.execute("SELECT * FROM checkpoints WHERE tenant=? AND run=?",("b","run-104")).fetchone() is None
print(row)

Run and check the result

Shell
python memory.py
  • A second run reopens the same database and reads step 2 with the packed payload.
  • The other tenant has no checkpoint. A checkpoint records execution position, not an inferred long-term preference.

Common failures

  • Database locked: keep transactions short and understand SQLite’s single-writer behavior.
  • A process-local file is not automatically shared durable storage across serverless instances.

Production decisions

  • Define allowed memory types, evidence/provenance, correction, expiry and user deletion before accepting automatic writes.
  • Derive user and tenant scope from authenticated application state. Test cross-user recall, expired facts and deletion from every derived index.
  • Back up using SQLite-aware APIs; decide on WAL mode, busy timeouts, file ownership and a migration path before adding concurrent writers.

Keep exploring

A layered architecture for agent memoryA context pipeline for a long-running agent

Explore the same layer

Mem0LettaZepGraphiti

Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.