ADR 0125 — Separate memory, knowledge and history
- Status: Accepted (2026-10-28; Josh: hard rename, optional shared profile, phase order as written)
- Date: 2026-10-28
- Deciders: Josh Mabry; protoAgent maintainers
- Implementation: Phase 0 in #4553; Phase 1 (history) in #4556/#4557; Phase 2 (memories table, split budgets, tool rename, shared profile) in #4630; Phase 3 in #4631.
- Builds on: ADR 0021 (extract, don't dump), ADR 0031 (knowledge backend seam), ADR 0041 (commons tier), ADR 0069 (delivery layer, trust tiers), ADR 0108 (D4 orthogonal memory attributes).
- Supersedes: ADR 0108 D4's "one table, orthogonal columns" model for memory rows.
Context
Every agent has one knowledge store: a SQLite chunks table (FTS5 plus vectors) that holds three different things:
- Memory: what the agent has learned about its operator and its work, such as preferences, decisions, standing rules and facts. It is small, should be curated, and is worth reviewing.
- Knowledge: reference material the operator gave it, such as books, PDFs, URLs and YouTube transcripts. It is large, read-only after ingest, and organised by collection.
- History: what happened. This covers compaction archives (#2784), retired-thread summaries (
conversation_harvest) and background job reports (ADR 0070 D2). It is written automatically, grows without bound, and the checkpointer and trajectory already hold the source.
They share one search path. ADR 0069 and 0108 handled the overlap by adding columns (memory_kind, source_type, delivery_policy, namespace, review_state, epoch, expires_at, subject, tier, invalidated_at, …) on top of domain, which still mixes "what kind of row" with "which bucket". Every reader and writer has to get about 12 fields right, and the default search covers all three layers.
Evidence (live fleet, 2026-10-28)
What the stores hold:
| Agent | Rows | History | Memory | Knowledge |
|---|---|---|---|---|
| managingEditor | 3,048 | 3,041 | 7 | 0 |
| protoEngineer | 1,505 | 1,218 | ~80 | 153 (claude-import) |
| jobCoach | 1,025 | 887 | ~70 | 38 |
| necroMunda | 1,218 | 5 | 2 | 1,211 (rulebooks) |
What automatic retrieval injected into prompts over the previous 7 days (injection log, ADR 0069 D6):
| Agent | Turns | Share of RAG hits that were history |
|---|---|---|
| managingEditor | 758 | 99% |
| jobCoach | 56 | 73% |
| protoEngineer | 210 | 59% (plus 34% claude-import) |
managingEditor writes about 170 archive rows a day from its scheduled-wake thread. Each turn's top-k retrieval then returns copies of its own wake prompt.
How agents use the memory tools (live checkpoints, ~350 threads across 10 agents): about 60 memory_ingest, 54 memory_recall and 45 recall_session calls in total. Most of what they save is work status, such as "v0.218.1 cut end to end by me", "#4318 merged at head cac39166" and "bd-8cfo is being split". That status belongs on the board or the issue, and it goes stale within days.
Stale facts are never reconciled. jobCoach has two live rows on the same subject: an extracted fact from 10-15, "Josh's minimum acceptable base compensation is $185K", and an always-on note from 10-16, "Comp floor $120K base (was $185K)". The extractor and the agent's own writes never meet, and nothing supersedes the older row.
Decision
D1 — Three stores, not one table
| Layer | Holds | Written by | Store |
|---|---|---|---|
| Memory | Preferences, decisions, standing rules, facts about the operator, projects and environment | The agent, deliberately; the extractor proposes; the operator reviews | memories table, core SQLite (FTS5 plus vectors) |
| Knowledge | Ingested documents in named collections; private plus commons tiers (ADR 0041) | knowledge_ingest and operator uploads only | chunks; still the ADR 0031 KnowledgeBackend seam |
| History | Compaction archives, thread summaries, job reports | The runtime, automatically | history table, core SQLite (FTS5 only, no embeddings) |
| Skills | How to do things | Unchanged (ADR 0060) | Unchanged |
Each store has its own schema with only the fields it needs:
- Memory:
kind(profile / standing / fact / decision),subject,content,delivery(always / retrieved / on_demand),review_state,provenance(operator / agent / extracted),scope(namespace),valid_from,superseded_by,expires_at,source_session. There is nodomain. - Knowledge:
collection(replacesdomain),source(URL or path),title,media_type,tier,ingested_at, chunk position. - History:
session_id,surface(chat / background / a2a / scheduled),kind(archive / summary / report),span_start,span_end,content.
Episodic memory (ADR 0021's "what happened") is history. Agents reach it with session_search and recall_session; it is not memory.
D2 — Only memory and knowledge reach the prompt unasked
The projected context (ADR 0108 D1) has these parts:
- Always-on memory:
delivery=alwaysrows, capped as hot memory is today. - Retrieved memory: top-k from
memories. - Retrieved knowledge: top-k from
chunks, cited by collection and source. - The prior-sessions digest: an index of history (session ID, date, topic; ADR 0069 D1), never its content.
Memory and knowledge get separate budgets and separate labelled sections. A 1,200-chunk rulebook can no longer push out the agent's three standing rules, and the reverse holds too. History content never auto-injects. Phase 0 (#4553) already enforces this on the current single table.
D3 — One tool family per layer
| Layer | Tools |
|---|---|
| Memory | memory_save, memory_search, memory_list, memory_forget |
| Knowledge | knowledge_ingest, knowledge_search |
| History | session_search, recall_session |
memory_save replaces memory_ingest. "Ingest" means fetching a document, which is what knowledge_ingest does. memory_recall becomes memory_search and covers memory only. This is a hard rename with no aliases: the old names are removed in the same release, and bundled skills and SOULs that name them are updated in that PR. This follows the no-legacy rule for fleet floors.
2026-11-07 refinement (upgrading): configs, plugins and stored rows written before the rename still carry the old names, and a list naming a tool that doesn't exist matches nothing without saying so. Until #4555 closes, graph/tool_renames.py translates the old names wherever a tool-name list is read, with one WARNING per source and name: tools.disabled, tools.hidden, tools.subagent_only, tools.deferred.keep, operator_mcp.tools (and the sidecar's OPERATOR_MCP_TOOLS), enforcement.disallowed_tools, enforcement.rate_limits keys, the execute_code tools/extra_tools bridge lists, subagent tool lists, and the stored tool fences on scheduled and background jobs. Boot (and each reload, for new sources) also logs one WARNING per SKILL.md file, subagent prompt or tool list, and SOUL.md that still names an old tool, so the operator can see which plugins need an update before the translation is removed. The old names are still never registered as tools.
D4 — Saving a memory checks for the same subject
memory_savewith asubjectreturns the live memories already on that subject.- If the new row has the same
subjectandkindas an existing one, it supersedes the older row (superseded_by). The older row stays for audit and is never delivered. - The agent sees what it replaced in the tool result, so a wrong supersession is visible and the operator can revert it from the inspector.
This is deterministic: no LLM reconciles at write time. That keeps ADR 0069's finding that write-time LLM reconciliation is a trap.
The retirement extractor writes through the same funnel as provenance=extracted, review_state=pending. An extracted fact therefore supersedes, or is superseded by, the agent's own row on the same subject, which fixes the $185K/$120K case.
D5 — Work status is not memory
The tool description and the operating model say what is worth saving: things that will still be true and useful in a month. Release logs, PR states and card progress live on the board, issues and PRs, where they stay current. If a memory_save call looks like a status line (a PR, card or SHA reference with a past-tense event and no subject), it still saves but returns a nudge. It is not refused.
2026-11-08 refinement (refuse, Josh: "PR the fixes"): the nudge did not stop it. An audit of protoEngineer found 48 of its 225 memories were release cuts ("release v0.231.0: I cut …") and PR-progress logs ("I verified PR558 merged with seven passing checks …"). The recent ones each carry a fresh subject, so the nudge never fired and D4 never retired one. memory_save now refuses a save whose opening sentence reads as a work-status log (a release cut, a PR/card step the agent narrates, a CI or QA state on a work reference, a triage outcome or board progress, or the original subject-less reference-plus-event line), and says where that fact already lives (the git tag and release PR, the PR's checks, the board). An opening that leads with a lesson or rule marker ("Lesson:", "Rule:", "Correction", "never", "always", …) is not status and still saves, even when it cites a PR. Against that agent's rows the detector refuses 45 of the 48 status logs and none of its other 56 agent-written memories. The same audit found the retirement extractor had mined 121 facts from peer-agent and /v1 threads (recording the peer as "the user"); facts are now extracted only from threads whose last turn was an authenticated operator chat turn (operator_chat_turn).
D6 — Migration
2026-11-07 refinement: rows are routed by source_type, not by domain name, and the Phase 2 backup is agent.db.pre-0125-p2.
A one-shot migration runs at boot and is idempotent (_kb_meta marker). It routes each existing row as follows:
| Existing row | Goes to |
|---|---|
domain = conversation (archives, harvest, background reports) | history |
source_type is ingest / url / youtube / pdf / text / file, or a non-memory freeform domain (necromunda-core, claude-import, …) | chunks, with collection set to the old domain |
Everything else (hot, preferences, fact, context, general written by the agent) | memories, with kind from memory_kind and delivery=always for hot |
The pre-migration database is kept as agent.db.pre-0125 until the next release. The console's Memory inspector reads memories, its Knowledge browser reads chunks, and a History tab reads history.
D7 — An optional shared operator profile
Memory is per agent, but who the operator is (name, timezone, how they like to work, standing preferences) is the same for every agent on the box. Re-teaching each agent is how the fleet drifts apart.
- Store.
<commons.path>/profile.dbuses thememoriesschema, next to the knowledge commons (ADR 0041). It holdskind=profileandkind=standingrows about the operator only, never project facts. - Opt-in per agent. It is off by default:
memory.shared_profile: truein the agent's config (Settings → Memory). A sandboxed or client-facing agent never sees the operator's profile unless it is switched on. - Delivery. For an opted-in agent, confirmed shared rows join always-on memory (or retrieved memory, by their
delivery) under their own label, "Operator profile (shared)". If an agent's private row has the samesubjectandkind, the private row wins for that agent. That lets one agent keep a deliberate local exception. - Writes.
- The operator edits the shared profile directly in the console, and those rows start
confirmed. - An agent proposes with
memory_save(..., shared=True). The row lands in the shared store asreview_state=pendingand reaches no agent until the operator confirms it. This is the same promotion rule as the knowledge commons: curated, never automatic. - D4 supersession applies within the shared store, so a confirmed replacement retires the older shared row for every agent at once.
- The operator edits the shared profile directly in the console, and those rows start
- Migration. Nothing moves automatically. After Phase 2, the review pass (Phase 3) offers each agent's
kind=profilerows as shared-profile candidates, de-duplicated bysubject, for the operator to confirm.
D8 — Out of scope
- Sharing anything beyond the operator profile: project memory stays per agent; knowledge already has the commons tier.
- Memory evals (LongMemEval subset): wanted, but tracked separately.
Phases
- #4553: history rows stop auto-injecting (shipped on the current table).
- History store: add the
historytable, point compaction, harvest and job reports at it, migratedomain=conversationrows, and movesession_searchandrecall_sessiononto it. - Memory/knowledge split: add the
memoriestable, migrate, split retrieval and budgets (D2), rename the tools (D3), split the console inspector, and add the optional shared profile store (D7). - Better memory use: subject supersession (D4), status-line guidance (D5), the extractor through the memory funnel, and a review pass over each agent's migrated memories with the operator, including shared-profile candidates (D7).
Consequences
- Retrieval sees only memory and knowledge. On today's fleet that is 1–10% of rows, so auto-injected context gets smaller and more relevant.
- Each layer's schema shows its intent. Nothing has to remember that
domain="hot"means always-on, or thatdomain="conversation"is history. - History is no longer embedded, which stops the embedding cost on ~170 rows a day per busy agent.
- A plugin
KnowledgeBackend(ADR 0031) now backs only knowledge. Memory and history are core SQLite, so a vector-DB plugin can no longer hold the agent's memory. That is deliberate: memory is small and needs review. - One breaking rename (D3) touches bundled skills and agent SOULs that name
memory_ingestormemory_recall.