Agent Memory Retrieval Ranking: Relevance Is Not Usefulness, and How to Choose What Goes Into a Small Context Budget

Agent Memory Retrieval Ranking: Relevance Is Not Usefulness, and How to Choose What Goes Into a Small Context Budget
On this page
  1. Why the most relevant memory is often not the useful one
  2. What production ranking looks like today, and where it stops
  3. What to rank on, besides similarity
  4. How MemCredit measures usefulness
  5. MemCredit beat relevance retrieval by the widest margin at the tightest budget
  6. How to measure usefulness on your own traces
  7. A tested Python implementation
  8. When to retrieve, which index to ask, and what order to render in
  9. Failure modes and limits
  10. Keep your retriever for recall, and rank the final set on usefulness
  11. Frequently asked questions
  12. Sources

Published 16 November 2026 by Gaurav Dadhich. The research figures below come from the MemCredit paper (arXiv 2611.15600, v1, 11 November 2026) and the Generative Agents paper, both read in full on 16 November 2026. They are the authors' reports and have not been independently replicated.

Rank agent memories on whether they change the next decision, not on how similar they look to the current turn. Similarity is the right tool for collecting candidates and a weak one for choosing among them. The clearest evidence so far is MemCredit, a paper from Quanjiang Guo and colleagues at UESTC and NTU posted on 11 November 2026: across 1,041 controlled interventions on 45 ALFWorld tasks, where each memory was added to or removed from the agent's prompt and nothing else changed, 86.9% of interventions produced no measurable change in what the agent did, and the Spearman correlation between a memory's semantic relevance and its measured effect was −0.011 (95% CI −0.073 to +0.077). On that benchmark, a memory's relevance score carried almost no information about whether it would matter.

Ranking on measured usefulness paid off under tight budgets. With a 500-token budget for historical memory on 134 unseen ALFWorld tasks (Qwen3.6-27B-FP8, temperature 0), MemCredit's selector reached 86.57% success within 50 steps against 65.67% for BM25 retrieval and 71.64% for dense retrieval. On WebShop it scored 0.612 (against 0.407 for BM25) while putting 152.1 memory tokens into each decision, 74.5% fewer than BM25's 597.0. One correction to how the result has been circulating on X: the 152.1 tokens and 74.5% reduction are WebShop figures, not ALFWorld.

Why the most relevant memory is often not the useful one

Similarity answers "does this memory look like the current situation". The agent needs an answer to a different question, which is "would I act differently, and better, if I saw this". The two diverge in predictable ways.

A memory can be highly similar and redundant. If the agent is looking at product A and three memories describe product A, the most similar ones restate what is already in the observation. A memory can also be dissimilar and decisive: "A failed: over the $100 budget" shares few words with "search wireless headphones", yet it is the line that stops the agent buying A again. The MemCredit authors use exactly this shopping example to motivate the paper, and their numbers back it up. Mean credit after a failure was 0.176, against 0.029 outside failure states, so the memories that matter cluster around moments where the agent has just gone wrong, and those are the moments where the latest observation is the poorest guide to what is relevant.

The correlation also flipped sign depending on which tasks were sampled: −0.191 on a dense 11-task subset and +0.135 on a broader 44-task subset. That instability is the practical point. A similarity score is not a bad estimate of usefulness that you can recalibrate with a constant; on this evidence it is a different quantity.

None of this says similarity is useless. Retrieval still has to find the failure note among thousands of memories, and similarity, keyword search and filters are how you do that cheaply. The mistake is letting the retrieval score also decide what fills the last few hundred tokens.

What production ranking looks like today, and where it stops

Most agent memory ranking descends from the Generative Agents paper (Park et al., 2023). Its retrieval score is a weighted sum of three signals, each min-max normalised to [0, 1]: recency, an exponential decay with factor 0.995 per sandbox game hour since the memory was last retrieved; importance, an integer from 1 to 10 that the model assigns when the memory is created; and relevance, the cosine similarity between the memory's embedding and the query. All three weights are 1, and the top-ranked memories that fit the context window go into the prompt.

Production stacks have added stages on top. A typical pipeline runs vector and keyword search in parallel, fuses the lists with reciprocal rank fusion, reranks the shortlist with a cross-encoder that reads query and memory together, then applies recency or confidence boosts and truncates to a token budget. Hindsight's recall docs, for example, describe that sequence, with graph and temporal search running alongside and the reranker shortlist capped at 300 candidates by default.

