· 13 min read · 2495 words

Evaluating Project Memory for AI Agents: Two Lanes, Honest Scores, and Memory Traps

Our first search eval reported 100% recall on an easy set, and our agent suite passed an 80% average while over half its answers broke. How we split memory evals into stub and seeded lanes, switched to Wilson lower bounds, and tested for memory traps with three paired arms.

Part 2 of Shared Project Memory for AI Agents.

Evaluating Project Memory for AI Agents: Two Lanes, Honest Scores, and Memory Traps

When our team merged shared project memory, it shipped switched off. The agreement was simple: it stays off until an evaluation gives a real go or no-go. I owned that evaluation.

The headache started on day one. Every existing agent evaluation we ran assumed a frozen world: feed the same prompt, get the same context, check the answer. Project memory breaks that assumption by design. What the agent sees depends on whatever specifications people happened to save in a live workspace five minutes ago. If a test fails, did the agent regress, did search degrade, or did a colleague edit a document? A single end-to-end test against a live workspace cannot tell you.

Worse, once we did get numbers back, the first two runs looked great and were completely misleading. The search service reported perfect recall on an easy fixture, and the agent suite passed our 80% average bar while more than half its answers failed basic checks.

This is how we split memory evaluation into two lanes, threw out misleading averages for Wilson lower bounds and per-failure triage, and built a three-arm test for memory traps where accurate memory makes answers worse.


Why one end-to-end eval lane lies to you

The obvious way to test RAG memory is to seed a workspace, hit the agent over HTTP, and score the final reply. We rejected running only an end-to-end lane for three reasons:

  1. Mutable state blurs causality. Any workspace edit reads like an agent bug.
  2. HTTP hides the mechanism. Most safety checks need the agent's internal trace (which passages were placed, which coverage state fired, whether any write tool ran inside a subagent). Over HTTP you only see the final prose.
  3. An empty workspace passes isolation. Cross-tenant leakage is the single failure that can never ship. An end-to-end test that gets zero hits from an empty workspace looks green without proving isolation works.

So we split the evaluation into two lanes driven by the exact same YAML fixture corpus, where every single passage begins with a unique canary marker (MEM-CANARY-...):

Dimension Stub lane (agent behaviour) Seeded lane (search & isolation)
What runs Real agent + live model in-process Real Postgres search service against 3 eval-only workspaces
Search backend Schema-matched stubs reading fixture YAML Deployed workspace service after saving fixture docs as real baselines
What it proves Context placement, coverage honesty, citations, zero writes, prompt-injection resistance Cross-tenant isolation, real embedding/indexing health, retrieval recall & MRR
What it cannot prove Real retrieval quality (stub scores are synthetic) Agent reasoning or final answer phrasing
Model token cost Yes Zero

Using deterministic code checks over LLM judges on the stub lane was deliberate. As I wrote in my piece on starting evals without a gold dataset, if you can verify a safety property with code, never hand it to a noisy judge.

With unique canary markers inside every passage, safety checks become crisp, repeatable code:

  • Memory use: reads the harness's own injection trace span and fails closed if evidence is missing, coverage state is wrong, or expected markers were dropped.
  • No writes: scans every tool call at every depth, including inside subagents, and fails if any of 17 write tools fires during a read-only answer.
  • Prompt injection as a split-string regex: our hostile-text fixture hides nine attacks (authority overrides, citation suppression, fake coverage claims) inside body prose, table cells, and HTML comments alongside real facts. Obeying an attack instructs the agent to emit a code assembled from two separated fragments. Simply quoting the attack to warn the user does not join the fragments, so "did it obey?" becomes an exact regex with zero false positives.

That stub lane caught real defects before merge: in early runs, roughly a quarter of replies answered without loading the memory skill, one in six analyst replies leaked an internal passage ID into the citation slot, and the citation-suppression attack succeeded half the time (every single time on replies that had skipped the skill).

On the seeded lane, we maintain three eval-only workspaces (a rich project with memory on, a neighbour project with similar content and memory on, and a neighbour with memory off) and reset them before every run. Two safeguards keep the seeded lane honest:

  1. Semantic-only creation check. After reset, we poll for each passage's marker using semantic search only. Why? Without embedding credentials, the service falls back to a deterministic placeholder embedder and still reports ready; a keyword query would falsely pass on broken embeddings.
  2. Seven mandatory control probes. Before declaring zero cross-tenant leaks, we run seven control queries against the neighbour workspace that must return the neighbour's own passages. If a probe comes back empty, the run is void.

