Local-first agent runtime
Sage
A personal agent runtime in Rust that keeps its memory on my own machine, runs a tool only when a fail-closed gate allows it, and hands builds to a lifecycle checked with TLA+. Multi-agent manager supervision and live board wakeups are still in progress.
what it does
Memory stays on my machine
Local SQLite with a provenance rule for each kind of entry, recapped before context is compacted.
A build lifecycle a model checker reads
One state machine in TLA+; TLC catches all 12 deliberately broken TLA+ spec variants (runtime conformance is checked separately by boundary tests).
Rules live outside the persona
Hard policy is compiled separately, so the voice can change without the limits moving.
A tool runs only when the gate allows it
One fail-closed check per tool call; outbound actions drafted, confirmed and logged.
two stores, two gates
Memory
about me: Preference, Belief, Context, KbPointer
source · user_quote · expires_at · kb_claim_id
“belief memory requires user_quote provenance”
Knowledge base
about the world: atomic claims, each active, probationary, disputed or deprecated
source_pointer · source_quote · tier
“claim requires source_pointer and source_quote”
A memory may point at a claim. It never holds the fact itself.
“No truth laundering into memory.” ADR-0001

The problem
Hosted assistants forget what you told them yesterday, and everything you tell them leaves the machine. I wanted an agent that remembers context, works under hard safety rules, keeps its data at home, and is there on my phone and at my desk.
How it fits together
- Telegram, terminal, desktop to NATS message bus: “message”
- NATS message bus to Gateway, versioned protocol
- Gateway, versioned protocol to Prompt compiler: policy, persona, memory
- SQLite memory to Prompt compiler: policy, persona, memory: “recall”
- Prompt compiler: policy, persona, memory to llama.cpp, or a hosted model: “prompt”
- llama.cpp, or a hosted model to Fail-closed tool gate: “allowed calls only”
- llama.cpp, or a hosted model to Gateway, versioned protocol: “reply”
- Gateway, versioned protocol to SQLite memory: “captured, with provenance”
What I built
Memory lives in local SQLite, and each kind of entry has its own provenance rule. Every kind except a preference needs a source, a belief also needs the user’s words, a context entry needs an expiry, and a knowledge-base pointer needs the id of its claim. Each turn, the runtime captures what is worth keeping, recalls what is relevant, and writes a recap before old context is compacted.
Facts about the world go to a separate knowledge base of atomic claims, each with a pointer into its source and a quoted span. A memory can point at a claim but cannot hold one. A claim is active, probationary, disputed or deprecated; for now that status only orders retrieval, and nothing moves a claim from one state to another on its own.
I keep security rules and persona apart. A runtime policy layer holds the hard boundaries and is compiled separately from the persona prompt, so the voice can change without touching what the agent is allowed to do. Every tool call passes one fail-closed gate before it runs, and outbound actions go through allowlists, draft-then-confirm and an audit log.
Builds are the riskiest thing Sage starts, and Sage hands the work itself to Bob the Builder through its CLI. To remove drift across build paths, the lifecycle is consolidated into one write path and one gateway operation shared by CLI, web and chat, specified in TLA+ and model-checked with TLC against 12 deliberately broken TLA+ spec variants (runtime conformance is checked separately by boundary tests). Every merge to Sage’s main is attested against the exact git tree: changed-line coverage, plus mutation testing, a threat model and formal verification wherever the change triggers them.
My agents and I coordinate on Commons, a shared board with named identities and no private channels. It is one Rust binary whose CLI, HTTP API and MCP server are all derived from one operation table, so they cannot drift apart. A task is claimed under a lease, and every claim carries a fencing epoch, so an agent that wakes after its lease lapsed cannot overwrite the next holder’s work. The task model is checked in TLA+.
The delivery store grew without bound because replies to the CLI never got a delivery receipt. Only the Telegram connector listens for outbound messages, so every 30 seconds the recovery task replayed each CLI reply and recorded the attempt again. Replay now stops after three rounds without a receipt, and I made CLI replies count as delivered locally. To shrink the file, a script copies it into a new one that keeps only the history rows recording a state change, because deleting tens of millions of rows in place would have grown the write-ahead log to the size of the database.
It began in the shape of OpenClaw, the open-source assistant I used as a reference: a gateway with a versioned protocol and a NATS message bus. Then I cut hard. Of sixteen connector crates, most of them stubs, only Telegram stayed, because every connector is code to secure. The design now in progress puts a chief of staff over one manager per project, and a manager reviews each worker’s result before accepting it. Models run locally through llama.cpp or come from a hosted provider.
How it turned out
A working runtime on my own hardware, reached from Telegram, a terminal UI, a desktop app, a CLI and a web UI, with its memory kept at home and a local model available when nothing should leave the machine. Multi-agent manager hierarchy and Commons SSE/load tests are still in progress.
Written about it
- A shared board for my agents and meCommons is the board my agents and I work on together: named identities, leased tasks, one operation table for CLI, MCP and web, and no private channels.11 min read
- Done means used: wiring agent-built code end to endHow I keep an agent-built system wired end to end: done means integrated and used, a scoreboard whose bar only rises, and a review of what really runs.11 min read
- Memory that can’t launder a rumourFor multi-turn assistants with shared world knowledge, memory needs provenance, separate personal and world stores, and code write gates—smaller than a prompt’s promise, and only as strict as the code actually enforces.10 min read
Built with
- Rust
- SQLite
- NATS
- TLA+
- Tauri
- llama.cpp