Every stage in that pipeline still scores the same thing: how well a memory matches the query. A cross-encoder is a much better judge of relevance than cosine similarity, and it is still a judge of relevance. Importance comes closest to usefulness, but it is assigned once, at write time, by a model guessing how much a memory will matter in general rather than at this decision. MemCredit's contribution is to measure the thing directly and learn from the measurements.

What to rank on, besides similarity

Treat ranking as two jobs with different signals. Filters remove memories that should never reach the prompt, whatever their score. Scores order what survives.

SignalUse it asWhy
Scope (user, tenant, task, agent)Hard filter, before searchA memory from another user is a leak, not a low-ranked candidate
SupersessionHard filterIf "budget is $200" was replaced by "budget is $100", the old value must not compete on similarity
Validity windowHard filter, or strong down-weightTime-bound facts ("on leave until Friday") expire
Pinned or safety factsReserved slots, outside the rankingAllergies, legal holds and access limits must be present even when they do not change this turn
Memory typeScore featureConstraints and failure notes behave differently from episodes and preferences
Decision stateScore feature, combined with typeThe same memory is worth more right after a failed action
Recency and ageScore featureUseful for "latest state" questions, harmful when it buries an older constraint
Overlap with what is already selectedScore feature, recomputed per pickSecond copies of a fact add tokens and no new information
Measured past usefulnessScore feature, learnedThe only signal here that is about outcomes rather than appearance
RelevanceCandidate generationFinds the pool; on the MemCredit evidence, it should not set the final order

The MemCredit estimator uses close to this feature set. For each candidate it looks at relevance, age, functional type, source, entity overlap with the current state, observable progress and history statistics, and then at the context already chosen: the highest token-level Jaccard overlap with any selected item, how many of the candidate's entities are already covered, per-type counts and how full the budget is. Its memory types (Goal, State, Constraint, Episodic, Reference) come from an earlier paper, MemArbiter.

The filters belong at write time as much as at read time. A memory write policy that records supersession with history and stores scope on every item is what makes the first rows of that table cheap to enforce; a retriever cannot filter on a field nobody wrote.

How MemCredit measures usefulness

MemCredit defines a memory's credit as the difference in outcome when the agent decides with and without it, holding everything else fixed:

credit(memory, state, context) = outcome(state, context + memory) − outcome(state, context)

Four details make that measurement meaningful.

Replay from the same state. Both branches start from the same reconstructed environment snapshot with the same frozen policy, and differ only in whether the memory is rendered into the prompt. On ALFWorld the one-step outcome is +1 if the episode is won at that step, −1 if the action is inadmissible or repeats a previously failed action, and 0 otherwise. Each pair was run once, and samples whose reconstructed state did not match the recorded one were discarded; all 1,041 retained samples passed that check.

Condition on the rest of the context. Removing one memory from the full candidate set hides redundancy: if two memories carry the same necessary fact, removing either alone changes nothing, so both score zero. MemCredit samples reference contexts at five fill levels of the budget (empty, a quarter, half, three quarters, full) so the label reflects what a memory adds to a particular selection, not to an imagined full set.

Distil, do not replay at runtime. Running two agent calls per candidate on every live turn would be far too slow. MemCredit fits a small regressor (ExtraTrees) on the intervention labels and freezes it. At inference time there are no counterfactual rollouts and no extra environment calls.

Select greedily by credit per token. Starting from an empty set, the selector predicts each candidate's credit given what is already selected, keeps only candidates above a threshold tuned on development tasks, picks the one with the highest predicted credit per added token, and repeats, rescoring after every pick. It stops when nothing eligible is left, so the budget is a ceiling rather than a quota. The chosen memories go into the prompt in chronological order.

The estimator is far from perfect, and the authors say so. Under task-disjoint 5-fold cross-validation it reached a Spearman correlation of 0.220 with measured credit and an AUROC of 0.744 for picking out helpful memories; relevance features alone scored −0.031 and 0.483, which is chance. A weak but real signal, used only to rank, was enough to beat every relevance-based baseline on ALFWorld at both budgets.

MemCredit beat relevance retrieval by the widest margin at the tightest budget

