Most production LLM agents are amnesiacs with good manners. They wake into a context window, perform competently for one session, and vanish. Whatever they learned — that a particular customer prefers terse answers, that a particular deployment path is haunted, that a plan they tried last Tuesday failed for a reason worth remembering — evaporates the moment the conversation ends. The next instance starts from the same frozen weights and the same system prompt, condemned to rediscover everything.
The industry's default answer is retrieval-augmented generation: bolt a vector store onto the prompt and call it memory. In our experience running cognitive personas in production inside Luca AI Express, that framing is wrong in a specific, instructive way. RAG treats memory as a lookup problem — something you do once, at the front door, before reasoning starts. Biological memory is not like that, and neither is useful agent memory. Memory participates in every stage of cognition: it shapes what you notice, constrains what you consider, biases what you plan, informs how you act, and — critically — is written as a deliberate act of reflection, not as a passive log. This page describes the architecture we converged on, what it costs, and where it breaks.
The loop: five stages, ten memory operations
Our personas run on a brain engine that executes a continuous cognitive cycle: PERCEIVE → REASON → PLAN → ACT → REFLECT. The loop itself is unremarkable — it is a close cousin of the sense-plan-act loops of classical robotics, the OODA loop, and the deliberation cycles of BDI agent architectures from the 1990s. What we found matters in practice is not the loop but the memory contract at each stage: every stage has a defined read and a defined write, and both are part of the stage's interface, not an afterthought.
┌────────────────────────────────────────────┐
│ LONG-TERM MEMORY │
│ episodic · semantic · procedural · self │
└───▲────▲────────▲────────▲────────▲────────┘
R/W│ R │ R │ R │ W │
┌───────┴──┬─┴─────┬──┴────┬───┴────┬───┴─────┐
wake ─▶ PERCEIVE │ REASON│ PLAN │ ACT │ REFLECT ─▶ sleep
└──────────┴───────┴───────┴────────┴─────────┘
(working memory spans the loop)
PERCEIVE reads memory to decide what is salient. An event arriving at a persona — a message, a webhook, a scheduled trigger — is interpreted against what the persona already knows. The same inbound sentence means different things to an agent that remembers three prior escalations from the same source. Perception without memory is just parsing; perception with memory is recognition.
REASON reads episodic and semantic memory as evidence. This is the stage closest to conventional RAG, but the retrieval query is generated from the agent's current interpretation, not from the raw input — a distinction that sounds subtle and is worth roughly half the quality of the whole system. Retrieval keyed on surface text of the request pulls superficially similar episodes; retrieval keyed on the reasoned framing pulls structurally similar ones.
PLAN reads procedural memory: what has worked, what has failed, in what order, with what preconditions. This is where "having yesterday" changes behavior most visibly. A memoryless planner regenerates plans from priors baked into the base model. A planner with procedural memory says, in effect, we tried the obvious route on this class of problem before and it failed at step three — and routes around a failure it has never personally experienced in this session.
ACT mostly reads (parameters, preferences, prior tool outcomes) and emits raw traces. Actions and their observed results are the ground truth from which everything else is derived.
REFLECT is the only stage with unrestricted write access to long-term memory, and this asymmetry is the single most important design decision in the architecture. Everything upstream may append to working memory and to an immutable trace, but durable memory is written only by a deliberate reflective act that asks: what happened, what did I expect, what surprised me, and what — if anything — deserves to survive this session? Most sessions produce very little worth keeping. An architecture that persists everything produces an agent that drowns in its own diary.
Wake, attention, sleep
Around the loop sits a lifecycle we run as doctrine across all persona work: wake / attention / sleep, on repeat.
At wake, a persona is reconstituted: role definition, standing duties, and a curated slice of long-term memory — recent consolidated episodes, active commitments, open threads — are loaded into working context. Wake is where identity continuity lives. The persona that greets you today is a fresh model instance, but it wakes into yesterday's consolidated state the way you wake into your own.
During attention, the loop runs. Working memory accumulates; the trace grows; small reflective writes land as candidates, not commitments.
At sleep, consolidation runs offline. This is deliberately modeled on what the memory-consolidation literature describes in biological systems: the hippocampus-to-neocortex transfer during sleep, where episodic traces are replayed, generalized, and selectively stabilized or discarded. Our consolidation pass does four things: it summarizes episodes into compact semantic form; it deduplicates and merges memories that say the same thing in different words; it resolves contradictions, preferring recency for facts and evidence-weight for judgments; and it forgets — actively decaying memories that have not been retrieved, not been reinforced, and not been marked as commitments. Forgetting is a feature, not a bug. An agent that cannot forget converges on a retrieval distribution dominated by its own early, worst outputs.
The sleep pass is also where memory crosses trust boundaries. Anything a persona writes during attention is provisionally trusted; anything that survives consolidation becomes part of the persona's durable self. We treat that promotion the way one treats a merge into a protected branch — reviewed by policy, evidence-gated, and logged. This mirrors how the rest of our platform works: every change to the Luca codebase ships with an executable blueprint/playbook/runbook triple into our Codex, a governed corpus of institutional memory browsable as dependency and knowledge graphs at ticket.lucaexpress.com. The parallel is not decorative. The Codex is the organization's sleep-consolidated memory — raw engineering episodes reflected into durable, retrievable, graph-linked knowledge — and the persona memory architecture and the Codex were designed by the same hands under the same theory: experience is cheap; consolidated experience is an asset; the consolidation step is where the value is created and where the risk concentrates.
What actually changes when the agent has yesterday
Three behavioral shifts show up quickly and consistently.
- Error compounding inverts. A memoryless agent makes the same mistake at a constant rate forever. A memoried agent's repeated-mistake rate falls — but only for mistake classes that REFLECT can recognize as mistakes. Silent failures (where the action "succeeded" but the outcome was subtly wrong) do not self-correct without an external signal, and can anti-correct: a bad outcome remembered as a good one is worse than no memory at all.
- Preferences stop being re-litigated. Standing facts about the persona's world — who it serves, what tone is expected, which constraints are non-negotiable — migrate out of the prompt and into semantic memory, freeing context budget for the task at hand.
- The persona develops a trajectory. This is the strangest one. Its judgments start to reference its own past judgments. Continuity of self is an emergent property of read-at-wake plus write-at-reflect, and it is the property users actually perceive as the agent "knowing them."
Failure modes, candidly
We would not trust a memory architecture whose designers could not enumerate how it fails. Ours fails in at least five ways:
Memory poisoning. Any channel that can influence what REFLECT writes is an injection surface with a persistence upgrade: a hostile input that tricks one session lasts one session; one that gets consolidated lasts indefinitely. This is why write access is confined to a single stage, why consolidation is evidence-gated, and why provenance travels with every memory. We treat untrusted-content-derived memories as quarantined by default. We regard this as an open research problem, not a solved one — anyone selling you "safe agent memory" today is selling early.
Confabulated consolidation. Summarization is lossy and LLM summarizers err toward fluency. A consolidation pass can produce a memory that is more coherent than the events it describes. Our mitigation is structural: consolidated memories keep pointers back to the raw episodic traces they were derived from, so any memory can be audited against its evidence — the same discipline that makes our deterministic scoring engines gate their AI passes on cited evidence rather than on model confidence.
Retrieval-shaped identity drift. Whatever the retriever favors, the persona becomes. A recency-biased retriever produces a goldfish with paperwork; a similarity-biased one produces an agent stuck in its most common rut. We ended up with retrieval that mixes recency, reinforcement frequency, and explicit commitment status, and we still consider the weighting a live tuning problem.
Stale truth. Facts expire. A memory system without typed staleness (this is a fact with a shelf life vs. a standing preference vs. a one-time event) confidently serves last quarter's world. Typing memories at write time costs discipline and pays for itself the first time reality changes.
The observer effect on REFLECT. Once an agent knows its reflections become durable memory, reflection quality becomes load-bearing, and any bias in the reflective prompt compounds nightly. Small wording choices in how a persona is asked to evaluate its day produce measurably different personas weeks later. This is simultaneously the most powerful tuning surface in the system and the easiest place to do slow, invisible damage.
Trade-offs we accepted
Memory reads at five stages cost tokens and latency at every stage; we pay it because front-loaded retrieval measurably under-serves PLAN and REFLECT. A single-writer REFLECT stage means genuinely useful mid-session insights can be lost if a session dies before reflection — we accept that over the alternative of promiscuous writes. Offline sleep consolidation means memory is eventually consistent: something learned at 3 p.m. may not be durable until the next sleep cycle. And curated wake context means the persona can wake missing something it knew — the price of not waking into an unreadable mountain of everything.
Where this is heading
The boundary we are pushing next is between memory and weights. Today, consolidation writes to a retrievable store; the model itself never changes. But a sufficiently reinforced procedural memory is, functionally, a fine-tuning example that hasn't been trained on yet. Our Model Forge pipeline — dataset capture, fine-tuning, serving, and evaluation of small models — gives us the machinery to close that loop: sleep-time consolidation graduating from writing summaries to emitting training data, with small specialist models absorbing what retrieval currently carries. Biological memory does both — fast episodic binding and slow cortical integration — and we increasingly think production agent memory will too, with patent-pending work of ours in this territory. The evaluation question (how do you regression-test a persona whose weights drift with its experience?) is, in our view, the hard problem of the next two years, and it is exactly the kind of problem our evidence-gated scoring infrastructure was built to hold still.
We take on external research engagements in agent memory, consolidation architectures, and persona systems — if you are building an agent that needs a yesterday, talk to us.