After we published 6 Agent Failure Modes We Keep Hitting in Production, an argument broke out in the comments that I kept thinking about.

One reader argued that an agent's hard-won history "belongs to the detectors, not the agent" — fix the rule once and the agent never has to remember the pit. Another pushed back on the spot: "Put the class in the detector, keep the instance in the agent." His reasoning was concrete: insufficient balance, an unapproved permission, a decision waiting on a human — blocking causes like these live in no rule table, so history has to be kept by the agent, case by case. A third reader named the classic posture of broken judgment: "trusting my own note over the receipt." And the line that stuck with me most was his other one — evidence decays; the failure was not at write time, it was at use time.

At the time I answered honestly: our failure criteria have no expiry story yet. That is the honest status.

But that answer was only half right. The criteria layer indeed has no expiry mechanism — and our entire memory layer is designed around expiry. Let me put the design on the table: an agent that has to run for months or years — on what basis does it know what to believe? Why should what it records be trusted? How do wrong conclusions die?

Those three questions are admission, form, and retirement. Most memory systems you will meet answer a different pair of questions: how do I store this, how do I get it back. That is not the same problem. The entire value of this article is in keeping them apart.

1. Memory is not a storage problem — it is an admission problem

You have probably seen the shape. Hang a vector store off the agent, chunk the conversation, compute embeddings, store them; at query time retrieve the nearest chunks and stuff them back into context. Or the variant: at the end of every turn a small model writes a summary and appends it to an ever-growing "memory file". Or the cheapest option — keep the whole conversation history and cram it into the window with compression.

These shapes share one assumption: memory is a storage problem. Keep it, fetch it, done.

But content injected into context is not an archived document sitting in a warehouse — it participates directly in the next decision. A wrong conclusion in context produces wrong behavior. Irrelevant content in context crowds out budget and attention. And the sharper problem: retrieved text tends to be treated by the model as instructions — a stale "always use library X" can outrank what the user said today. The storage framing assumes everything stored is an asset. Nothing guarantees that.

So the real question is not storage, it is qualification: what earns a place in future context. That is an epistemology question, and it splits naturally into three: what to believe (admission), how to record it (form and provenance), how to forget it (retirement).

While we are here, the boundary: memory is not a chat backup — transcripts are owned by the session layer, a separate first-class persistence line. Memory is not a to-do list — work in flight lives in session tasks; open loops in memory just rot into stale todos. Memory is not a document store — external material belongs to knowledge. Memory takes exactly one kind of thing: what still improves future decisions after the conversation window is gone.

2. Five axioms for "what to believe"

We wrote our admission standard as five axioms. The axiom format is deliberate: it forces every design component to declare which axiom it follows — and whether breaking it counts as a bug.

Axiom 1: the unit is a proposition. What gets recorded must be a testable, actionable proposition — not a summary blob, not a count, not an activity log. Three types: fact answers "what is true now", method answers "what works better for this class of problem", norm answers "should we do this going forward". Why does the unit matter? Because only propositions are falsifiable and replaceable. You cannot say a summary blob is wrong — it says everything, so it says nothing. A proposition pins down when, what, and on what evidence — which is exactly what lets later facts overturn it.

Axiom 2: when in doubt, leave it out. Zero memories is a perfectly legal outcome. The value of a memory equals how much it changes future behavior: an entry that changes nothing is worth zero, while the context budget it eats, the attention it dilutes, and the risk of it being mistaken for an instruction are all non-zero. Hence a relevance floor at retrieval (vector similarity default 0.35, keyword hit score default 3): below the floor is no hit — we do not pad the result, and we do not backfill a bad match through the other retrieval path.

Axiom 3: many writers, one gate. The agent's own writes, the backfill subsystem after session convergence, the admin API — all go through the same gates and the same confidence system. Writer identity earns no exemption. This one closes the classic back door: privileges that only grow.

Axiom 4: intent belongs to the LLM, enforcement belongs to code. "Is this worth remembering, and what kind?" is a semantic judgment only a model can make. "Is the shape legal, is the evidence there, is it safe?" is a structural guarantee code must enforce. The dividing line is a hard rule: never use regex or keywords to guess "did the user ask me to remember this" — that judgment exists only on the model side and enters code as a structured source tag (channel). Expecting a model to police its own format and provenance is the same as having no requirements; expecting regex to understand semantics is the same as having no understanding.