SetupMemCreditBest baselineBM25Dense retrieval
ALFWorld, 134 unseen tasks, 500-token memory budget, success within 50 steps86.57%82.84% (MemArbiter)65.67%71.64%
ALFWorld, same, 750-token budget90.30%85.82% (MemArbiter)81.34%83.58%
WebShop, 200 tasks, 10K-product catalog subset, task score0.6120.586 (MemArbiter)0.4070.451
WebShop, memory tokens per decision152.1427.6 (MemArbiter)597.0596.8

Authors' report from Tables 1 and 2 of arXiv 2611.15600v1. Main runs use Qwen3.6-27B-FP8 served with vLLM at temperature 0 and a 4,096-token context window, and none of these results has been independently replicated.

Practitioners should take three things from the table. MemCredit's lead shrinks as the budget grows: 20.90 points over BM25 at 500 tokens, 8.96 points at 750. Selection matters most when space is scarce, which is the situation of a voice agent, a small model or any agent paying per token on long sessions. The ablation also shows that mixing relevance back in hurts: a 50/50 blend of relevance and predicted utility scored 78.36%, against 84.33% for utility alone on the same features. And the gain is not a "show the last failure" trick: a failure-only heuristic scored 70.15%, and removing the explicit failure and state indicators from the estimator raised success from 84.33% to 86.57%, which became the reported configuration.

On cross-model tests, with only the action model swapped (Qwen2.5-7B-Instruct, DeepSeek-V3, GPT-5.4) and the 500-token budget fixed, the authors report MemCredit ahead of flat recency, BM25 and MemArbiter in almost every setting, with one exception: GPT-5.4's success within 50 steps, where BM25 scored marginally higher.

How to measure usefulness on your own traces

You do not need MemCredit's code to test the idea; you need logged decisions and a way to grade an action. A one-week version looks like this.

1. Log decision points with their candidates. For each agent step, store the prompt inputs, the full candidate list your retriever returned (not only what was finally included), each candidate's type, scope, age and relevance score, and the action the agent took. Tag the state: just after a tool error or a user correction, mid-task, at a handoff, at the start of a session.

2. Pick a grader before you ablate. Ablation measures a change in outcome, so you need an outcome. In a tool-using agent it can be deterministic: did the action succeed, was it valid, did it repeat a failed call. In a conversational agent it is usually a rubric or a judge model, which brings its own noise; check the judge against itself before trusting a small credit difference. The cheapest proxy is "did the action change at all", which tells you which memories are inert but not which ones help.

3. Ablate a sample, not everything. Single removal from the full candidate set costs one extra agent call per candidate per decision, plus the baseline: 20 candidates across 500 decisions is 10,500 calls. Sample decisions across state types, weight toward failure and correction states, and run each pair more than once if your agent is not deterministic. MemCredit's own pipeline check found that repeated runs of the same deterministic configuration agreed on at least 94% of tasks and moved aggregate success by up to ±3 points because of GPU nondeterminism near ties, so treat small credit differences as noise.

4. Watch for masked redundancy. If two memories hold the same fact, single removal gives both zero. Run some ablations from partial contexts (start from an empty or half-full selection and add one memory) to see what each adds on its own.

5. Fit the simplest predictor that ranks. Average credit by memory type and decision state is a reasonable first model. Move to a regressor over richer features once you have thousands of labels, and always evaluate it on tasks or users it did not see, with relevance-only and shuffled-label baselines alongside.

6. Gate the change like any other. Compare the new selector against your current retriever on held-out traces and on live A/B traffic, reporting task success, tokens per decision and the failure modes you care about. The agent memory test plan covers how to grade store, retrieval and outcome separately so a ranking change does not hide a recall regression.

A tested Python implementation

The code below implements the measure-then-pack loop with the standard library only. ablate computes single-removal credit for each candidate at one logged decision; UsefulnessPrior turns those credits into a per-type, per-state estimate shrunk toward the global mean when data is thin; pack drops out-of-scope and superseded memories, reserves room for pinned facts, then fills the budget by predicted usefulness per token. Plug in your own policy (the agent call) and grade function.

"""Measure which memories change an agent's next action, learn a usefulness
prior from those measurements, and pack a token budget with it.

Standard library only. Plug in your own policy (the agent call) and grader.
"""
from collections import defaultdict
from dataclasses import dataclass, field


@dataclass
class Memory:
    id: str
    text: str
    type: str                  # e.g. "constraint", "failure", "preference", "episode"
    scope: str                 # e.g. "user:42", "task:abc"
    tokens: int
    relevance: float = 0.0     # whatever your retriever returned
    superseded_by: str = ""    # id of the newer memory that replaced this one
    pinned: bool = False       # must-carry facts (allergies, legal holds)


