Two Memories, One Boundary: How Loa Decides What to Remember
Every session our agents run ends the same way. The context window closes, and whatever was worked out inside it is gone unless something wrote it down first. Loa, the framework our repos run on, has two places to write it down. The persistent memory reference that ships with Loa draws a line between them, and the line is recent: the mechanism itself is marked v1.28.0 in the reference, while the boundary arrived with v1.40.0. It is a small decision. It is also the kind of small decision that either pays back a little on every session or quietly charges a little on every session, so we want to lay it out.

Two systems, two owners
Claude Code carries its own persistent memory. It is file based, it lives in the user's project directory under the harness's own path, and it is described in the Claude Code memory documentation. Its subject is the person: how they prefer to work, which tools they reach for, how the project is laid out from their side of the keyboard.
Loa adds a second system on top. A hook called the memory writer watches tool outputs, and when it sees a learning signal it appends an observation to a file at grimoires/loa/memory/observations.jsonl. The file is JSON Lines, one JSON record per line. That choice matters more than it looks. Appending a line does not require rewriting the file, and scanning for a record does not require parsing the whole file into memory. For a store that a hook appends to whenever a signal fires, and that is read at the start of a session, both properties are load bearing.
The reference lists six learning signals that trigger a capture: discovered, learned, fixed, resolved, pattern, insight. These are the words an agent tends to emit when it has just worked something out. Matching on them is crude. It is also cheap, it runs without anyone deciding to remember anything, and it fits the shape of a Claude Code hook, which sees tool output and can act on it before the agent moves on.
The ownership table
Version 1.40.0 of the reference adds what it calls the ownership boundary. It is a table of eight scopes, four on each side.
- Auto-memory, owned by Claude Code: user preferences, working style, project structure, tooling preferences.
- Observations, owned by Loa hooks: framework patterns, anti-patterns, debugging discoveries, cross-session technical context.
Underneath the table sits a single decision rule, and it is the part we would keep if we had to throw the rest away. If the observation is about how the user works, it belongs to auto-memory. If it is about how the framework or the code works, it belongs to the observations file.
The rule reads cleanly, but one row asked us to slow down. Project structure sits on the Claude Code side. We would have guessed it belonged with the technical context. The reference does not explain the placement, so what follows is our reading, not the document's. The harness already learns project layout as part of how it serves the person, so Loa writing it again would be the exact duplication the boundary exists to stop. The decision rule is about ownership of the act of remembering, not about which facts feel technical.
Ask the ledger what it was told to forget.
The boundary is enforced at the writer, not the reader. The memory writer hook carries a skip-list, a set of patterns that stop it from recording observations that belong to auto-memory scope. This is a denylist, and we hold the usual view of denylists: they catch what they were written to catch. We expect some observations about working style to slip through when the phrasing does not match a pattern, and we have not measured how often that happens. The reference does not claim the skip-list is complete, and we will not claim it for them.
Progressive disclosure
The second half of the reference is about reading, and it is where the token accounting shows up. The query script offers three levels of detail, with approximate costs given in the document itself.
- Index: roughly 50 tokens per entry.
- Summary: roughly 200 tokens per entry.
- Full: roughly 500 tokens for a single observation fetched by id.
The script also filters by observation type and accepts free-text search terms.
.claude/scripts/memory-query.sh --index
.claude/scripts/memory-query.sh --summary --limit 5
.claude/scripts/memory-query.sh --full obs-1234567890-abc123
.claude/scripts/memory-query.sh --type learning
.claude/scripts/memory-query.sh "authentication pattern"The pattern is the same one we use for any large corpus an agent has to consult: pay for the cheapest view first, then pay for detail only on the entries that earned it. An agent starting work can read the index for the cost of a few paragraphs, pick out the observations that touch the task at hand, and pull the full record for those alone. Loading every observation at full detail would be the wrong default, and the reference does not offer it as one.
The cap
Configuration is a short YAML block, and we reproduce it as the reference gives it.
memory:
enabled: true
max_observations: 10000
capture:
discoveries: true
errors: trueThe cap of 10000 observations is a ceiling, and the reference does not say what happens when it is reached, so we will not guess at the eviction behavior. We will do one piece of arithmetic, scoped as a back-of-envelope estimate from the document's own figures: at roughly 50 tokens per index entry, a full index at the cap would run to around half a million tokens. That is more than we would want any session to spend on recall, which is why the summary view takes a limit flag and why the free-text search exists. The index is cheap per entry. It is not free in aggregate.
We read the two capture switches, discoveries and errors, as mapping onto the learning signals, with errors covering the fixed and resolved events, though the reference does not spell the mapping out. It ships with both switched on, and we see no reason to turn either off. A debugging discovery that is not written down is a debugging discovery we will make again.
What the boundary buys
Duplication in memory is billed twice: once when it is written, and again on every session that recalls it. Two writers aimed at the same scope also produce drift, where the same fact exists in two versions and the agent has no principled way to pick one. Ownership addresses both. When a memory turns out to be wrong, the decision rule says which system holds it, and that is the system to correct.
The boundary also makes each store legible on its own. A person reading auto-memory sees a description of how they work. A person reading the observations file sees what the fleet has learned about the code. Neither file has to be read against the other to make sense.
What we are watching
We are not yet in a position to report on how well the skip-list performs, how often the signal words fire on noise, or whether the type filter earns its place in practice. Those are measurements we have not taken, and the reference does not take them either. What we can say is that the shape is right: one writer per scope, a rule short enough to hold in mind, and a reader that lets an agent buy exactly as much memory as the task in front of it needs.
Get the next post
Free membership: new posts on how the fleet is built, delivered by email. Subscribe free
№ 2731