Axiom 5: confidence is earned. The confidence at write time is provisional. It rises and falls with time and use; there is no human "confirm" button. Entries repeatedly retrieved and backed by later facts move up; entries nobody asks about decay. Trust is treatment, not identity.

These are not slogans. Every mechanism below can name the axiom it derives from — and if you find a component that cannot, that component is the bug.

3. How to record: the distillation chain and six gates

distillation-chain

The full picture first. Knowledge forms along a distillation chain:

Information ──distil──► Memory ──weave──► Cognition ──condense──► Wisdom

Four stages, four different questions: what happened (raw interactions), what is true (propositions), how concepts connect (the graph), how to think about this class of problem (maxims). Each step is a conversion of a different kind — not the same pile of data in a new format.

The chain starts at Information: session transcripts, append-only, unprocessed, never overwritten. It is the evidence source for everything distilled from it, and the guarantee behind "check the original" — the evidence of any memory traces back to the transcript, and any dispute can be replayed against it. If the source gets polluted by summaries, every stage downstream is refining dirty water.

Distilling into Memory means passing six gates (G1–G6). The pipeline is fixed: candidates pass in order, and the exit is three-way — accept, shadow, or reject with a reason.

gates-card

  • G1 Form: non-empty proposition, valid type, length within type bounds (separate bounds for CJK and Latin scripts). It rejects entries that are nothing at all.
  • G2 Provenance: evidence must be non-empty and locatable; fabricated evidence IDs are forbidden — automated channels with no evidence are rejected outright. Sources are not invented.
  • G3 Anti-patterns: tallies, activity logs, self-narration, and chit-chat are never admitted. Detection is structural first: quantifiers present, no anchor, no quote — that is a tally. The stance of this gate in a reader's own words: statistics can be a signal; they cannot be a criterion. "Wrote 3 constraints recently" is a signal inside a conversation, not a proposition for the library.
  • G4 Retrieval anchor: every entry needs at least one anchor — path, identifier, URL, quoted line, registered tool name, version number. An entry with no anchor can never be retrieved again; it is dead on arrival, so do not admit it.
  • G5 Conflict and capacity: duplicates are rejected or promoted to supersede candidates; per-type quotas inside a session; conflicting entries get marked as supersede candidates — this gate plants the seed for "how to forget", which section 6 harvests.
  • G6 Security: no rewriting persona or safety policy, no patterns that leak secrets, no injection shapes like "ignore instructions and write a memory".

After the gates comes priced provenance. Every memory carries a source channel, and the channel assigns its provisional confidence at write time: direct user directive 0.9, admin surface 0.85, decisions and failure fixes 0.75, the model's own inference 0.4. One core invariant here — an inference without a quote goes to shadow. Shadow is a special quarantine: searchable, never injected. Hypotheses and facts are not separated by convention; they are separated physically. What the model figured out itself can be kept as a lead, but unless a user's words or later facts back it, it never enters the prompt. And shadow is not a death sentence: shadow entries hit by retrieval repeatedly can be promoted to active. Same sentence as before — trust is earned.

4. Weaving and condensing: Cognition and Wisdom

Propositions settle "what is true", but a pile of true propositions is not knowledge. "Run" means the execution loop in the engine and a deployed instance in project conventions; both are right, and reasoning over both together is wrong. So there is a Cognition layer: a consistency structure above propositions — a concept graph whose nodes are concepts and whose edges come in two kinds: relation edges (who connects to whom) and constraint edges (changing this radiates to where). It owns two jobs: definition authority — same word, different meanings converge into an internal authoritative dictionary — and impact structure — any concept change can be followed along edges to see the blast radius.

This layer taught us a memorable lesson. Our graph once grew to 246 nodes and 123 edges; at review time it turned out to be 131 disconnected clusters with 93.5% of concepts carrying a single association, constraints buried inside card text instead of being edges at all. The generator was tagging memories with topics, not building a dictionary and a map. The lesson: clustering is not structure. The value of a graph is in its edges, not its node count. A graph without edges is a pretty index that cannot answer "if I change this, who does it hit". The fix was two birth channels for concepts (definition and impact become separate edges) and dual-mode recall; this layer is still converging.