@dataclass
class Decision:
    """One logged decision point from a real trace."""
    state_kind: str            # e.g. "after_failure", "normal"
    prompt: str
    candidates: list = field(default_factory=list)


def ablate(decision, policy, grade):
    """Credit of each candidate = grade(with all) - grade(without it).

    policy(prompt, memories) -> action; grade(decision, action) -> float.
    Single removal from the full candidate set: cheap, but two copies of
    the same fact will each score zero (redundancy masks credit).
    """
    full = decision.candidates
    base = grade(decision, policy(decision.prompt, full))
    out = []
    for m in full:
        rest = [x for x in full if x.id != m.id]
        out.append((m, base - grade(decision, policy(decision.prompt, rest))))
    return out


class UsefulnessPrior:
    """Mean measured credit per (memory type, state kind), shrunk toward the
    global mean when a cell has few samples. A lookup table, not a model:
    replace it with a regressor once you have thousands of labels."""

    def __init__(self, k=5.0):
        self.k = k
        self.sum = defaultdict(float)
        self.n = defaultdict(int)
        self.total = 0.0
        self.count = 0

    def fit(self, labelled):
        for state_kind, mem, credit in labelled:
            key = (mem.type, state_kind)
            self.sum[key] += credit
            self.n[key] += 1
            self.total += credit
            self.count += 1
        return self

    def predict(self, mem, state_kind):
        g = self.total / self.count if self.count else 0.0
        key = (mem.type, state_kind)
        n = self.n.get(key, 0)
        return (self.sum.get(key, 0.0) + self.k * g) / (n + self.k)


def pack(candidates, state_kind, scope, budget, prior, min_score=0.0):
    """Relevance has already picked the candidates. Here: drop wrong scope and
    superseded items, carry pinned facts first, then fill by predicted
    usefulness per token. The budget is a ceiling, not a target."""
    live = [m for m in candidates
            if m.scope in scope and not m.superseded_by]
    chosen, used = [], 0
    for m in [m for m in live if m.pinned]:
        if used + m.tokens <= budget:
            chosen.append(m)
            used += m.tokens
    rest = [m for m in live if not m.pinned]
    rest.sort(key=lambda m: prior.predict(m, state_kind) / max(m.tokens, 1),
              reverse=True)
    for m in rest:
        if prior.predict(m, state_kind) <= min_score:
            continue
        if used + m.tokens <= budget:
            chosen.append(m)
            used += m.tokens
    return chosen

The tests use a toy shopping policy that mirrors the paper's example. The two product memories are the most similar to the task and change nothing; the failure note is the least similar and flips the action from retrying product A to choosing B. They also check that duplicated failure notes mask each other under single removal, that pinned facts go in first, and that superseded and other-scope memories never reach the prompt.

from usefulness import Memory, Decision, ablate, UsefulnessPrior, pack


def toy_policy(prompt, memories):
    texts = " ".join(m.text for m in memories)
    if "buy" in prompt:
        if "A failed" in texts:
            return "choose B"
        return "retry A"
    return "noop"


def toy_grade(decision, action):
    return 1.0 if action == "choose B" else 0.0


def mems():
    return [
        Memory("m1", "Product A costs $149 and matches the search", "episode",
               "task:1", 12, relevance=0.92),
        Memory("m2", "Product A matches wireless headphones", "episode",
               "task:1", 10, relevance=0.90),
        Memory("m3", "A failed: over the $100 budget", "failure",
               "task:1", 9, relevance=0.41),
    ]


def test_ablation_credits_the_low_relevance_failure_memory():
    d = Decision("after_failure", "buy headphones", mems())
    credits = {m.id: c for m, c in ablate(d, toy_policy, toy_grade)}
    assert credits == {"m1": 0.0, "m2": 0.0, "m3": 1.0}


def test_redundant_copies_mask_each_other():
    ms = mems() + [Memory("m4", "A failed: price too high", "failure",
                          "task:1", 7)]
    d = Decision("after_failure", "buy headphones", ms)
    credits = {m.id: c for m, c in ablate(d, toy_policy, toy_grade)}
    assert credits["m3"] == 0.0 and credits["m4"] == 0.0


