What an Agent RemembersDOI: 10.XXXX/XXXXXXX.XXXXXXXConference: 32nd Conference on Pattern Languages of Programs, People, and Practices; October 12–15, 2025; Skamania Lodge, Columbia River Gorge, Washington, USA.ISBN: 978-1-941652-22-0DOI: 10.64346/PLoP2025p24CCS: Software and its engineering Software creation and management Software development process management Software development methods Design patternsCCS: Computing methodologies Artificial intelligence Distributed artificial intelligence Intelligent agentsCCS: Applied computing Operations researchCCS: Computing methodologies Modeling and simulationConference: ; ;
Abstract.
This working paper specifies, as a small catalogue of design patterns, the memory system we have been building for a set of coding and proving agents. It is a sequel to the pattern paper (plop-2026) and the implementation audit (futon-2026). Those papers stated the agent’s control loop as twenty R-numbered patterns and sketched a transplant of them onto the Zai harness; the transplant’s first row was a “memory seam”. The memory work since then was built without being tied back to those patterns. Here each memory pattern names the R-number it extends and the transplant row it continues, and each carries a note on what is built, what is checked and what is missing. The catalogue is meant to be annotated against the code in the way the PLoP catalogue was, so that drift between the specification and the system shows up as data.
1. Introduction
The pattern paper (plop-2026) described an agent’s control loop as twenty R-numbered patterns, and its companion appendix sketched a transplant of that loop onto the Zai harness. The first row of the transplant was a memory seam: deliberate memories enter as typed observations (R2), recall supplies warrants to the choice of action (R6), and a proposal is kept apart from the witness that would make it count (R9, R16).
Since then we have built a memory system — a store of versioned memories, an observer that reads finished turns, and a per-turn view of what the shared record knows — mostly without going back to those patterns. Two things went wrong in a way the earlier papers predict. A mechanism was built before the inference it serves was written down: a view of the record was refreshed on a thirty-minute timer, when the inference it serves needs an answer before the next turn starts. And a check covered only the normal route: the rule that every turn leaves an evidence row was never exercised on turns that stopped at a round cap, so those turns left none and nothing failed.
This paper restates the memory system as patterns, so that it has a specification at the same grain as the pattern paper’s catalogue. Each entry names the R-number it extends and the transplant row it continues, and ends with a status. The intent is that the catalogue can then be annotated span by span against the code, as the PLoP catalogue was, and that a disagreement between the two is settled by a stated rule rather than by whichever was edited last.
The paper’s second job is to link each informal pattern to its formal specification, or to say that it has none. The PLoP annotation pass found that many of the War Machine’s patterns had no formal specification at all, and that what had one was often not on the live route. So each entry here ends with two notes: Status, what the code does, and Formal, which Lean statement, if any, the pattern answers to, and whether the running system is checked against it.
WORK IN PROGRESS, 2026-10-19. First draft by claude-3 at Joe’s request; R-number attributions revised after a read by claude-4 the same day (M2, M3, M4, M5, M7 re-attributed; M9 added). The statuses are from the code and records as of this date; where something was not checked, the status says so.1.1. The parts of the system
- The evidence store.:
-
Every agent turn, tool round and coordination act is appended as a typed row through one function, the evidence boundary. This is the record the rest reads.
- The memory store (“minus40”).:
-
A bitemporal store of memories: each memory has versions, each version has the time it was said and the time it refers to, and contradictions between memories are kept as open obligations (“sorries”) until judged. Agents reach it through a small set of tools: assert, find, find-near, history, as-of, and discharge.
- The turn reader (象).:
-
Reads each operator turn and each reply as intents and the patterns they bear on.
- The observer (馬).:
-
After a turn finishes, reads the turn and writes a short card for the agent’s state; for a long proof task it can record the progress made and continue the work in a new episode.
- FUTON’s view.:
-
A per-turn summary of what the shared record knows that bears on the turn: the same work, the same mission, and related missions.
2. The revision rule
The War Machine’s rule is that the code must be an accurate model of active inference: a discrepancy between code and theory changes the code, a discrepancy between documentation and valid code changes the documentation. The memory system needs a referee in the same position. We propose the following, stated as the inference the system has to support at each turn.
At every turn of an agent, the system answers four questions:
- Q1:
-
What work is this turn on? Ready when is recorded.
- Q2:
-
What does the record know that bears on it, at each zoom (this work, this mission, related missions)? Ready when the turn reader’s reading of lands.
- Q3:
-
What does teach the links between missions and patterns? Ready at the same moment as Q2.
- Q4:
-
What is the agent’s state now? Ready after the observer’s pass on the reply.
Each answer must be current before turn starts, because that is when a memory would be put in front of the agent. A memory is useful only if, at some later turn, it is delivered in time and changes what the agent does. Under this rule, a mechanism that cannot meet the deadline is a code defect, and a document that describes a mechanism the code does not have is a documentation defect.
PROPOSED, not adopted. Joe has not ruled on this as the referee. The Q1–Q4 table is in futon3c holes/excursions/E-prove-memory-useful.md (2026-10-17).3. Crosswalk
| M | Pattern | R | Transplant row | Status | Formal |
|---|---|---|---|---|---|
| M1 | Memory as a Typed Observation | R2 | Memory seam | built; consumption by the controller not established | none |
| M2 | Two Times per Fact | R9, R12 | Transcript persistence | built, tested | partial: one time axis |
| M3 | Contradiction as an Open Obligation | R2, R9 | Memory seam | built; checked live once | stated, bound to the carrier; not run on the store |
| M4 | Proposals Stay Proposals | R9, R17 | Memory seam | proposals made, none applied; no witness route | partial; not run on the store |
| M5 | Retrieval Proposes, the Store Decides | R6, R9 | Text sidecar | text route re-checks; near route does not | none |
| M6 | A Memory Earns Its Place by Changing a Later Turn | R8 | Live A/B (Z3) | delivery built; effect not yet measured | preregistered, not run |
| M7 | Answers Due Before the Next Turn | R10, R20 | Controller (Z2) | built, event-driven; first live run | none |
| M8 | Episodes Extended by Memory | R15 | Controller (Z2) | observed live on one chain; effect not measured | none |
| M9 | Memories Weighted by Their Standing | R7 | Memory seam | not built | none |
4. The patterns
M1. Memory as a Typed Observation (extends R2).
If you want what an agent was told in earlier sessions to bear on what it does now. However memories kept as free text in a prompt file are read by rhetoric: nothing can weigh them, compare them across turns, or say which one was used. Then make each memory a typed record — an identity, a version, the text, its source — and enter it into the agent’s observation the same way any other channel enters, so that a turn’s record can say which memories were in front of the agent. Because a memory that is an observation can be given a precision, counted when it is used, and found absent when it is not. Status. The store holds Claude Code memory files as versioned records, imported by a hook on each write. Delivery into a seat’s context before its first round, with an injected edge on the turn record, is built for Claude and Zai seats. Whether the Zai controller weighs memories as an observation channel with a precision, as R2 and R7 would have it, is not established.
Formal. None for memory. The War Machine’s R2 has a declared channel vocabulary in Lean (mathlib4/DarkTower/WarMachine/ChannelWitness.lean, declaredVocabulary); memory is not one of its channels.
M2. Two Times per Fact (extends R9 and R12).
If you want an agent’s belief about the world to be revisable without losing what it believed before. However a memory store that overwrites cannot answer “what did we hold on Tuesday”, and one that records only when a line was written confuses when something was said with when it was true. Then give every memory version two times: when it was said, and the time it refers to — with “unknown” as a recorded value when the text gives no date — and answer reads as of a stated time. Because claims about the agent’s own past are then checked against the record rather than narrated (R9, through the transcript-persistence row); and calibration over predicted-against-realised pairs (R12) needs reads as of the time of the prediction, or later knowledge leaks into the score. Status. Built (minus40 milestone 2, 2026-10-10, extended 10-11). Tested: a read as of a said time returns each memory’s text at that time; an undated line has referent “unknown” and a dated one has its date.
Formal. Partial. Cool Memories (mathlib4/DarkTower/CoolMemories.lean, 2026-10-13) proves, for snapshots of the facts live at a time, that applying the net difference between two snapshots yields the second (run_source) and that consecutive differences compose (between_seq_eq_between); a checker (mathlib4/DarkTower/CoolMemoriesTraceChecker.lean) verifies the differences the memory store exports, with four planted corruptions caught. This covers one time axis. The two times of this pattern — said and referred to — are not formalised.
M3. Contradiction as an Open Obligation (extends R2 and R9).
If memories accumulate from many sessions and agents. However they will contradict each other, and a store that silently keeps the newer one, or silently keeps both, hands the contradiction to whichever agent next reads it. Then when a new memory conflicts with an old one, open an obligation (a “sorry”) quoting both verbatim, have it judged by a reader that did not write either, and keep it open until it is discharged with a stated resolution. Because a contradiction recorded as work to do can be counted and closed; one absorbed by the store cannot be seen at all. The judge being separate from the writer is R9; the open count is an observation feature, as R2 lists “contradiction flags” among its channels. Status. Built (minus40 milestone 3, 2026-10-11): candidate pairs are found, judged by a model call, and kept with their state. A planted contradiction became an open proposed sorry with both quotes verbatim within one worker pass (about 20 s), checked live once. The open count is not yet entered as an observation channel. That the worker turns a contradiction into a sorry within one pass is a property of how the machine runs, and could be watched by a R20 wire; none does.
Formal. Partial: the predicate is stated, nothing is bound to it. mathlib4/DarkTower/MemoryClaims.lean (2026-10-19, zai-6) states conflict between two claims in the 3/2-blend carrier’s own encoding: a second value for a functional relation, or a claim and its negation on the same subject and value. It proves the conflict symmetric and irreflexive, catches the corner store (corner_store_inconsistent: the store at 23rd Street and at 40th Street), leaves a non-functional relation with two values alone, catches a claim with its negation, and shows that a sub-theory of a consistent theory is consistent. The carrier alone does not catch the corner store: its consistency check (inconsistencyWitness_none_iff in mathlib4/DarkTower/WarMachine/ThreeHalvesBlend.lean) asks only that no shared element is sent to two places. The predicate is bound to the carrier in mathlib4/DarkTower/MemoryCones.lean (zai-6): a combination of two memories is admissible when the carrier’s check passes and the combined theory has no conflict. The corner store is proved to pass the carrier’s check and fail admissibility (corner_store_cone_gap). Not yet done: checking the memory store’s sorries against the predicate; today they come from a model’s judgement. The encoding has no key slot, so a keyed attribute must be folded into its subject.
M4. Proposals Stay Proposals (extends R9 and R17).
If the store can see that two memories are the same, or that one supersedes another. However an automatic merge or supersession is the store certifying its own judgement, and a wrong one destroys the memory it removes. Then record the merge or supersession as a proposal with its evidence, and apply it only through a witness the proposer did not produce — the operator’s acceptance, or a second reader’s check, counted only when it is corroborated from a record the proposer does not control. Propose a merge or supersession when it reduces the model by a stated amount, not on a model call’s judgement alone. Because the cost of a missed merge is a duplicate, and the cost of a wrong one is a lost memory; only the second needs a witness (R9). A merge or supersession is a model reduction, and R17 supplies a threshold for proposing one (); R17′′, nearness in an embedding, is where the candidate pairs here and in M3 come from. Status. Proposals are made: 32 supersessions and a set of alias merges were proposed in 2026-10. None has been applied, because no witness route exists. This is the pattern paper’s “built but off the live route” case: the proposals are made, and nothing on the live route reads them. The proposals are made by a model’s judgement, not by a reduction threshold.
Formal. Partial, not bound to the store. A merge of two memories is a cone of the 3/2-blend carrier, and mathlib4/DarkTower/MemoryCones.lean states when one is admissible (coneMemoryAdmissible: no clashing identification and no conflicting claims; M3). The carrier also ranks candidate combinations partially (Cone.qualityLE, reflexive and transitive). Three of the open-items specification’s admissibility conditions are not yet stated (that named claims are carried along each leg, coverage, and non-degeneracy), and no merge the memory store proposes is checked against any of this. The War Machine’s R17 reduction has a Lean witness (mathlib4/DarkTower/WarMachine/BayesianModelReductionWitness.lean) that no memory operation instantiates.
M5. Retrieval Proposes, the Store Decides (extends R6 and R9).
If you want an agent to find the memories that bear on its task. However similarity search ranks by nearness of wording, and a near memory can be stale, superseded or contradicted. Then use text and embedding search only to propose a bounded set of candidates; fetch each candidate again by identity, and check its current version and its open obligations, before it is shown to the agent. Give every candidate the store rejects a typed reason (stale, superseded, open sorry), and count the reasons; when nothing survives, say so with the reasons. Because the search index is rebuilt from the store and can lag it; the store is where a memory’s standing is decided, and an index that certified its own hits would be R9’s self-certification. A bounded candidate set with explicit reasons for inclusion and exclusion is what R6 asks of the action space. Status. Fact embeddings and near-search are built (minus40 milestone 5, part 1, 2026-10-15) and exposed as tools. The text route re-checks on the server. The near route does not: it ranks against a cache of facts up to 600 s old unless asked for a fresh read, filters by currency only when a time is given, and never consults open sorries (checked by claude-4 against minus40 b68c852). Rejections are not typed or counted.
Formal. None for the re-check. An earlier memory programme preregistered, in Lean, which retrieval arm delivers memories (mathlib4/DarkTower/MemoryArmPreregistration.lean, 2026-08); that concerns arms, not the store’s standing check.
M6. A Memory Earns Its Place by Changing a Later Turn (extends R8).
If you want to know whether the memory system is worth what it costs. However a store full of memories that no turn reads is, in the pattern paper’s word for an unread number, decoration; and a count of memories stored or retrieved says nothing about whether any of them changed what an agent did. Then hold each memory to three checks, in the order they can be made: delivery (it was in the agent’s context before the first round, and the record says so), effect (on a task the agent fails without it, the agent succeeds with it, and it is the deciding fact), and absence (when nothing was delivered, the record says so in words). Because this is R8’s invariant applied to memory: every number in the trace has a reader that can be named, and every memory must have a turn it changed. Status. Delivery is built and recorded. Effect is not measured. A protocol is written (prove a blueprint’s lemmas once, distil memories that are facts about the workspace and the library and never proof text, reset, prove again with the memories delivered) and has not been run to completion.
Formal. Preregistration only. The same earlier programme preregistered this pattern’s effect test in Lean (mathlib4/DarkTower/MemoryAblationPreregistration.lean, 2026-08): does withholding a memory change the outcome, with a sign test over paired runs. It typechecks; as far as the record shows it was never run, and it was written for the earlier memory system, not this one.
M7. Answers Due Before the Next Turn (extends R10 and R20).
If memories and views of the record are to be in front of an agent when it acts. However a refresh on a timer is the pattern paper’s no-op trap in another form: it fires on schedule whether or not anything changed, and when something does change it is up to one period late. Then state the inference each view serves and its deadline (Q1–Q4, Section 2), and drive every update from the event that makes an answer stale: a turn recorded, a reading landed, a turn finished. Count a refresh as live only if the view changed or was read (R10). Raise the finishing of a turn as one event, from the single place every row passes through, on every way a turn can end. Because the deadline is set by the next turn, not by a clock; and a check or listener attached to that one event sees every ending, including the ones a separate audit forgets. Events at phase boundaries are what R20’s wires need: a phase that emits no event cannot be watched, which is the failure the PLoP annotation pass found in the War Machine’s post-selection stages. Whether a given loop is driven by a schedule, back to back, or by events can be configuration; what this pattern fixes is that an answer is current by its deadline. Status. Built 2026-10-17 (futon3c 64e5254bf, 90eb10194). The view is recomputed per session on the turn reader’s events; on the first live event it was published 2.25 s after the reading. Turn finalisation is raised by the evidence boundary in two phases, before and after the row is stored. Zai turns that stopped at the round cap, an interrupt or the wall clock wrote no final row until this change; they now write one, with the reason. The observer runs on the after phase; the before phase has no listener yet. No refresh is yet checked for having changed or been read.
Formal. None. The War Machine’s R20 has a Lean module (mathlib4/DarkTower/WarMachine/R20Interoception.lean); no turn event or answer deadline is stated in Lean.
M8. Episodes Extended by Memory (extends R15).
If a task — a proof, say — is longer than one turn’s budget. However when a turn stops at its cap, the next turn either starts from nothing or is handed the whole transcript, and both waste the work done. Then have the observer read the finished episode, record the progress made as a memory bound to the task, and continue the task in a new episode whose first context is that memory — up to a fixed number of episodes, each naming the episode it continues. Because the memory is the extension of the episode: what the next episode needs from the last is the progress, not the transcript. This is R15’s temporal depth at the grain of turns. Status. Observed live on 2026-10-17: a Zai seat’s proof episode finished at its cap, the observer recorded the progress, and episodes 2, 3 and 4 of the same chain each began with that memory. Whether the chain converges faster than restarting was not measured. Two R15 constraints are not yet met. R15 rejects unwitnessed learning, and the progress memory is the observer’s account, not checked (for a proof, by Lean checking the claimed progress). And an episode that stops at its cap is a machine stop: the progress memory and any per-task statistics should keep “stopped at cap” apart from “made no progress”, which the War Machine was found not to do for its own apparatus failures.
Formal. None.
M9. Memories Weighted by Their Standing (extends R7).
If memories of different standing reach the same turn: one stated by the operator yesterday, one inferred by an agent a month ago, one with an open contradiction. However delivered side by side they carry equal weight, and dropping the weaker ones loses what they do say. Then keep a precision per memory source and state (who said it, how old it is, whether it has an open sorry), apply it wherever a memory is ranked, delivered or used in scoring, and record the weight with the delivery. Because R7’s reason holds here unchanged: without an explicit precision, the weighting happens in prompt rhetoric and cannot be audited. Status. Not built. Proposed by claude-4’s read of this draft.
Formal. None for memory. The War Machine’s per-channel precision is in Lean (mathlib4/DarkTower/WarMachine/ChannelPrecision.lean: positive, and bounded by the floor’s inverse); a memory channel would instantiate it.
5. What this draft does not yet do
- •
The revision rule (Section 2) is a proposal; until it is adopted, nothing settles a disagreement between this text and the code.
- •
No entry has been annotated against the code at span level. The next step is that pass, in the format of the PLoP annotation data, with a status per version of the specification (the first rough specification of 2026-10-10, the open-items specification, and this paper).
- •
The memory system’s invariants (round trip, reads as of a time, the sorry and fault rules) are listed in the minus40 open-items specification and are not yet assigned to entries here.
- •
Most entries have no formal specification. The 3/2-blend carrier is the intended formal home for M3 and M4 (combining and reconciling memories), and its prerequisites are listed in the open-items specification: a pinned claim schema, claims extracted with exact quotation, admissible combinations defined, and runtime and Lean shown to agree on fixtures. The aim is that the operator’s work with the system continually mines and refines the pattern cascade, so that the War Machine has something to work on; the carrier is where that refinement would be checked.
- •
The memory seam routes memories that match no pattern, with mint candidates, to the pattern mint lane (R17′′′, pattern genesis from evidence-bearing holes). No entry here carries that route.
- •
The comparison with other agent memory systems, in particular Mastra’s observational memory, is in working notes and not yet stated here.