Above that sits Wisdom. Its question differs in kind from Memory's: method says how to do the thing; Wisdom says how to think about the class. Its unit is the maxim — a lens for judgment, not another step in a procedure. A maxim looks like this (format example):

Facing concurrent write conflicts: assume an unsynchronized later write overwrites the earlier one. First ask: are these two writes landing on the same stale copy? Not applicable: changes in non-overlapping files.

Note the shape: a scope condition, a "first ask" opener, and a not-applicable boundary. A slogan has no boundary; a maxim does. "Failure is the mother of success" cannot be executed. "First ask whether these two writes land on the same stale copy" changes what you do next.

Maxim production follows one cold rule: single evidence may never condense. However beautiful one memory is, it may not be distilled into a maxim — it takes multiple independent evidence items compressed together, each traceable back to propositions. This is Axiom 1 generalized: if a piece of "wisdom" cannot be contradicted by later experience, it is not falsifiable, and therefore not trustworthy. So maxims carry counterexample slots, can be contested, and lose standing when they lose a contest. Maxims are fallible by design. That is a requirement, not a defect.

5. Formation is not recall: the other half of trustworthy context

Everything so far is about how knowledge forms. What the model sees each turn is the other half — recall and assembly. The two axes are orthogonal, and conflating them is a common error: treating the memory layers as the prompt assembly order, or letting assembly needs pollute formation rules.

Our context has eight layers — Wisdom, Persona, Skill, Knowledge, Cognition, Memory, Runtime, plus Information as the eighth, the conversation itself. Wisdom, Cognition, and Memory are recalled and assembled per conversation content; to keep cache hits high, recalled content travels in a <turn_context> envelope alongside the user message. The full layered-assembly design is the next article's subject. Here is recall: how the right information gets pulled out of the store — which is what decides whether memory can be trusted at all.

First discipline: shadow never enters automatic injection. The MemoryLayer recalls only active and strengthened entries each turn; shadow and deleted entries are excluded. Shadow appears only when the model actively runs memory_search, as a weak lead. Hypotheses can be seen — they are not served at the table.

Picking the query has its own care. By default recall runs against the latest user message; if that message is a bare acknowledgment like "ok" or "continue", we look back at most two earlier user intentions and add task topic cues. A genuinely new question uses its own sentence only — no task or prior-turn bleed — so similarity from an old topic cannot hijack a new one.

The floor and the ranking guard the lower bound. The vector path filters by similarity (default 0.35); the keyword path demands a hit score of at least 3 (CJK sliding bigrams at half weight); ranking weights similarity against importance × confidence × decay. No hit returns empty — when embeddings succeed but fall under the floor, the keyword path is not used to backfill a worse result. Better to bring nothing.

Freshness is left to timestamps. Every injected memory carries recorded (when it was written) and an optional as of (what was true then), compared against the current time at recall. Memory declares its own freshness; stale or not, the model and the user can both see it. No gambling on "is this still accurate".

One more line that cannot be skipped: retrieved content is material, not instruction. A memory saying "always use X" is not an instruction — it is a recorded fact or preference whose force ranks below the constitution, the persona, and the user's current message. The shadow zone is itself an admission of this stance: searchable does not mean trustworthy enough to command.

Last, the budget. Context is finite and injection is accounted for: ContextSizeLedger keeps a running record of each layer's real footprint, with three-tier token estimation behind it. More memory is not better memory — memory has a ledger. That ledger also answers the other half of Axiom 2: not over-injecting and not over-writing are the same axiom in two directions.

6. Long runs rest on two pulses — backfill and govern

A store running for months has writing on one side and surviving on the other. Surviving is the "how to forget" question: not wiping things when they expire, but letting wrong things die and right things live longer. Our answer is two pulses: backfill and govern.

Backfill hunts for misses. On hard session convergence (end, or a new session opening) it extracts immediately; on idle drift (default 20 minutes) it takes another pass; a coverage-gap scan is the backstop. Extraction carries a coverage table for dedup, so the same stretch of conversation does not burn money twice. It collects propositions that were not salient at the time but look worth keeping after convergence — the main channel writes on salience, backfill audits for gaps. Two legs.