def test_prior_shrinks_toward_global_mean():
    labelled = [("after_failure", mems()[2], 1.0),
                ("after_failure", mems()[0], 0.0),
                ("normal", mems()[0], 0.0),
                ("normal", mems()[0], 0.0)]
    p = UsefulnessPrior(k=1.0).fit(labelled)
    # one sample of 1.0, global mean 0.25: (1.0 + 0.25) / 2
    assert abs(p.predict(mems()[2], "after_failure") - 0.625) < 1e-9
    assert p.predict(mems()[2], "after_failure") > p.predict(mems()[0], "normal")


def test_pack_prefers_useful_over_relevant_and_respects_budget():
    d = Decision("after_failure", "buy headphones", mems())
    labelled = [(d.state_kind, m, c) for m, c in ablate(d, toy_policy, toy_grade)]
    p = UsefulnessPrior(k=1.0).fit(labelled)
    chosen = pack(mems(), "after_failure", {"task:1"}, budget=15, prior=p)
    assert [m.id for m in chosen] == ["m3"]
    assert toy_policy("buy headphones", chosen) == "choose B"


def test_pack_drops_superseded_and_out_of_scope_and_keeps_pinned():
    ms = mems() + [
        Memory("old", "Budget is $200", "constraint", "task:1", 5,
               superseded_by="m3"),
        Memory("other", "Another user's card", "preference", "user:9", 5),
        Memory("allergy", "User is allergic to latex", "fact", "user:42", 8,
               pinned=True),
    ]
    p = UsefulnessPrior().fit([("after_failure", ms[2], 1.0)])
    chosen = pack(ms, "after_failure", {"task:1", "user:42"}, budget=40, prior=p,
                  min_score=0.1)
    ids = [m.id for m in chosen]
    assert ids[0] == "allergy"
    assert "old" not in ids and "other" not in ids
    assert sum(m.tokens for m in chosen) <= 40

All five tests passed on Python 3.10.12 with pytest on 16 November 2026. The prior is a lookup table on purpose: it is easy to inspect, and it shows quickly whether usefulness in your traces depends on type and state at all before you spend time on a model.

When to retrieve, which index to ask, and what order to render in