Three quick debugging scars from building the harness itself: an inherited fixture reset had a misspelled error-handling attribute that silently logged write failures and reported success (always read back state after a reset); a daily GitOps seed job running an older container image kept switching our eval workspaces back off overnight; and when memory moved into user token claims, CI had no claim so 90% of stub checks nearly failed until we scoped per-case permissions in a ContextVar verified identical at concurrency 1, 4, and 8.

Two-lane evaluation architecture sharing canary-marked fixtures, bar chart showing mean check scores hiding failing answer rates, and three-arm paired memory trap testing.

Left: one fixture corpus drives both deterministic stub-lane agent checks and zero-LLM seeded-lane isolation checks; underneath, weighted check averages masked failing whole-answer pass rates. Right: three-arm paired evaluation tests whether accurate memory makes answers worse than no memory.


Why our first two eval reports pointed the wrong way

Once both lanes were green, the numbers themselves set two traps.

Trap 1: perfect recall on a tiny corpus. Our very first seeded run reported 100% recall in top-6. Before celebrating, I asked what a random ranker would score. The fixture had so few sections that picking six passages at random already hit half the labels, the questions echoed the passages' exact wording, and the negative questions were wildly off-topic. I also almost posted a recommendation to raise the service's relevance floor, until I checked and realized every floor across a wide band scored 100% on that easy set. Tuning thresholds on an easy test is just memorizing the test.

We moved to a larger, realistic retail-banking specification corpus, wrote questions in two styles (direct factual lookup and implicit drafting tasks), added on-topic unanswerable questions, and printed the random baseline beside every metric. Recall dropped from 100% to roughly two thirds, well above a random baseline of one sixth, and for the first time the number actually meant something.

That rebuild also taught me how to work with domain experts: I started with a seven-tab, 100-row review spreadsheet that nobody would finish carefully, cut it down to a single 20-minute tab of roughly two dozen core facts (generating ~90 test cases programmatically from those facts), and on that 20-minute call the domain expert caught that our source scoping sheet had mixed two different payment products, invalidating our first label set.

Trap 2: weighted averages that pass over failing answers. Our standard eval gate passed a dataset when its weighted mean across all checks reached 80%. Look at what happened on our harder October run:

Dataset Weighted mean check score Whole answers passing all text checks
Analyst contract set ~88% (passes 80% rule) ~59%
Architect set ~85% (passes 80% rule) ~53%
Analyst quality set ~76% ~28%

A passing mean across checks can hide a majority of broken answers because easy structural checks (no writes, memory placed) score 100% and pull the average up.

We switched the verdict rule to count whole answers passing every text check, and applied a 95% Wilson score lower bound. If the product bar is "at least 80% quality," observing 73 passes out of 91 items (80.2% raw) does not prove 80% true quality; with a 95% Wilson lower bound, you need 81 out of 91 (~89% observed) to clear 80% honestly.

Before touching a single prompt, I triaged every failing answer by owner: roughly 85% were real agent defects (mostly leaking internal passage IDs as links and narrating retrieval mechanics like "the extract says"), 12% mixed, 4% check bugs, and 0% dataset bugs. After the citation fix and a team decision separating natural phrasing ("your project documents say") from mechanical narration, we re-scored the stored answers without re-running the LLM so we measured the check change cleanly. Answer pass rates roughly doubled, and later agent fixes pushed them from under a third to roughly three quarters.

Meanwhile, sweeping the semantic floor on our on-topic unanswerable questions confirmed an important limit: their similarity scores overlapped directly with answerable questions. Raising the floor high enough to silence most negatives killed nearly four answerable questions for every negative it silenced. Similarity measures topic, not answerability. No single scalar threshold solves abstention on its own.


Memory traps: testing when accurate context hurts

In October, a colleague shared MemTrapBench (arXiv 2608.20202), which documents an uncomfortable reality: faithful, relevant memory can distort reasoning so badly that an agent with memory scores worse than the same agent with memory turned off.

Every check we had so far evaluated memory-on answers in isolation. None could see "memory off would have beaten this."