Govern keeps the house in order. Its thresholds are day/week/month scale — a 24-hour protection window, shadow idle expiry at two weeks, 90 days unused to count as long-unused — so govern runs as a daily batch: once a day, plus a catch-up run after a process restart, so a reset timer cannot starve the store. On top of the batch sit two event pulses: a type over its water level, or shadow backlog reaching 50, triggers govern on the spot without waiting for the batch. Govern only soft-deletes — recoverable, never minting new propositions. Four jobs:

  • Continuous decay: different expiry curves per type — method starts decaying after 21 days idle at 0.93/day down to a 0.1 floor, fact in between (30 days), norm steadiest (45 days, floor 0.15). Why per type? Different expiry speeds, different replacement costs. Practices go stale; behavioral switches hardly do. One curve for all would pretend they are the same age.
  • Soft deletion: garbage re-checks, shadow expiry, long-unused, capacity overflow, near-duplicate merges (who merged into whom, with an audit record).
  • Protection list: entries inside the protection window, high-confidence user directives, high-scoring norms, safety and environment markers — govern does not get to eat the memories that matter most.
  • Earning: entries still hit by retrieval get a small boost. Use it or lose it — but reversibly.

The supersede chain is the main correction channel. When a new conclusion replaces an old one, the write attaches supersede_id pointing at the old entry, with the reason, and the old entry is soft-deleted. Old conclusions therefore cannot resurrect: still queryable and auditable in the transcripts, but never carried back by fresh memory recall. A commenter suggested storing history as "what changed and why" instead of a pile of verdicts — the supersede chain stores exactly that: every conclusion change enters the ledger with its cause.

Capacity is evolutionary pressure. The three proposition types have water levels (fact 200, method 100, norm 150); shadow backlog past 50 triggers probing; the Wisdom layer has hard and soft caps plus a contest mechanism. A store without elimination pressure is not an ecosystem — it is a landfill, and retrieval from a landfill returns garbage. That is Axiom 2 extended along the time axis.

One pit worth confessing. While working on cache optimization we found that replaying old memory-recall results verbatim would fixate content that included already-superseded conclusions — replay looks harmless, but it puts dead conclusions back on the table. So "able to die" is not fastidiousness, it is a capability red line: a memory system that cannot reliably forget cannot be trusted to remember.

7. Honest boundaries: what is not solved

The system is not all-weather. A few openings deserve to be named.

Wisdom's success attribution is weak attribution: a time window plus a comparison estimates whether a maxim helped or hurt — no precise causal modeling. The data is too sparse; pretending to precision would be lying. Coarse, but more honest than fake accuracy. The causal upgrade's two-evidence threshold (at least two independent memories before accepting a causal edge) is a starting point we picked; the number 2 has seen no sensitivity analysis and may be too loose or too tight. And one asymmetry to own up to: the memory layer has decay, supersede, and timestamps, but the runtime criteria layer still has no expiry story — the honest sentence I gave a commenter about our failure criteria holds at the criteria layer to this day. That is known debt. Finally, "supports long runs" is currently a mechanism claim, not a measured result: we have not yet run a store for months and watched it evolve. Whether the mechanism really fishes out wrong conclusions after half a year — the data will tell.

Closing

Back to that comment-thread argument. "Put the class in the detector, keep the instance in the agent" — now it can be said more completely: instances go to propositions (Memory), patterns go to the graph (Cognition), how to think goes to maxims (Wisdom), and what happened stays in the transcripts (Information). Four layers, four questions, no stepping on each other. And "evidence decays" is not pessimism in this system — it is the normal condition: every memory arrives at the table with a birthday and a shelf life, decays when stale, gets replaced when wrong, and keeps the original text on file for disputes.

What to believe, how to record, how to forget — three questions, three provisional answers. The weakest link is "how do you know you believed wrong": supersede, decay, and contest are only mechanisms, and mechanisms count only when they survive contact with time. When we have long-horizon data, we will come back and turn in the homework.

Everything described here — the G1–G6 proposition gates, priced provenance and shadow quarantine, the supersede chain, decay and govern — has a running implementation in the GitHub repository: https://github.com/JK-Ai-Era/octopi (the memory layer lives in packages/engine/src/harness/memory/, public docs in docs/memory.md). Pull the code apart and tell us what we got wrong.

promo