The state breakdown in the MemCredit appendix is a useful guide to when retrieval is worth its latency. Mean credit was +0.176 in failure contexts, +0.060 in normal progress, +0.035 where the agent risked repeating an action, +0.033 at constraint-sensitive steps, +0.023 at reference-sensitive steps and −0.005 at subgoal transitions, where 96.2% of interventions changed nothing (Table 8, ALFWorld, authors' report). Only the failure-context and normal-progress intervals exclude zero, so treat the middle of that list as weak. Read loosely for a production agent: refresh the memory block after a tool error, a rejected action or a user correction, and do not pay for a fresh retrieval on every step of a plan that is going well. Load pinned facts and the person's profile once, at session start, and keep them.

Some questions are not similarity questions at all. "What did we agree before the contract changed" needs a validity window or a temporal index, and "who introduced this supplier" needs a relationship graph; both produce candidates that an embedding search would rank low. Add those indexes when your traces show those question shapes, and feed their results into the same candidate pool instead of a separate prompt section.

Order still matters after selection. Long-context models use information unevenly across positions, a result from Lost in the Middle (Liu et al., TACL 2024) that the MemCredit authors cite in their motivation. MemCredit renders its selected memories in fixed chronological order, which keeps cause before effect for a failure note. A shorter, more useful block also leaves the model less middle to lose things in, although nothing in the MemCredit paper measures that directly.

Failure modes and limits

The evidence comes from one benchmark family and one main model. ALFWorld and WebShop are simulated environments with crisp rewards, a frozen Qwen policy and short memories. Customer conversations have fuzzier outcomes, longer horizons and memories that matter weeks later. The cross-model results help, but this is a single paper, posted on 11 November 2026, with every figure the authors' own.

Interventions cost money. Labels need two policy calls per memory per decision, more for repeated runs or multi-step horizons, and an environment you can restore to a snapshot. ALFWorld is deterministic, which made replay possible; a live web or customer environment usually is not, so you will be replaying from logs with a simulator or a judge, and the labels inherit that grader's errors.

Credit is conditional, not a property of the memory. The paper is explicit that a credit belongs to a state, a policy, a reference context and a horizon. Change the model, the prompt template or the renderer and the labels can go stale. Re-collect a sample after any of those changes.

Greedy selection misses pairs. Two memories that only help together can each score low. The authors note the selector "may miss complementary memories that are useful only jointly".

Usefulness to the next action is not the whole job for a customer-facing agent. A person's allergy, their preferred name, a legal hold on their account or the fact that they asked not to be called after 6pm may change nothing in most turns, so they will score near zero on any next-action ablation. They still have to be present the turn they matter, and the cost of missing them once is far higher than the tokens. Keep a small pinned set chosen by policy, outside the learned ranking, and let usefulness compete for the rest of the budget.

Fewer tokens is not always the goal. MemCredit's budget is a ceiling, and on WebShop it used 152.1 memory tokens per decision where MemArbiter used 427.6. That is a feature when tokens are the constraint. If you are also trying to keep the prompt cache warm, reordering and dropping memories per turn changes the prefix; the trade-offs between compacting, retrieving and caching are covered in context compaction vs retrieval.

Keep your retriever for recall, and rank the final set on usefulness

Keep it. Hybrid search, a reranker and good filters are still how you build a candidate pool with high recall, and the paper makes recall a separate, measured stage for that reason. What changes is the last step: instead of taking the top-k by relevance, score the pool on what each memory is likely to change at this decision, given what is already selected, and stop when the next memory is not worth its tokens.

For teams on Maximem Synap, the retrieval it documents runs several techniques at once, then merges, deduplicates, ranks on relevance, recency and confidence, and trims to a token budget you set, and every memory carries a type, a confidence score, a scope and a timestamp. Those fields are what the filters and features above need, and the ablation loop works on the ranked set Synap returns as it would on any other retriever's output. For a worked read path that ranks episodes and facts into a prompt, see episodic and semantic memory for AI agents.

Frequently asked questions

How should an AI agent rank retrieved memories?

Use relevance, keyword search and hard filters (scope, supersession, validity) to collect a candidate pool, then order that pool by expected effect on the next decision: memory type, decision state, overlap with what is already selected and measured past usefulness, divided by token cost. In the MemCredit study this beat relevance ranking by 20.90 points of ALFWorld success at a 500-token budget (authors' report).

Is semantic similarity a good measure of memory usefulness?

Semantic similarity is a poor measure of usefulness on current evidence. Across 1,041 controlled interventions on ALFWorld, the correlation between a memory's semantic relevance and its measured effect on the agent's action was −0.011, and 86.9% of interventions changed nothing (MemCredit, arXiv 2611.15600, authors' report).

How do I measure whether a memory is useful?

Ablate it. Replay a logged decision with and without the memory, keep everything else fixed, and grade both actions. The difference is the memory's credit at that decision. Sample decisions across states, weight toward post-failure steps, repeat runs if your agent is nondeterministic, and test some memories from partial contexts so duplicates do not mask each other.

How many memories should go into the context?

As many as are worth their tokens, which is often fewer than the budget allows. On WebShop, MemCredit's selector used 152.1 memory tokens per decision against 597.0 for BM25 and still scored higher. Set the budget as a ceiling and stop adding when the next memory's predicted value per token falls below a threshold tuned on held-out tasks.

Does a cross-encoder reranker solve this?

It improves relevance, which is a different target. A reranker reads the query and memory together and judges how well they match; it does not know whether the memory changes the action or duplicates something already selected. Use it to improve the candidate pool, and rank the final selection on usefulness.

What is MemCredit?

MemCredit is a method from a November 2026 arXiv paper (Guo et al., arXiv 2611.15600) that measures each memory's credit by counterfactual intervention, trains a small ExtraTrees estimator on those credits, uses semantic relevance only to collect candidates, and packs a fixed token budget greedily by predicted credit per token. It leaves the agent's policy unchanged and needs no extra environment calls at inference time.

Should a customer-facing agent drop memories that do not change the next action?

Keep them. Facts about a person such as allergies, access limits, legal holds or stated preferences can be inert in most turns and essential in one. Keep a small pinned set chosen by policy and let learned usefulness rank only the remaining budget.

Sources

All retrieved 16 November 2026.

The Python example and its arithmetic are our own.

From the team at Maximem

Stop rebuilding agent memory from scratch

Maximem Synap is the context management layer we built after hitting every problem in this post ourselves. Persistent recall across sessions, entity resolution and conscious forgetting, in Python, TypeScript and REST.

Looking for more to read? See our directory of the best engineering blogs to follow.