Brain Docs

Reference

RecipesSupport bot with memorySession summaryIdentity from a session JWTTune salience decayWalk the entity graphManual rate-limit backoff
Brain/Docs
✦ ASKBrain on GitHubDashboard
RecipesTune salience decay

Tune salience decay

Run the salience-decay worker on a faster cadence for a deployment whose memories go stale quickly — and understand why that changes what recall filters, not how it ranks.

PURPOSE

Run the salience-decay worker more often for a deployment whose memories go stale fast — a trading agent, a live operations console. And understand what decay actually changes, because it is not what most people assume.

Decay moves salience, not confidence

These are two different numbers with two different mechanisms, and the distinction decides whether this recipe is the one you want.

Salience is "how important is this memory", in [0, 1]. A background worker decays it exponentially — the Ebbinghaus forgetting curve — and the memory kind sets the rate. This is what the knob below tunes.

Confidence is "how sure are we this is true". It is computed from evidence (noisy-OR, with a decay by statement kind) and stored as a snapshot at last touch. Pure age-based decay is not applied to it at read time, and no worker cadence changes that.

What decay actually changes

Salience is a filter, not a ranking term

Decaying a memory's salience does not push it down the results. Above your salience_floor a more-salient memory does not outrank a less-salient one; below the floor it is excluded entirely. Salience only reaches a read through that threshold.

This is deliberate. Salience decays on a schedule the caller does not control, so folding it into relevance would make the same cue return a different order tomorrow for reasons that have nothing to do with the cue.

So tuning the cadence changes when a memory crosses your floor, and nothing else about retrieval. If what you actually want is "prefer recent things", that is a separate, built-in term — recency, with a 90-day half-life on event time, worth at most half of one top-rank vote. See How recall decides.

The knob

Decay cadence lives in the [workers] section of config.toml, baked into the image at /etc/brain/config.toml. The default runs hourly:

[workers]
decay_interval_sec = 3600   # run the decay pass every hour

Lower it to decay more aggressively:

[workers]
decay_interval_sec = 300    # every 5 minutes

Any field is overridable at runtime with the generic BRAIN__SECTION__FIELD form — no bespoke variables:

BRAIN__WORKERS__DECAY_INTERVAL_SEC=300

The worker runs on every shard, and the new cadence takes effect on the next server start. This is a deploy-time setting, not a per-request or per-namespace one.

Then set a floor, or nothing changes

A faster cadence with no salience_floor on your reads is a no-op from the caller's side — the numbers move and nothing is excluded. The two go together:

const answer = await client.recall(
  new RecallBuilder("last quarter revenue").maxResults(10).salience(0.3).build(),
);
answer = client.recall(
    RecallBuilder("last quarter revenue").limit(10).salience(0.3).build()
)
let answer = client
    .recall(&RecallBuilder::new("last quarter revenue").max_results(10).salience(0.3).build())
    .await?;

Verify

Watch a known memory's salience move across passes:

const answer = await client.recall(
  new RecallBuilder("last quarter revenue").maxResults(10).build(),
);
for (const m of answer.memories) {
  console.log(m.memoryId, m.salience, m.salienceInitial, m.accessCount);
}
answer = client.recall(RecallBuilder("last quarter revenue").limit(10).build())
for m in answer.memories:
    print(m.memory_id, m.salience, m.salience_initial, m.access_count)

salience_initial beside the current value is the useful pair — it tells you how far a memory has faded rather than just where it ended up. Re-encoding the same fact reinforces it and resets decay: a memory that keeps coming up stays salient, one nothing refers to fades.

Do not expect an exact number

The access boost runs every ten seconds and decay runs hourly with a read-then-write. A boost landing between decay's read and its write is overwritten, and re-applied by the next boost cycle. That race is accepted because salience is a threshold, not an accounting figure. If your logic needs an exact value, you want a different field.

Decay is server-wide, not per-tenant

A deployment that needs sub-minute staleness for one tenant and month-long retention for another is really two workloads. Run separate Brain deployments rather than fighting one cadence.

See also
Retention and decayHow recall decidesConfiguration

Was this page helpful?

Identity from a session JWT

SSR pattern — verify your app's session JWT, derive the caller's (namespace, space), and run each request under that scope with act_as.

Walk the entity graph

Encode a transcript, list the entities the pipeline extracted, and walk the relation graph with /v1/entities and /v1/graph.

On this page

What decay actually changesThe knobThen set a floor, or nothing changesVerify
Suggest an editOpen in Playground