Brain Docs
Learn

Why memory exists

Why agents forgetWhy a bigger window doesn't fix itWhy RAG isn't memory

What a memory is

What a memory isThe statement kindsWhen facts collide

How it answers

How recall decidesDecay and retention

Using it well

What to write, and what not to

Reference

Brain/Docs
✦ ASKBrain on GitHubDashboard
LearnDecay and retention

Decay and retention

Salience decays on a kind-dependent half-life, superseded claims close off, tombstones reclaim after a grace period — three mechanisms, three different meanings of "forget".

PURPOSE

A memory layer that only accumulates becomes a slower, more expensive version of the problem it was meant to solve. Here is what fades, what closes, what is actually destroyed — and the numbers that govern each.

Four mechanisms, deliberately separate

Mechanism
What happens to the record
Decay
Salience falls exponentially for memories that aren't reinforced
Nothing is removed. It stops competing as hard for a place in the answer
Consolidation
Clusters of episodic memories are summarised into one derived memory
Sources are retained and linked by DERIVED_FROM edges
Supersession
A newer claim closes the older one's validity interval
Retained and linked. Still answers questions about the past
Tombstoning
Soft: marked, grace period runs. Hard: the slot is zeroed immediately
Destroyed after the grace elapses. This is erasure

Keeping these separate is what lets "stop surfacing this", "this changed" and "delete this" be different operations. A system with only a delete cannot express the first two, so it either hoards everything or loses history.

It also means "forgetting" is not one feature with a switch. Three of the four run continuously without you asking, shaping what surfaces; only the fourth is something you call. Most of the tuning questions people bring to a memory layer — why is this old thing still ranking?, why did my summary never appear? — are questions about which of the four is or isn't doing its job.

Salience: one number, three forces

Every memory carries a salience in [0, 1]. It answers a narrow question: of two memories that match a cue equally well, which is the more important? It is a ranking signal and an eviction signal, never a visibility switch.

salience(M) = clip( S₀(M) + B(M) − D(M), 0, 1 )

Initial salience, accumulated access boost, accumulated decay.

Where it starts

S₀ = clip( w_hint·H + w_surprise·U + w_kind·K + S_base, 0, 1 )
TermWhat it isDefault
Hyour salience_hint, [-1, +1]0
Usurprise — 1 − cos_sim(vector, centroid of the last 100 in this session)computed
Kkind weight — Episodic 0.5, Semantic 0.7, Consolidated 0.6—
S_basebaseline, so nothing starts at zero0.4
weightsw_hint, w_surprise, w_kind0.4, 0.2, 0.4

In practice, with no hint: a typical episodic memory starts near 0.6, a semantic one near 0.7, and one you flag H = 1 lands between 0.8 and 1.0.

The surprise term is the interesting one. A memory much like the last hundred things in its session scores low; something genuinely new scores high. It is a cheap novelty signal that costs one cosine against a running centroid, and it is why the tenth near-identical status update does not arrive as important as the first.

Where it goes up

Every access — by recall, plan or reason — boosts it:

boost = (1 − salience) · 0.05

The shape matters: a low-salience memory gains more per access than a high-salience one, so salience saturates rather than running away. This is use-it-or-lose-it — memories that keep proving relevant become harder to forget, and memories nothing ever asks for drift down.

The boost is applied asynchronously. A recall returns immediately and the update is enqueued for the writer; typical lag is under 10 ms. Tying every read to a synchronous write would cost the read path its lock-freedom, which is the trade Brain takes.

Where it goes down

salience(t) = salience · exp( −ln2 / half_life · Δt )
Memory kindHalf-lifeSalience after 300 days
Episodic30 days≈ 0.0009
Semantic365 days≈ 0.5
Consolidated90 days≈ 0.06

Decay is applied two ways: lazily on read (a memory loaded for a recall has its salience aged by the elapsed time and the new value persisted) and by a background sweep for memories nothing has read in a long time. A space that goes quiet for a year and then gets a read will see a large single drop — that is correct, not a bug.

Two floors bound it. Decay never pushes salience below 0.05, so nothing is erased by decay alone. Below an eviction threshold of 0.1 a memory becomes eligible for eviction by the consolidation worker — eligible, not evicted.

The distinction between those two numbers is the whole safety property. A memory at the floor is still a memory: still indexed, still recallable, still the right answer to a question only it answers. Nothing in this section ever removes it. Eviction is a separate decision made by a different worker, and even then eligibility is not action.

