This guide describes how agent memory, tasks, messages, and runtime state persist across restarts in dist_agent_lang. Persistence is on by default — no setup required. This guide covers configuration, backends, and troubleshooting.
When you run dal agent serve or execute agent DAL
scripts, the agent accumulates state: key-value memory, pending tasks,
queued messages, evolution data, and registered skills. By default, all
of this is saved to disk after every change and restored automatically
when the process restarts.
This means:
store_memory) carries
across sessions.Conversation history (evolve) is already file-based and unaffected by this system.
| State | Persists? | Location |
|---|---|---|
| Conversation / context | Yes (already) | evolve.md |
| Agent memory (key-value) | Yes | Snapshot file or SQLite |
| Task queue | Yes | Snapshot file or SQLite |
| Message bus | Yes | Snapshot file or SQLite |
| Evolution store | Yes | Snapshot file or SQLite |
| Agent contexts (registry) | Yes | Snapshot file or SQLite |
| Runtime-registered skills | Yes | Snapshot file or SQLite |
| Serve agent ID | Yes | Snapshot file or SQLite |
| Variable | Default | Description |
|---|---|---|
DAL_AGENT_RUNTIME_PERSIST |
1 (enabled) |
Set to 0 or false to disable |
DAL_AGENT_RUNTIME_BACKEND |
file |
file for JSON, sqlite for SQLite |
DAL_AGENT_RUNTIME_PATH |
auto-derived | Override the snapshot path |
[agent]
runtime_persist = true # false to disable
runtime_path = ".dal/agent_runtime.json" # override pathThe snapshot path is resolved in this order:
DAL_AGENT_RUNTIME_PATH env var (used
directly if set)[agent] runtime_path in
agent.toml or dal.toml (resolved relative to
cwd if not absolute).dal/agent_runtime.json (file
backend) or .dal/agent_runtime.db (SQLite backend) under
the current working directoryagent_runtime.jsonagent_runtime.db--features sqlite-storageSelect the backend:
# File backend (default)
export DAL_AGENT_RUNTIME_BACKEND=file
# SQLite backend
export DAL_AGENT_RUNTIME_BACKEND=sqliteWhen the agent runtime is first accessed, the persistence layer:
If the file is missing, the runtime starts empty (no error). If the file is corrupt, a warning is logged and the runtime starts empty.
Every mutation triggers an immediate save:
The snapshot includes a version field (currently
1). If you upgrade to a newer version of dist_agent_lang
that changes the schema, the runtime automatically migrates old
snapshots. Snapshots from a newer version than the runtime
supports are rejected (runtime starts empty with a warning).
To opt out of persistence entirely:
export DAL_AGENT_RUNTIME_PERSIST=0Or in agent.toml:
[agent]
runtime_persist = falseWhen disabled:
Copy the snapshot file:
cp .dal/agent_runtime.json .dal/agent_runtime.json.bakFor SQLite:
cp .dal/agent_runtime.db .dal/agent_runtime.db.bakIf the snapshot is corrupt:
The JSON snapshot is human-readable:
cat .dal/agent_runtime.json | python3 -m json.toolFor SQLite:
sqlite3 .dal/agent_runtime.db "SELECT data FROM agent_runtime_snapshot WHERE id = 1" | python3 -m json.tool| Symptom | Cause | Fix |
|---|---|---|
| State lost after restart | Persistence disabled | Check DAL_AGENT_RUNTIME_PERSIST and
agent.toml |
| "Corrupt snapshot" warning | Invalid JSON or schema mismatch | Delete or restore snapshot from backup |
| "Version > supported" warning | Snapshot from newer dist_agent_lang | Upgrade dist_agent_lang or delete snapshot |
| Permission errors | Cannot write to .dal/ |
Check directory permissions |
| SQLite errors | Missing sqlite-storage feature |
Rebuild with --features sqlite-storage |
src/stdlib/agent_persist.rs — Persistence
implementationsrc/stdlib/agent.rs — Agent runtime with integrated
persistence