Essay · Agent Memory
AI Agent Memory: How to Preserve Sources and Detect Stale Context
AI agent memory can preserve outdated facts. Follow a compiler walkthrough to see how source links, version checks, and validation expose stale context.
By Carlos Shields-Davis · Published
Implementation walkthrough; proposed extensions
Suppose an agent’s project note says Atlas uses SQLite. The note links to a README, and the link works. But the application has moved to Postgres, and somebody updated the README without updating the note.
The agent has memory. It also has an outdated fact with a perfectly good source link.
This fictional example captures a problem I want to make easier to inspect: when an agent reuses a claim, can we tell where it came from and whether its evidence has changed? AI agent memory needs a policy for what survives between steps or sessions. It also needs a way to revisit what it keeps.
Memory, retrieval, and the context window
Memory stores information for later use. Retrieval finds relevant stored material. Context engineering decides what the model receives at a particular step, including instructions, history, tools, and retrieved evidence.
A system can use all three. An agent might save a project decision, retrieve it next week, and include it beside a recent tool result in its context. The engineering questions are different at each stage:
| Part of the system | Decision to make | Failure to look for |
|---|---|---|
| Memory | Which facts, decisions, or observations should persist? | A temporary observation becomes a durable assumption |
| Retrieval, including RAG | Which stored material is relevant to this task? | The right source is missed, or an old source is returned |
| Context engineering | What should the model see now? | Useful evidence is buried among irrelevant or contradictory material |
Anthropic’s context engineering article describes this work as curating the information available during inference. LangChain’s memory documentation makes an operational distinction between memory scoped to a thread and memory retained across threads or sessions.
Those terms help describe the system. They do not tell us whether the information it delivers is current. For that, we need to follow a claim back to its source.
What the Brain Vault Compiler does today
The Brain Vault Compiler takes curated source records and authored notes and writes them into a navigable set of Markdown files. Its outputs include source traces, canonical notes, maps, and context packs. Separate scripts check their structure.
The inputs are explicit. A SOURCES dictionary contains source paths, summaries, and statements about what each source supports. A registration function contains the note text. The generator writes those definitions into files and connects notes with source traces.
The interpretation has already happened before generation. The script does not independently read the archive, decide what a source means, or verify its support for a claim. A wider architecture might include those stages, but they are separate work.
This makes the current compiler a useful, modest case study. We can inspect which statements were selected, where they point, and how they become reusable context. We can also identify what a structural check leaves unanswered.
A saved validation report records six checks passing in the June 22, 2026 compilation. That is a historical result; no new compiler or validator run was performed for this article.
A source path is not a source version
One detail in the implementation is especially revealing. The source writer records a value labeled Path hash: a shortened SHA-256 digest of the source path string.
That identifies a path. It does not identify the bytes in the file at that path.
In the Atlas example, the README can change from “SQLite” to “Postgres” while remaining at atlas/README.md. Its path hash stays the same. The canonical note may still link correctly and pass a link check while describing the old database.
A content digest would let us detect a different kind of change. For a file-based system, the basic operation is small:
from hashlib import sha256
from pathlib import Path
def content_digest(path):
return sha256(Path(path).read_bytes()).hexdigest()
A proposed version check would save this digest when a claim is reviewed, then compare it with a later digest of the same source. A difference would mark affected claims for review. This is an extension readers could build, not a feature the current compiler already provides.
The check has a limit worth preserving. A formatting edit changes the digest. A substantive edit changes it too. The digest detects changed bytes; someone still has to decide whether the change affects a claim. An unchanged file can also contain an error.
Give each claim a route back to its evidence
For the fictional Atlas project, a record might look like this:
claim_id: "atlas.database"
claim: "Atlas uses Postgres."
source_path: "atlas/README.md"
source_revision: "<reviewed repository revision>"
source_content_sha256: "<digest captured at review>"
reviewed_at: "2026-10-18"
status: "current"
This is a proposed record with placeholders, not an extract from the private vault. The compact note gives the agent a usable fact. The source path, revision, and review date give a researcher somewhere to go when the fact is questioned.
I would keep source versions separately from the current claim. That allows an old note to retain the evidence on which it was based, even after a newer source becomes authoritative. Replacing the source silently would make the history harder to reconstruct.
Markdown and a manifest may be sufficient for a small collection that one person reviews. A database becomes useful when several processes update claims concurrently or need structured queries over their history. The storage choice follows those requirements; neither format supplies the review policy by itself.
Be precise about what “validated” means
The compiler’s checks cover files, paths, source references, manifest consistency, wikilinks, and credential-like strings. Each pass establishes a particular property.
| Check | What it can establish | Question still open |
|---|---|---|
| Required files and paths | Expected artifacts exist where the validator looks | Is their content accurate? |
| Source references and manifest | Expected identifiers and entries are present and consistent | Does the source support the note? |
| Wikilinks | Links resolve according to the validator’s rules | Is the linked material relevant to this task? |
| Credential-pattern scan | No configured pattern matched in the scanned files | What sensitive material falls outside those patterns or file types? |
I would report the property directly: “the expected links resolved” or “no configured credential pattern matched the scanned Markdown.” Calling the whole memory “validated” would imply more than those checks established.
Source-version detection would add another property to this table. It would tell us that evidence changed. It would still leave the meaning of the change to be evaluated.
Test what happens when a source changes
Before evaluating whether the memory helps an agent, I would exercise the pipeline with a small, fictional collection. Two sources and one note are enough to begin.
Run generation twice and compare the outputs, accounting for any intended timestamp changes. Then break a link, remove a required file, and omit a source reference in separate copies. Check that each validator catches the failure it claims to detect.
Next, edit a source without renaming it. The path hash should remain unchanged; a content digest should change. Follow the source reference back to every claim that may need review. That step tests whether the version signal actually reaches the notes that depend on it.
Only then would I ask whether an agent benefits. Give it defined questions about the collection, including a question whose answer changed in a newer source. Compare its answers with and without the compiled context. Preserve which source versions it received and whether its answers cite them correctly.
This is a proposed test procedure. File generation and passing structural checks are not evidence that the agent will answer better.
At Walking Stick Labs, the larger interest is how agents use inherited context in an environment. A map can be stale in much the same way as the Atlas note: the representation still exists, but a door has closed. When an agent makes a poor choice, I want to know whether it received an old observation, retrieved the wrong one, or failed to use information that was available.
Reading the Failure Logs takes that question into the action trace. Make the Model Commit examines how to make claims explicit enough to check. For the broader engineering choices around retrieval and compaction, Game Changer Labs’ context engineering guide provides an applied companion.
The source link is where I would start investigating an outdated answer. I would want it to lead to the version the agent actually used.
Carlos Shields-Davis writes at Walking Stick Labs, a research studio exploring spatial intelligence and artificial worlds. Explore the research.