Everyone says "give your agent memory." Few posts show what happens when the memory fills up and the codebase moves on. So I built a small incident-memory layer for a debugging agent and tried to break it.

Important up front: this is a synthetic benchmark. No LLM is involved; it only tests the retrieval layer (what the agent would be shown). The absolute numbers depend on my simulation assumptions (listed at the end), so read the direction of each effect, not the exact percentages.

The setup

  • SQLite table of past incidents: service, version, symptom, root_cause, fix, a simulated day, and helped / failed counters.
  • Retrieval: BM25 over the symptom text (pure stdlib, ~100 lines).
  • Query: a new symptom + the current service and version.

Two kinds of trials:

  • stale-trap: the right memory is from the current major version, but an older-major memory with the same symptom exists, and its fix worked 3 times before the upgrade.
  • evergreen: the right memory is from an old major version and is still valid (think "expired TLS cert").

Failure 1: the store grows, retrieval collapses

Plain BM25, top-3 contains the right incident:

store size baseline + service filter
20 50.5% 89.0%
200 9.0% 53.0%
2000 1.5% 10.5%

Filtering by service was the single biggest win at small scale, and it still decays. Symptom text alone is a weak key: every incident says "timeout", "502", "retry".

Failure 2: stale memories win

At 20 incidents with only a service filter, the outdated fix ranked first in 39% of stale-trap trials, while the correct one ranked first in 42%. A version filter drove stale-first to 0% and lifted correct-first to 82%.

Failure 3: "learning from feedback" can make it worse

I weighted memories by past success. Alone, that pushed the stale fix to first place in 72% of stale-trap trials (correct-first: 15%). Success history is a record of the past system. Feedback only helps if it is combined with something that knows the system changed.

Failure 4: the hard filter deletes good memories

The version filter that fixed failure 2 scored 0% on evergreen trials (by construction in my setup, but the trade-off is real). A soft penalty (multiply the score by 0.4 on a major-version mismatch) kept both:

config (20 incidents) stale-trap top-1 evergreen top-1 overall top-3
service + hard version filter 82.0% 0.0% 49.0%
service + soft version penalty 79.0% 37.0% 89.5%

Demote, don't delete.

Failure 5: confidently wrong (and abstaining only half-works)

Even my best config returned a wrong top-1 in 31.0% of trials at 20 incidents, and 82.0% at 2000. BM25 always returns something, and an agent handed a plausible wrong fix will act on it.

So I added an abstain rule: if the best score is below a threshold, show the agent nothing. Results for the soft-version config at 20 incidents (all 200 trials):

min score answered correct@1 wrong@1 precision
0 98.5% 58.0% 40.5% 58.9%
2 53.0% 36.0% 17.0% 67.9%
3 25.0% 20.5% 4.5% 82.0%
4 5.5% 5.5% 0.0% 100.0%

Cutting wrong answers from 40.5% to 4.5% also cut correct answers from 58.0% to 20.5%. It's a trade, not a fix.

To check I wasn't overfitting, I tuned the threshold on one set of 200 trials (lowest threshold with wrong@1 <= 10%) and evaluated it on 200 unseen ones:

store config min score tune correct / wrong held-out correct / wrong
20 soft version 3 20.5% / 4.5% 20.5% / 3.5%
20 hard version + decay + feedback 2 34.0% / 3.5% 30.5% / 2.5%
200 soft version 5 2.0% / 4.0% 3.0% / 3.0%
200 hard version + decay + feedback 3 22.0% / 4.5% 20.5% / 6.5%
2000 soft version none reaches the target - -
2000 hard version + decay + feedback 5 0.0% / 7.0% 0.0% / 10.0%

At 20 incidents the rule generalizes. At 200 it holds up only for one config; the other met the safety target by answering almost nothing (3.0% correct). At 2000 it breaks down: one config never reached the target, and the other "passed" with 0.0% correct answers by refusing nearly everything. Keeping errors under 10% at that scale meant giving up essentially all the help.

Why: a BM25 score measures overlap with the query, not correctness, and a big store is full of equally overlapping noise. (The hard-version configs also never answer "evergreen" cases, which flatters their precision.)

Caveats: thresholds are absolute BM25 scores, so they depend on query length and corpus. Each 0.5% is a single trial, so differences of a few points are within noise.

What I'd take away

  1. Store metadata (service, version, date) and filter or weight by it. Don't rely on text similarity.
  2. Treat version as a soft signal, not a hard filter.
  3. Never let success counts alone drive ranking.
  4. Add an abstain threshold and validate it on held-out data, but expect it to trade coverage for safety and to stop being useful as the store grows. Past a few hundred incidents, lexical scores are not a trustworthy confidence signal; that's where embeddings, a reranker, or a human-confirmed memory step have to come in.

Simulation assumptions

  • 200 trials per store size, fixed seed
  • 50% stale-trap, 50% evergreen
  • 25% of queries use a synonym absent from stored symptoms
  • Symptoms are 5-9 random tokens from a generic pool plus one signature word
  • Noise incidents have random service, signature, version and day, helped 0-2, failed 0-1

Code: https://github.com/PouyaBasiri/retrieval_study (memory.py, bench.py, bench2.py, bench3.py). Next post: I ran the same retrieval layer on a real project's git history: LINK_TO_POST_2