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.

ec_query · group 1canonical · reviewed

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.

Example
  1. 1
    Conclusion. One conclusion per record. Once accepted, its wording is never rewritten.
  2. 2
    Type. One of eight: implication, constraint, principle, decision, observation, pattern, invariant, trade-off.
  3. 3
    Scope. 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.
  4. 4
    Confidence. Moved by evidence, in log-odds. Ranking uses the value after decay.
  5. 5
    Brain and status. The header shows the brain: canonical · reviewed here, session · unreviewed otherwise. Only active, challenged and open-question conclusions are retrieved.
  6. 6
    Source. How the conclusion was reached. It sets the starting confidence: debugging starts higher than planning.
  7. 7
    Grounding. Files, symbols and the commit at extraction, checked against the repository.
  8. 8
    Related. Conclusions that support, contradict, depend on or replace this one come back with it.
  9. 9
    Framing note. Always attached: verify before acting.
Fig. 3Anatomy of a conclusion. Each part of a stored record, and what it does. Example record; this is also what your agent receives from a query.

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 agent writes conclusions into the session brain with ec_observe and reads both brains with ec_query. Extracted conclusions reach the canonical brain only through the review gate, where you accept, reject or skip. Evidence about long-term conclusions waits as pending until review. The one exception is ec_reconsolidate, which updates a conclusion the agent has just retrieved, with verified evidence, and records the update.Your agentOpenCode · Claude Code, Cursor, Codex and other MCP agents: coming soonec_observeec_queryreads both brainsec_queryec_reconsolidateupdates a conclusion itjust retrieved, with verifiedevidence; recordedSession brainper repo and branchunreviewed, usable nowrelates new conclusions:supports / contradictsno decayevidence about long-termconclusions waits as pendingReviewopen questions firstaccept →reject → discardedskip → next sessionCanonical brainshared across projectsreviewed, long-termrelates fully:supports / contradicts / supersedes / depends onconfidence fades by scopeweak conclusions can be supersededmaintenance, in the backgroundgrounding checks · open-question parking ·supersession · reversal of evidence fromretired conclusions
  1. Your agentOpenCode · Claude Code, Cursor, Codex and other MCP agents: coming soon
  2. Session brain
    • per repo and branch
    • unreviewed, usable now
    • relates new conclusions: supports / contradicts
    • no decay

    ec_observe writes here. ec_query reads here.

    Evidence about long-term conclusions waits here as pending.

  3. Review
    • open questions first
    • accept →
    • reject → discarded
    • skip → next session
  4. 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_query reads here.

    ec_reconsolidate writes here directly, without review: it updates a conclusion the agent just retrieved, with verified evidence, and the update is recorded.

  5. Maintenance, in the backgroundgrounding checks · open-question parking · supersession · reversal of evidence from retired conclusions
Fig. 4Two brains and a review gate. Extracted conclusions reach long-term memory only through review; the bold arrow, reconsolidation, is the one labelled exception.

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.
  1. Step 1 · Extracted

    A is extracted in a debugging session.

    prior = base[source] × multiplier[scope] = 0.70 × 0.80

    A0.56session · unreviewed
  2. Step 2 · Accepted

    You accept A at review. The full relating pass runs.

    promoted with the same confidence

    A0.56canonical · reviewed
  3. 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.

    A0.66active
  4. Step 4 · Retrieved

    A is retrieved by a query.

    L′ = L + 0.05

    The decay clock resets.

    A0.67active
  5. 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.

    A0.67active

    Effective confidence after decay: computed from config

  6. 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

    A0.55challenged
    C0.61active
  7. Step 7 · Open question

    The conflict outlasts the module’s time limit. Maintenance parks both A and C.

    confidence frozen · retrieved at half weight

    A0.55open question
    C0.61open question
  8. 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

    C0.62active
    A0.55superseded
  9. 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

    A0.67deprecated
  1. Step 1Extracted

    A is extracted in a debugging session.

    prior = base[source] × multiplier[scope] = 0.70 × 0.80

    A0.56session · unreviewed
  2. Step 2Accepted

    You accept A at review. The full relating pass runs.

    promoted with the same confidence

    A0.56canonical · reviewed
  3. 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.

    A0.66active
  4. Step 4Retrieved

    A is retrieved by a query.

    L′ = L + 0.05

    The decay clock resets.

    A0.67active
  5. 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.

    A0.67active

    Effective confidence after decay: computed from config

  6. 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

    A0.55challenged
    C0.61active
  7. Step 7Open question

    The conflict outlasts the module’s time limit. Maintenance parks both A and C.

    confidence frozen · retrieved at half weight

    A0.55open question
    C0.61open question
  8. 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

    C0.62active
    A0.55superseded
  9. 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

    A0.67deprecated
Fig. 5The life of a conclusion, step by step. Example values, computed with Reverie’s update rules.

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:

ScopeRetired when
engineering, domainNever
organization, projectAll cited files are gone
repo, module, subsystemAny 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:

  1. Reverie infers a task mode: debugging, implementation, investigation, planning or architecture.
  2. It searches both brains.
  3. It filters results by status, scope and relevance.
  4. It ranks them by similarity, confidence after decay, session activity and how connected a conclusion is.
  5. 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

ToolWhat it doesWhen your agent calls itNeeds an active session?
ec_observePasses 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_queryReturns relevant conclusions from both brains, grouped with their neighbours and framed.After it has read the code.Yes
ec_get_summaryReports 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_reconsolidateUpdates 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

AgentStatusInstructions file
OpenCodeWorks today~/.config/opencode/AGENTS.md
Claude CodeComing soon~/.claude/CLAUDE.md
CursorComing soon~/.cursor/rules/ec.md
CodexComing soon~/.codex/AGENTS.md
Other MCP agentsComing soonSet 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.