How Reverie works
What Reverie keeps, who decides, how memory changes, and how your agent gets it back, in that order.
What gets remembered
Reverie keeps conclusions, not facts. Each one is the smallest self-contained piece of engineering understanding that could change a future decision.
That TokenManager.refresh() is called before cache.clear() is information. That cache invalidation must follow token refresh, because clearing the cache first serves stale tokens, is a conclusion.
Every candidate faces three questions. So what? Is it a conclusion, not a fact? Future session. Would knowing it change how an engineer approaches a future task? Independence. Is it understandable without the original conversation? Each record holds one conclusion, and a self-review pass rejects anything an engineer could get by reading the code. The extractor keeps conclusions and rejects facts, code descriptions, process steps and summaries. Zero is a valid output.
A kept conclusion is an Engineering Cognition Unit (ECU). It has one of eight types: implication, constraint, principle, decision, observation, pattern, invariant and trade-off. It has one of seven scope levels, from engineering to subsystem, plus a path: engineering, domain, organization, project, repo, module and subsystem. And it has one of six statuses: active, challenged, superseded, deprecated, open_question and archived.
Cache invalidation must follow token refresh; clearing the cache first serves stale authentication tokens.
- type
- invariant
- scope
- repo:myapp > module:auth
- confidence
- 0.67
- status
- active
- source
- debugging
- grounding
- auth/
token_manager.rs
auth/cache.rs @ d64d0e0 - symbols
- TokenManager::refresh
TokenManager::clear_cache
Past engineering understanding; verify against current code.
- 1Conclusion. One conclusion per record. Once accepted, its wording is never rewritten.
- 2Type. One of eight: implication, constraint, principle, decision, observation, pattern, invariant, trade-off.
- 3Scope. One of seven levels, from engineering to subsystem, plus a path. It sets how fast confidence fades, how retrieval ranks the record, and what deleting code retires.
- 4Confidence. Moved by evidence, in log-odds. Ranking uses the value after decay.
- 5Brain and status. The header shows the brain:
canonical · reviewedhere,session · unreviewedotherwise. Only active, challenged and open-question conclusions are retrieved. - 6Source. How the conclusion was reached. It sets the starting confidence: debugging starts higher than planning.
- 7Grounding. Files, symbols and the commit at extraction, checked against the repository.
- 8Related. Conclusions that support, contradict, depend on or replace this one come back with it.
- 9Framing note. Always attached: verify before acting.
implemented in: ec/extractor.py · ec/prompts/extractor_prompt.md
Who decides what’s kept
Reverie keeps two stores, called brains. The session brain is per repo and branch. What your agent concludes goes in at once, unreviewed, and ranks slightly lower than reviewed conclusions, so the current session benefits immediately. The canonical brain is reviewed, long-term and shared across projects.
The boundary is hard. Evidence about long-term conclusions waits as pending until its source is accepted.
When the session ends, you review in the terminal: open questions first, then accept, reject or skip, per group or per item. Skipped items carry into the next session.
The one exception. When your agent finds verified evidence about a conclusion it has just retrieved, it can update that conclusion straight away. This is reconsolidation, and the update is recorded on the conclusion. So: nothing extracted from a session becomes long-term memory until you review it, and reconsolidation is the documented exception.
The split came from a practical problem: one store either fills with noise or blocks in-session use. It later turned out to mirror a well-known account of biological memory, fast encoding and slow consolidation. Read the paper
- Your agentOpenCode · Claude Code, Cursor, Codex and other MCP agents: coming soon
- Session brain
- per repo and branch
- unreviewed, usable now
- relates new conclusions: supports / contradicts
- no decay
ec_observewrites here.ec_queryreads here.Evidence about long-term conclusions waits here as pending.
- Review
- open questions first
- accept →
- reject → discarded
- skip → next session
- Canonical brain
- shared across projects
- reviewed, long-term
- relates fully: supports / contradicts / supersedes / depends on
- confidence fades by scope
- weak conclusions can be superseded
ec_queryreads here.ec_reconsolidatewrites here directly, without review: it updates a conclusion the agent just retrieved, with verified evidence, and the update is recorded. - Maintenance, in the backgroundgrounding checks · open-question parking · supersession · reversal of evidence from retired conclusions
implemented in: ec/review_gate.py · ec/diffuser.py
How a conclusion changes
Confidence. A conclusion starts from a prior set by how it was reached and by its scope. Supporting conclusions raise it and contradicting ones lower it, in log-odds, weighted by similarity and by the other conclusion’s confidence. Every update is stored and can be reversed. Unused conclusions fade at a rate set by scope, and retrieval reinforces them.
Relationships. Conclusions relate in four ways: supports, contradicts, supersedes and depends_on.
Contradictions. A computable pre-check comes first, then adjudication. The existing conclusion is marked challenged, never hidden. After a scope-dependent time it becomes an open_question, and you choose: investigate, prefer one, mark both valid in different contexts, or archive.
Supersession. Accepted wording never changes. A new conclusion replaces the old one, which is frozen, kept and linked. Dependents of a weakened conclusion are challenged.
Step through one example below. A is the conclusion we follow; B supports it and C later contradicts it.
- A
- Cache invalidation must follow token refresh; clearing the cache first serves stale authentication tokens.
- B
- Token refresh must complete before any cache read in the auth middleware.
- C
- Since the session-store migration, token refresh no longer reads the cache; the ordering constraint no longer applies.
Step 1 · Extracted
A is extracted in a debugging session.
prior = base[source] × multiplier[scope] = 0.70 × 0.80
Step 2 · Accepted
You accept A at review. The full relating pass runs.
promoted with the same confidence
Step 3 · Supported
B is accepted later and classified as supporting A.
L′ = L + r × c_source · r = 0.78 (example), c_source = 0.52
The delta is stored on the edge, so the update can be reversed.
Step 4 · Retrieved
A is retrieved by a query.
L′ = L + 0.05
The decay clock resets.
Step 5 · Unused
Weeks pass and A goes unused.
effective L = L − λ × days (computed, never written)
The stored value stays. Only the value used for ranking falls, at the module rate.
Effective confidence after decay: computed from config
Step 6 · Contradicted
C is accepted and classified as contradicting A. A two-stage check judges the conflict genuine.
L′ = L − r × c_source · r = 0.84 (example), c_source = 0.61
Step 7 · Open question
The conflict outlasts the module’s time limit. Maintenance parks both A and C.
confidence frozen · retrieved at half weight
Step 8 · You decide
At review you choose to prefer C. A is kept and linked.
C: L′ = L + 0.05 · A is superseded by C
Branch · If code is deleted
Instead of steps 6 to 8: auth/cache.rs is deleted. At the next grounding check, A is deprecated, because at module scope any cited file gone retires it. Conclusions that depend on A are challenged.
scope module · retired when any cited file or symbol is gone
Step 1Extracted
A is extracted in a debugging session.
prior = base[source] × multiplier[scope] = 0.70 × 0.80
Step 2Accepted
You accept A at review. The full relating pass runs.
promoted with the same confidence
Step 3Supported
B is accepted later and classified as supporting A.
L′ = L + r × c_source · r = 0.78 (example), c_source = 0.52
The delta is stored on the edge, so the update can be reversed.
Step 4Retrieved
A is retrieved by a query.
L′ = L + 0.05
The decay clock resets.
Step 5Unused
Weeks pass and A goes unused.
effective L = L − λ × days (computed, never written)
The stored value stays. Only the value used for ranking falls, at the module rate.
Effective confidence after decay: computed from config
Step 6Contradicted
C is accepted and classified as contradicting A. A two-stage check judges the conflict genuine.
L′ = L − r × c_source · r = 0.84 (example), c_source = 0.61
Step 7Open question
The conflict outlasts the module’s time limit. Maintenance parks both A and C.
confidence frozen · retrieved at half weight
Step 8You decide
At review you choose to prefer C. A is kept and linked.
C: L′ = L + 0.05 · A is superseded by C
BranchIf code is deleted
Instead of steps 6 to 8: auth/cache.rs is deleted. At the next grounding check, A is deprecated, because at module scope any cited file gone retires it. Conclusions that depend on A are challenged.
scope module · retired when any cited file or symbol is gone
implemented in: ec/confidence.py · ec/maintainer.py · ec/reconsolidation.py
Grounded in your repository
The code has the last word. Each conclusion records the files, symbols and commit at extraction. In the background, Reverie checks them against your repository from time to time. Scope decides what a deletion retires, so principles survive and module-level conclusions don’t:
| Scope | Retired when |
|---|---|
engineering, domain | Never |
organization, project | All cited files are gone |
repo, module, subsystem | Any cited file or symbol is gone |
Conclusions that depend on a retired one are challenged, and you’re told at your next review. Being far behind HEAD is flagged, but it never retires anything.
implemented in: ec/grounding.py
How your agent gets it back
Your agent asks, after reading the code. Reverie doesn’t load memory at the start of a session. Our first version did, and on our benchmark the agent trusted memory over the code and did worse. EC-Bench
When your agent asks, in order:
- Reverie infers a task mode: debugging, implementation, investigation, planning or architecture.
- It searches both brains.
- It filters results by status, scope and relevance.
- It ranks them by similarity, confidence after decay, session activity and how connected a conclusion is.
- It groups each result with the conclusions that support, contradict or depend on it, or replace it, and fits everything into a budget that depends on the mode.
The agent receives the record in Fig. 3, with a framing note: past engineering understanding, verify against current code. One honest limit: agents don’t always ask when they should. Asking is an instruction in the agent’s instructions file, not something Reverie can enforce.
implemented in: ec/retrieval.py · ec/mode_detection.py
What you’re installing
Storage. One SQLite file at ~/.ec/ec.db, shared by your projects. There is no Reverie account.
Server. A local MCP server, spawned by your agent over stdio. It runs maintenance in the background.
MCP tools
| Tool | What it does | When your agent calls it | Needs an active session? |
|---|---|---|---|
ec_observe | Passes the prompt, the agent’s reasoning and its final output to the extractor, which keeps the conclusions in the session brain. | When it reaches a conclusion. | Yes |
ec_query | Returns relevant conclusions from both brains, grouped with their neighbours and framed. | After it has read the code. | Yes |
ec_get_summary | Reports counts from the canonical brain by scope and status, the last maintenance run and what awaits your review. | Once, at the start of a session. | No |
ec_reconsolidate | Updates a conclusion it just retrieved, with verified evidence, and records the update. | When it finds verified evidence about a conclusion it has just retrieved. | Yes |
Tools that need a session return an error until you start one.
Supported agents
| Agent | Status | Instructions file |
|---|---|---|
| OpenCode | Works today | ~/.config/opencode/AGENTS.md |
| Claude Code | Coming soon | ~/.claude/CLAUDE.md |
| Cursor | Coming soon | ~/.cursor/rules/ec.md |
| Codex | Coming soon | ~/.codex/AGENTS.md |
| Other MCP agents | Coming soon | Set up by hand |
For each agent, the installer adds an MCP entry and wires Reverie’s instructions into the file shown.
Across agents and models. Memory lives in one file, not inside your agent, so changing the model your agent runs keeps your memory. Agents added later share the same file. Setup instructions are in the repository ↗.
Models and data. Reverie stores memory locally. Extraction and classification use an LLM endpoint: hosted by default, or a local model through Ollama. What it sends there is the prompt, the agent’s reasoning and final output, and candidate pairs of conclusions for classification. The database, the embeddings and retrieval never leave your machine.
In the code, Reverie’s package, commands and tools use the prefix ec, for Engineering Cognition, the research program behind it.
implemented in: ec/install.py · ec/mcp_server.py
Limits, today
- Developed and tested on macOS. Other platforms aren’t verified.
- Review happens in the terminal only.
- You start and end sessions yourself. The agent never does.
- Extraction depends on an LLM and makes a single attempt per observation.
- There is no interface for editing or deleting long-term memory beyond your review decisions.
- Our benchmark hasn’t shown a clear advantage yet. EC-Bench
Last reviewed
Questions
Doesn’t my agent already have memory?
Instruction files and built-in memories store notes that load into sessions. Reverie stores reviewed conclusions with confidence, scope, code references and relationships, and returns them on request. It works alongside instruction files.
Does my code leave my machine?
Parts of your sessions can. Extraction sends the prompt, the agent’s reasoning and its final output to the configured LLM endpoint, and classification sends candidate pairs of conclusions. That endpoint is hosted by default, or a local model if you use Ollama. The database, the embeddings and retrieval never leave your machine.
What do I have to do?
Start a session, work, and review at the end. You start and end sessions yourself.
Why doesn’t it load memory automatically?
Our first version did, and on our benchmark the agent trusted memory over the code and did worse. So the agent asks, after reading the code, and gets results framed as “verify before acting”.
Does Reverie make my agent better?
That’s what the research is testing. No run has shown a clear advantage yet, and we publish results either way. See EC-Bench.
Which agents are supported?
OpenCode works today. Claude Code, Cursor, Codex and other MCP agents are coming soon. See the table.
Is it open source?
Yes. The code is in the repository ↗, under the Apache-2.0 licence.