Don't tune this first. The constants are all deployment-configurable and the defaults are calibrated to be reasonable. If old memories over-rank, shorten half-lives; if things vanish too fast, lengthen them; if your salience_hint isn't biting, raise w_hint. For workloads that want no decay at all, set a half-life of a hundred years. But reach for the recall trace before you reach for these — ranking complaints are usually a retrieval problem, not a decay one.

Recency is separate, and not stored

A fourth term is added at query time only:

recency_boost = 0.2 · exp( −age / 7 days )
effective_salience = salience + recency_boost

An hour-old memory gets ≈ 0.2, a day-old ≈ 0.17, a week-old ≈ 0.07, and older ones effectively nothing. It is computed per query and never persisted, which avoids constantly rewriting rows to express the passage of time.

This is a different thing from the recency boost in the read pipeline. That one is an RRF-scale term applied to fused ranks, gated on the query being temporal. This one is part of the memory's own salience. They stack.

What the worker actually does

Decay is a background cycle, not a trigger, and knowing its shape explains some behaviour that otherwise reads as inconsistent.

Every hour the worker walks the memories table in batches of 10,000, computes each new salience, writes back only the rows that changed, and stores a cursor so the next cycle resumes where it stopped. A large shard therefore takes several cycles to sweep — the cost is about 15 µs per memory, roughly 150 ms per batch, which is why it can be preempted under write load without anyone noticing.

It is deliberately soft real-time: missing a cycle is fine, missing several delays decay slightly and causes no incorrectness. Operators can pause it.

Decay and the access boost race, and that is accepted. The boost cycle runs every ten seconds; decay runs hourly and does read-then-write. A boost landing between decay's read and its write is overwritten — and re-applied by the next boost cycle.

This is a deliberate trade, not an oversight: salience is a filter threshold, not an accounting figure, and coordinating the two workers would cost more than the precision is worth. A memory either clears your salience_floor or it does not; the exact value either side of that line changes nothing. If you are tempted to build logic that depends on a precise salience number, that is the signal you want a different field.

Turning it off, and turning it up

Every constant is deployment-configurable, including out of existence:

[memory.decay]
episodic_half_life    = "30d"
semantic_half_life    = "365d"
consolidated_half_life = "90d"
boost_factor          = 0.10     # per access

[workers.decay]
enabled = true

A chat assistant may want fast decay so conversations fade; a knowledge base may want effectively none — set a half-life of a hundred years, or disable the worker entirely and salience simply stops changing over time. Nothing else breaks: decay is pressure on ranking, and removing the pressure leaves a system that ranks on the other signals.

There is also an auto-forget option, off by default: configure a salience floor and the decay worker soft-forgets anything that falls below it. Deliberately opt-in, because automatic deletion is a strong default to impose on someone else's data — most deployments want control over what disappears, and a typical opt-in threshold is around 0.05.

Consolidation: summaries as first-class memories

Every five minutes, a worker looks for clusters worth summarising: episodic memories in the same session, within a 24-hour window, with pairwise cosine above 0.6, at least five to a cluster. A session that crosses 50 episodic memories triggers a pass immediately rather than waiting for the next cycle.

Each cluster produces one Consolidated memory — a summary generated by an external LLM, since Brain ships no model for this — linked back to its sources by DERIVED_FROM edges. The originals remain. Consolidation is not compaction; nothing is deleted and the episode-level detail stays recallable.

What it buys is that recall can return the summary and its sources, instead of handing the agent eight adjacent episodes to re-aggregate itself.

The summary is Consolidated kind, which places it deliberately between the other two on every axis: it starts more salient than an episode (0.6 against 0.5) because a distilled pattern is worth more than any one observation, and less salient than durable knowledge (0.7); and it decays on a 90-day half-life, between episodic's 30 and semantic's 365. A learned pattern should outlive the episodes it came from and still not be treated as a standing fact.

Consolidation needs an external model and is the one stage that can be starved. Brain ships no summariser — generating the summary is an outbound LLM call. If that provider is unavailable or unconfigured, clustering still identifies groups and no Consolidated memories get written.

Nothing errors on your write path, because consolidation is hours downstream of it. The symptom is an absence: a long-running space that never develops higher-level memories and keeps returning raw episodes one at a time.

Confidence ages too, by statement kind

Separately from salience, a statement's confidence decays with the age of its evidence — and the rate is keyed off the statement kind:

  • Event — no decay at all, factor 1.0. What happened, happened.
  • Fact and Preference — exponential against their own configured half-lives.

