Entry 12Agent memory · LLM review2026

A knowledge base that coding agents write to through an AI reviewer

Coding agents start each session with no memory of the last one. kb-mcp gives them a shared store of infrastructure facts, past decisions and standing rules, served over MCP (Model Context Protocol, the standard way agents call tools). Agents read it freely but cannot write to it directly. Every change is a proposal, and a separate, cheaper model approves, edits or rejects each one before a database trigger copies it into the tables agents read.

proposals, last 30 days257
accepted by the reviewer92.0%
vague long rules caught (pooled)27.8%
search MRR, before and after0.54 → 0.64

Why agents propose instead of writing

If an agent can write straight to shared memory, one wrong fact is loaded into every later session. If a person approves every write, the store stops growing when that person is busy. kb-mcp puts a model in the approval seat, and I step in only to override it.

Three kinds of writer send proposals: coding sessions; a reflector job, which reads batches of past session summaries and drafts rules from patterns that recur; and a pruner job, which proposes deleting records that were never durable.

How a proposal becomes a record

  • The MCP server checks the proposal’s shape and inserts it as pending. Its database login can add proposals and has no write grant on the tables agents read.
  • An insert trigger notifies the reviewer worker, which looks up near-duplicate records by embedding similarity (a numeric representation of meaning).
  • The model sees the proposal, the agent’s reasoning and those neighbours, but not which agent sent it. A malformed reply leaves the proposal pending and never counts as an approval.
  • A status change to approved fires a second trigger that writes the record. Rejections are shown at the start of later sessions so agents stop re-proposing them.

Where the write boundary leaked

A check of the live database in October 2026 found four ways around the permissions. In the most serious, the function that applies an approved proposal ran with its owner’s privileges and any login could call it, including the read-only ones. A migration closed each route and then checks the privilege, because a revoke reports success even when the privilege still arrives through another grant.

Replaying the migrations onto an empty database also produced no review gate, because a later file had redefined the insert trigger without it. Production hid this because the deploy script re-applied the gated version each time. The trigger now has one definition, and review is skipped only when the setting is exactly off. By my choice, the personal-scope login keeps a self-approve grant as a manual override, so agent sessions on my own machine can still bypass the gate.

What measuring the reviewer showed

A list of recent rejections has no denominator. In July 2026, 11 of 20 recent rejections cited one cause, which made the reflector look broken; its accept rate was 67%. The reviewer now reports full counts for each proposing agent and record type.

Those counts showed a gap on rules in July: the reviewer accepted 98.9% of rules from coding sessions and 52.7% from the reflector. The reflector used the reviewer’s own model, so I expected the reviewer to favour that writing. It was harder on it. The gap lined up with length: coding-session rules averaged 383 characters and the reflector’s 143.

To find out whether the reviewer was scoring length, it was tested offline with canaries: 48 bad rules (vague, duplicate, short-lived, or claiming too wide a scope) in matched pairs, one at about 140 and one at about 380 characters with the same defect, plus 24 approved rules as controls. The harness calls the production prompt and model code with database connections disabled, and the pass and fail bars were written before the run.

Canary cell, 3 passes eachShortLong
All bad rules caught (set 1, 24 pairs)93.1%75.0%
Vague rules caught (set 1, 6 pairs / 18 calls per cell)83.3%33.3%
Vague rules caught (set 2, 12 pairs / 36 calls per cell)52.8%25.0%
Vague rules caught (pooled, 18 pairs / 54 calls per cell)63.0%27.8%
Approved controls wrongly rejected (set 1, 24 rules)0 to 5.6%

Short-lived and over-broad canaries were caught equally at both lengths. In the first set, the gap sat in vague rules (33.3% caught when long, 83.3% when short). A second set of 12 new vague pairs pointed the same way (25.0% when long, 52.8% when short) but missed the pre-set bar for the short cell, so the length effect is recorded as inconclusive. Both sets agree that most long vague rules get through: 33.3% in the first set and 25.0% in the second (27.8% pooled across all 54 calls), against 83.3% and 52.8% of the short ones (63.0% pooled).

The live record matches. Of 13 coding-session rules rejected in the 60 days to 29 October, most duplicated a named record or overstated their scope, none was rejected as vague, and three were wrong rejections I overrode by refiling. In the 30 days to 3 November, the reviewer accepted 83.3% of 72 reflector rules and 81.2% of 16 coding-session rules.

What measuring the search showed

In July 2026, 70% of logged agent searches used five or more words, and those missed 40 to 60% of the time against 12.5% for one-word searches, because keyword search required every word to match. Before the search fell back to embedding search on an empty result, 89% of logged keyword searches returned nothing; in the 30 days to 19 July, after that change, 42.4% did. The store grew over the same period, so this is not a controlled comparison.

For a controlled one, I built 46 labelled queries from the log. The labels were drafted by a script that never calls the search code under test, so a search change cannot score well by construction. The search was changed to retry with any-word matching when the all-words query found nothing, and both versions were scored on the same snapshot of the data.

46 queries, August 2026All wordsWith retry
Recall@50.4840.542
Recall@100.5050.580
MRR0.5440.636
Queries with no results21.7%4.3%

Recall@5 is the share of a query’s relevant records that appear in the top five results. MRR (mean reciprocal rank) averages 1 divided by the position of the first relevant result. Half the set was drawn from queries that had hits, so its empty-result rate is lower than the production log’s.

Four review rounds then found 11 defects in the change, and the evaluation could detect none of them. Later, a switch of embedding model left the fallback’s similarity floor at a value tuned for the old model, where it discarded 0 of 68 relevant rows and let through all 2,232 noise rows. It was recalibrated to 0.80. The ranking gain was not statistically significant (MRR +0.014, p = 0.090); the floor was kept because it restored the log of searches that find nothing.

Limits

Who wrote the canaries

Claude, the coding agent, wrote them. Some vague ones resemble rules the store already holds and may be fair to approve, so the catch rates are a rough lower bound.

How large the evaluations are

Each canary cell holds 6 to 12 items, enough to tell 85% from 50% and too few to tell 85% from 75%. The search set is 46 queries over one store with one operator.

What the reviewer counts leave out

The counts cover the personal and shared scopes, and a second install that shares the database is excluded. Whether the reflector still uses the reviewer’s model has not been checked since the reviewer changed provider.

What is planned and not done

A test of wrong rejections against the proposals I overrode, and a rubric clause that rejects rules without a checkable trigger and action, to be measured with the same canaries. The rubric is unchanged.

Agent memoryLLM evaluation MCPPostgresRetrieval

Questions about the method? Email [email protected] · Back to portfolio