Here's a failure mode I keep worrying about.
Picture this. Months ago your team learned that a fetch helper retries on one specific error code. You saved that as a note so your coding agent would stop asking. Then someone rewrote the helper. The note stayed.
Today the agent reads that note, trusts it, and writes a confident patch around behaviour that no longer exists.
Nothing crashes. The tests pass, because they were updated with the rewrite and the patch doesn't touch them. The only thing standing between that patch and main is a reviewer who notices the diff looks a little too sure of itself.
I test databases at ClickHouse for a living. My whole job is asking "what is this assuming, and is it still true?" Agent memory, as most of us use it today, is a pile of assumptions with no expiry date.
That worry is why one feature in Loom exists. It's the part of the project I'm most attached to, so this post is about it.
The problem with agent memory
Every coding agent I use has some form of memory now. A CLAUDE.md file. An AGENTS.md. A notes folder. A vector store bolted onto an MCP server.
They all share one weakness. A memory is a sentence, and a sentence has no idea what it's about.
"fetch_page() retries on code 115" is a claim about a function. When that function changes, the claim might become false. But the memory store doesn't know the function exists, so it keeps serving the sentence with the same confidence forever.
Humans deal with this through context. You remember who told you, roughly when, and you have a feel for whether that part of the code has been churning. An agent starting a fresh session has none of that. It gets the text and nothing else.
So the question I kept coming back to was simple. What if a memory knew which code it was about, and could tell you when that code changed?
What Loom does
Loom is an open-source, self-hosted memory server for AI agents. It speaks MCP, HTTP, Python and TypeScript, and stores everything in ClickHouse. It has shared long-term memory, document search with citations, and a code index of your repositories.
The code index is what makes the interesting part possible.
When an agent saves a lesson that names a function in backticks or as a call, like `fetch_page()`, Loom tries to resolve that name to exactly one definition in the indexed repository. If it finds one, the lesson gets a link to that definition. Unqualified names need four or more characters, so a lesson that mentions get doesn't end up linked to half the codebase.
From then on, every indexed commit is a chance to check the link. A background worker compares the definition's tokens with the ones the lesson was written against, and the link ends up in one of five states:
- fresh: same definition, same text.
- moved: the file moved, or the function was renamed with nothing else changed.
-
changed: the function's text changed, and
changed_sincenames the commit that did it. - unresolved: the name is gone and something new may be it, but nothing certainly is.
- missing: the code is gone. The link keeps its place, so a revert finds it again.
Because the comparison is on tokens, whitespace, comments and most formatter runs leave a link fresh. I spent more time on that than I expected. A memory system that cries wolf every time someone runs a formatter is worse than one that never warns at all, because people learn to ignore it.
What it looks like from the agent's side
Here is the smallest version, with the Python SDK against a local Loom:
import asyncio
from loom import Agent
async def main() -> None:
async with Agent(org="dev", namespace="local", agent="lareb") as agent:
# The repo tag tells Loom which indexed repository the lesson is about.
await agent.memory.set(
"fetch_retry_rule",
"`fetch_page()` retries on code 115, not on 503",
tags=["repo:<your-repo-id>"],
)
# Later, possibly in another session or from another agent:
for hit in await agent.memory.search("when does fetch_page retry"):
print(hit.memory_key, hit.code_state, hit.code_changed_since)
asyncio.run(main())
Link passes run every 60 seconds and pick up writes that are at least 60 seconds old, so on an indexed trunk the link shows up within about two minutes. Right after saving, code_state reads fresh.
Now change one expression in the function body, commit, and push to the indexed trunk. Once the index and the link worker have processed that commit, the same search returns changed, and code_changed_since is that commit's hash.
The Claude Code and Codex plugins do the tagging for you. They pull lessons out of a session's transcript and tag them with the repository, so most of the time I never write that memory.set call by hand. The lessons just accumulate, and they carry their own warnings.
"Changed" is not "wrong"
This was the design decision I argued with myself about the longest.
When a function changes, the lesson about it might still be true. Maybe someone renamed a variable inside it. Maybe they added logging. Throwing the lesson away would lose real knowledge. Serving it as if nothing happened is how I got the bad patch.
So Loom does neither. A changed lesson is still served, but it arrives with the commit that changed the code. The agent is supposed to read the current body before acting on it. In the docs we phrase it as "this marks changed code, not a judgment that the lesson is false."
Code that is gone entirely is treated more strictly. By default, search leaves out a memory whose code is all gone, unless a person pinned, locked or verified it. If a human said "keep this", it stays.
Renames get special care too. If you only rename the function, the link worker can rewrite the name inside the lesson's text on the next pass, and the link reads fresh at the new symbol. Where it can't safely rewrite the text, the link still records the new symbol with a was_symbol field holding the old name, so whoever reads it can connect the two.
How I test it, since that's the day job
I'm a QA engineer, so the feature only counts if something tries to break it on every change.
There's an integration test, test_memories_follow_their_code, that walks a lesson through commits and checks fresh, changed, a pure move (moved), removed code (missing), and a release branch where the unchanged definition still reads fresh even though trunk changed it.
On top of that, a packaged MCP smoke test saves a lesson, checks it's fresh, commits a body edit, and waits for the workers to report changed with that exact commit. A second harness restarts the Loom service and checks the link survives. CI runs both on amd64 and arm64.
What those checks don't cover matters too. They verify link state. They don't test answer quality or whether the agent actually reads the warning. A tool being available doesn't mean the model uses it.
Does any of this save money?
The README has numbers. Here they are, with the parts people tend to skip.
| Evaluation | With Loom | Without Loom | Efficiency gain |
|---|---|---|---|
| Coding-agent answer quality | 0.84 | 0.78 | 20% lower model cost |
| Coding-agent file localization | 96.4% | 91.4% | 21% lower model cost |
| Memory vs full-history answers | 94% | 90% | 91% fewer reader prompt tokens |
The two coding rows are Claude Code on the ClickHouse codebase: 24 questions with 3 paired runs for answer quality, and 36 questions with 10 paired runs for file localization. Cost is the whole session's model bill, and it excludes Loom's own server-side model calls, hosting and indexing. The memory row uses 100 paired LongMemEval-S questions with the same reader model, and the 94% vs 90% difference is descriptive, not statistically established.
Separately, Loom's memory.ask configuration scored 96.6% on all 500 LongMemEval-S questions. That's a product evaluation with its own answer models, not the same fixed-reader comparison.
None of these benchmarks measure the stale-memory feature directly. That one is harder to put in a table. What I can say is how the scenario at the top plays out with Loom: the stale note arrives marked changed, with the commit that changed the code, and the agent is pointed at the current body before it writes anything.
Try it, and tell me where it breaks
Loom runs locally with Docker. The default personal setup has no login and only listens on localhost:
curl -fsSL https://github.com/ClickHouse/loom/releases/latest/download/install.sh -o loom-install.sh && sh loom-install.sh && rm loom-install.sh
If you'd rather not install anything, there's a playground at loom.clickhouse.com where you can change a retry rule in a sample function and watch the saved lesson go from fresh to changed.
The repo is github.com/ClickHouse/loom. It's Apache-2.0.
I'd really like to hear from people who've hit the stale-memory problem in their own setup, and from anyone who finds a case where a link stays fresh when it shouldn't. That's the bug I most want to know about.

Top comments (6)
the note stays and the code moves on. a memory with no expiry date is just an old claim served with the same confidence.
Agreed. That is why I tie code facts to the commit they were written at, so whoever reads them can see when the code has moved on since. Confidence should come with a date.
exactly, a fact without a date is just a guess wearing confidence. tying it to the commit keeps it honest.
Nicely put, Robert. Curious where stale notes bite you most: docs, tickets or agent memory?
Stale context is an underrated problem. Associating project knowledge with a commit or version could make agent memory considerably more dependable.
Thanks! That was the whole idea: a fact about code should carry the version it was true at, so the agent can tell when a note may be out of date instead of trusting it blindly. How do you deal with stale context today?