This is why a two-year-old unrefreshed Preference loses to a recent one on confidence alone, with no supersession recorded between them.

Forgetting on purpose

forget comes in two strengths:

OptionTypeDefault / Env
Softdefault

The slot is tombstoned: hidden from queries, recoverable until the grace period elapses. Default forget_grace_period = "7d". A GC worker runs every 10 minutes and reclaims up to 1000 eligible slots per cycle.

Hardcompliance

The slot is overwritten with zeros, removed from the index, and the content is unrecoverable. Extra zeroing passes run over the arena slot so the data is genuinely gone rather than merely unindexed. This is the mode for an erasure request.

Both are idempotent: retrying a forget for an already-forgotten memory succeeds and reports was_already_forgotten = true.

And forgetting is cheap — around 3 ms at p50, because there is no embedding to compute. It is a log record and a metadata update, not a rewrite. Deleting is not the expensive operation; deciding what to delete is.

A reclaimed slot is reused, and the id does not alias. When the GC reclaims a slot it increments the slot's version, and the version is encoded in the memory_id. An id you held from before reclamation no longer matches the slot's current occupant — it resolves as absent rather than silently resolving to someone else's memory. Hold ids as long as you like; just expect a stale one to read as gone.

Forgetting cascades to the typed records derived from the memory, because a statement whose evidence no longer exists is an unattributed claim — exactly what the write path refuses to admit in the first place.

The three sweepers you never see

Alongside decay and consolidation, three cleanup workers keep the substrate from growing without bound. They are worth knowing because each one's retention window is a promise you may be relying on without realising:

OptionTypeDefault / Env
Slot reclamationevery 10 minutes

Finds memories tombstoned longer than the grace period and returns their arena slots to the free list, up to 1000 per cycle. It re-checks that the memory is still tombstoned before acting, so an un-forgotten memory is skipped rather than reclaimed out from under you.

Idempotency sweeperTTL-bounded

Expires the request-id table. The contract is idempotency within the TTL window — a retry beyond it may be treated as a new operation, which is the real meaning of the horizon on your request_id.

WAL retentionsegment-based

Truncates write-ahead log segments past the retention point. This is the one with a non-obvious consequence: a subscription resuming from a log position older than the retention window cannot resume, because the events it wants are gone.

Each of these defaults to a window that is comfortable for normal operation and tight enough to bound disk. Each is also the thing that quietly makes a recovery procedure fail at 3am if you assumed it was longer.

What this means for erasure requests

Three properties combine into something useful:

  1. Erasure by subject. Entities are canonical, statements point at them, and evidence points back at memories — so the subject is a real handle you can delete by, rather than a string you hope to find every copy of.
  2. Hard delete that zeroes, rather than hiding a row behind a flag.
  3. Provenance, so you can answer where did this come from — usually the harder half of a data-subject request.

What you still own is the policy: which spaces a subject's data lives in, how long you keep it, and whether a soft delete's seven-day window is acceptable for your obligations. Brain gives you the mechanism, not the decision.

Try it

Run Low signal in the playground — a deliberately vague, unhelpful sentence.

Watch the write path: it is admitted as a memory but produces little or nothing typed, because the gate does not promote noise into the graph. That is the same pressure decay applies over time, applied instead at write time — which is the cheapest place to apply it, since nothing downstream ever has to rank it.

Then run a cluster of five related sentences in one session and wait for a consolidation pass. The originals stay; a sixth memory appears above them with DERIVED_FROM edges pointing back. Seeing the sources survive is the quickest way to internalise that none of the four mechanisms on this page is a delete.

See also
When facts collideHow recall decidesErasing a subject

Was this page helpful?

How recall decides

Three retrievers fan out, their ranks fuse with RRF at k=60, a filter chain trims, and a relevance band — not a top-K cut — decides whether the answer is Single, Many or None.

What to write, and what not to

The judgement call every memory deployment gets wrong at least once — plus exactly which duplicates the database collapses for you, and which ones it lets through.

On this page

Four mechanisms, deliberately separateSalience: one number, three forcesWhere it startsWhere it goes upWhere it goes downRecency is separate, and not storedWhat the worker actually doesTurning it off, and turning it upConsolidation: summaries as first-class memoriesConfidence ages too, by statement kindForgetting on purposeThe three sweepers you never seeWhat this means for erasure requestsTry it
Suggest an editOpen in Playground