Case study · 26

Cairn AID-OS

Making a local LLM into a development environment by treating it as a CPU, not a database.

The problem. Every local LLM I tried had the same shape: stateless, session-bound, and amnesiac. You ask it to build a feature, it builds something, you close the browser, and tomorrow it has forgotten everything — the file layout, the decisions, the bug you fixed last week. The context window was the ceiling, and the ceiling was low.

The approach. Cairn treats the model as a CPU, not a database. The context window is RAM: fast, small, volatile. Everything else — files, decisions, task state, memory — lives on disk and gets re-assembled into the prompt every turn. The agent reads AID.md (current state), PROJECT.md (architecture), ROADMAP.md (plan) and checkpoint.json (task graph), plus a semantic recall of past memories from SQLite. It never has to remember anything in advance, because it can always ask.

Under the hood: a real PTY for the terminal (node-pty, not a fake shell), headless Chromium via Playwright for browser tasks, SQLite with local embeddings for long-term memory, a permission gate that classifies every shell command as allow / confirm / block, and a task DAG so multi-step work has a shape. A small router picks a coder model or a reasoning model depending on the ask, keeping only one chat model in VRAM at a time.

The outcome. You can close the browser for a week, come back, click Resume, and the agent continues from the exact task it was on. Memory persists. The whole thing runs offline, on consumer hardware, with zero API keys and no billing surface. It is open source under MIT at github.com/Had0o/cairn ↗.

What I would do differently. Push harder on model quality earlier. An 8B local model is genuinely capable, but it slides back into “helpful chat assistant” mode under pressure, and every hedge costs a turn. I would also design tool descriptions before writing the tools — a one-line wording change in the run_terminal description turned out to be the fix for an entire class of routing bugs.

← Back to work→