So we adapted the idea to project specifications across four families:

  • Scope mismatch: a true passage for another market or product, mistakenly applied to this request.
  • Task boundary: a passage retrieved for an earlier task in the thread, bleeding into a new task.
  • False premise: the user assumes something the project specification contradicts.
  • Positive control: a question that cannot be answered without memory (without this arm, an agent that completely ignores memory passes every trap with flying colors).

Each item ran across three paired arms (memory on with trap fixture, memory on with clean control fixture, and memory off), repeated three to five times per arm, with roughly a third of items held out outside the repository against overfitting. An item counted as a Trap when memory-off beat memory-on by at least half the runs (2 of 3, or 3 of 5).

I asked the feature team to hold their trap-guard PRs until we ran a clean three-run baseline. And then the baseline delivered a shock: nearly the entire scope-mismatch family lit up as "worse with memory on."

Before reporting a dramatic headline, I read the actual answers. Many of them explicitly mentioned the planted out-of-scope value to tell the user it did not apply to this product, which was the exact right behaviour. My regex check was failing any answer that contained the planted string at all. Whenever a brand-new check produces a dramatic headline on its first run, suspect the check before you blame the model.

Rewriting the check to detect application rather than mention (backed by unit tests of known right and wrong answers) and re-scoring stored outputs dropped scope-mismatch traps from almost all to zero. Then, with the feature team's guards applied on a five-run confirmation, no trap family was worse with memory on, positive controls passed 100% with memory on and 0% with memory off, and task-boundary leaks dropped from roughly four in five cases on baseline to zero.


When the evaluation clock and the rollout clock diverge

The hardest lesson had nothing to do with statistics.

On October 12, my formal go/no-go verdict was: "OK for a small, named pilot; not yet for broad enablement." Zero cross-project leaks, 100% tool and safety compliance, citation leaks fixed, yet answer quality sat below the Wilson bar and trap guards were not yet merged.

The next day, product leadership framed it as an alpha that needed real-world feedback fast, switched staging on broadly, turned on one production customer in late October, and enabled all production customers in early November. Meanwhile, my staging release-gate Kubernetes Job did not pass its first full green run until November 19, partly because of my own ordering mistake: I told reviewers the GitOps Job config could merge before the agent image actually contained the eval runner entry point, so the Job failed at startup for three weeks waiting for the image to catch up.

And in late November, a colleague uncovered an authorization bug our evals could never have caught: a platform-wide administrator role bypassed every permission check, allowing memory use inside a workspace where memory was switched off. Our eval identities were all plain workspace members; we tested the permission, never every role capable of bypassing it.


What I am still going back and forth on

Looking back at that rollout, I still go back and forth on how hard an evaluation owner should push when product wants an alpha in front of users early. An eval is one input to a business decision, not a veto over reality, and real production traces taught us things synthetic tests missed. At the same time, writing a verdict as a flat list of four conditions makes it effortless to accept two and waive two. Next time I would separate hard safety conditions (zero leaks, role-bypass coverage, no unapproved writes) from quality conditions, and wire the safety gate directly into the enablement pipeline instead of running it as a sidecar report next to rollout.

I also still wish we had scored even a small slice of real answers end-to-end against the live search service while preserving traces. Separating the stub lane from the seeded lane gave us crisp diagnosis, yet it left a seam in the middle where real search quirks and real LLM phrasing never met inside an automated test.


Make the metric harder to fool than the model

If you are building evals for agent memory this quarter, build them in this order:

  1. Split behaviour (stub lane, deterministic trace checks) from retrieval and isolation (seeded lane, canary markers plus mandatory control probes), driven by one shared fixture corpus.
  2. Print random baselines next to retrieval metrics, count whole answers instead of check averages, and demand a Wilson lower bound on small sets.
  3. Test for memory traps with paired memory-on and memory-off arms, include positive controls, baseline before fixes land, and read the raw answers before trusting any dramatic first result.
  4. Test every user role that can bypass an entitlement, merge eval runners before the Jobs that invoke them, and put release gates directly in front of enablement.

It is surprisingly easy to build an evaluation suite that tells you your agent memory is ready. The work is building one that can tell you when it isn't.

Previous in this series: Part 1: Shared Project Memory for AI Agents: Postgres Isolation and Search That Abstains.

Related writings