ADocumentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
MemoryStore is the storage backend for Memory. Definable provides three built-in implementations, from ephemeral in-memory stores for testing to file-based and SQLite backends for persistence.
Available Backends
| Backend | Import | Dependency | Best For |
|---|---|---|---|
InMemoryStore | definable.memory | None | Testing, ephemeral sessions |
SQLiteStore | definable.memory | aiosqlite (core) | Local dev, single-process |
FileStore | definable.memory | None | JSONL-based persistence, simple deployments |
Backend Examples
InMemoryStore
Ephemeral store for testing. Data is lost when the process exits.memory=True on an Agent or when you omit the store parameter:
SQLiteStore
The default choice for local development. Usesaiosqlite (included as a core dependency). Tables are auto-created on first use.
Path to the SQLite database file. Created automatically if it does not exist.
FileStore
JSONL-based file storage. Each session gets its own.jsonl file in the specified directory.
Directory where JSONL session files are stored. Created automatically if it does not exist.
MemoryStore Protocol
All backends implement theMemoryStore protocol. You can create custom stores by implementing these methods:
Method Reference
| Method | Description |
|---|---|
initialize() | Prepare the store (create tables, open connections). Called automatically by Memory on first use. |
close() | Release resources. Called by Memory.close() or the agent’s shutdown. |
add(entry) | Add a MemoryEntry to the store. |
get_entries(session_id, user_id) | List entries for a session, ordered by creation time ascending. |
get_entry(memory_id) | Fetch a single entry by its UUID. Returns None if not found. |
update(entry) | Update an existing entry (matched by memory_id). |
delete(memory_id) | Delete a single entry. |
delete_session(session_id, user_id) | Delete all entries for a session. |
count(session_id, user_id) | Count the number of entries in a session. |
MemoryEntry Data Type
Every store works withMemoryEntry objects:
| Field | Type | Default | Description |
|---|---|---|---|
session_id | str | — | Session this entry belongs to |
memory_id | str | None | Auto-generated UUID | Unique identifier |
user_id | str | "default" | User this entry belongs to |
role | str | "user" | Message role ("user", "assistant", "summary") |
content | str | "" | The message content |
message_data | dict | None | None | Optional structured message data |
created_at | float | None | Auto-set | Unix timestamp |
updated_at | float | None | Auto-set | Unix timestamp |
Choosing a Backend
| Scenario | Recommended Store |
|---|---|
| Unit tests, quick prototyping | InMemoryStore |
| Local development, single-process apps | SQLiteStore |
| Simple deployments, human-readable logs | FileStore |
SQLiteStore during development. The store is a constructor parameter, so swapping backends requires changing a single line: