The bitter lesson for agent memory
Letting an agent query its own event logs achieves SOTA in all major memory benchmarks and scales with intelligence.
Time is a river which sweeps me along, but I am the river.
In Christopher Nolan's Memento, Leonard Shelby is set upon a seemingly impossible task. To find the man who killed his wife, despite the anterograde amnesia caused by a blow to his head. To maintain context with a memory that resets every so often, he uses polaroids, notes and tattoos.
This reminds me of how we do agent memory. Models have anterograde amnesia. They can't form long term memories, and their state of the world is frozen to a training cutoff. To maintain context across sessions, we engineer memory systems that encode and retrieve information from the past.
But how much engineering does a memory system need? Richard Sutton famously stated in The Bitter Lesson that general methods such as search and learning outperform systems built with human domain knowledge.
We found this to be the case with agent memory.
Allowing an agent to run SQL queries and search over its own event log beats or matches specialised memory systems in all major memory benchmarks and scales with model intelligence.
We argue that memory systems lose valuable task-relevant information during compression. In contrast, agentic search over an event log defers compression until query time. We propose a design for memory systems that aims to maximise the epistemic value of searching past events, using a hierarchy of derived views over an immutable event log.
A survey of memory systems
Anthropic recently described memory as knowledge an agent gains from experience and retains between sessions. Information theory offers us a sharper lens: memory is information from the past that reduces uncertainty in the future. A memory system is what encodes, consolidates, and retrieves that information.
Decades of research from cognitive neuroscience give us a systematic framework to understand memory systems: encoding, consolidating, and retrieving experience.
Within each process, we can further classify systems in terms of whether it's done in an open-loop or closed-loop. In control theory, closed-loop systems act, measure their outputs and adjust their inputs to reduce errors. Open-loop systems are more rigid: they act on commands and models without adjusting to feedback.
Encoding experience
The goal of encoding is to extract information from experience into a representation that reduces uncertainty during an unknown future task. The following diagram shows this in the context of a typical agent loop.
The major forms of memory stores are vector embeddings, graphs and ontologies, or summaries and notes. Open-loop systems use conditions and handcrafted domain models to decide when to write to the memory store. Mem0, Supermemory, and Mastra are examples.
Supermemory batches multiple turns asynchronously by default, allowing for an optional per turn extraction. Extracted facts are encoded into temporal graphs. In Mem0, the harness sends every new turn to an extraction model that distills them into atomic facts, which are embedded into a vector store.
Compaction could be viewed as a form of memory encoding too. It triggers at context window boundaries and extracts goal-relevant information from one context window into the next.
In contrast, closed-loop systems use the agent to update information in the memory store through tool calls. It comes with variable costs and latency since it adds inference compute within a turn.
In practice, systems like Claude, Codex and Letta use a hybrid approach. During latency-sensitive tasks, agents use general shell and file tools to make small closed-loop updates to their memory stores. In idle time between interactions, deeper consolidation and cleanup cycles run as open-loop background processes.
Consolidating experience
The goal of consolidation is to improve an existing encoded memory representation to optimise retrieval during an unknown future task. Notice the contrast with encoding which was focused on extracting information.
As a nod to its parallels in the brain, researchers from Letta introduced the term sleep time compute to describe this process.
Claude, Codex, and Letta use different variations of memory consolidation. For example, Claude managed agents use idle periods between interactions to reflect on the past and update their memory store, a process they described as dreaming. Their blog gives a great write-up about their approach and findings.
Codex asynchronously summarises idle past sessions into markdown files in a /memories directory, linked to their raw transcripts. The directory also contains a summary markdown file with information about the user and a ranked index to the session summaries.
In the context of consolidation, a closed-loop system would actively use feedback from historical events to improve the memory store. For example, one approach is to create variations of a memory store and iteratively test them on different checkpoints to score outcomes. The variation that produces the least error is then promoted.
Retrieving experience
The goal of retrieval is to find task-relevant information from the past to reduce uncertainty for a known query.
Open-loop systems retrieve information without responding to feedback. For example, Mem0 searches the store using the current query and injects top_k matches into context. Mastra's observational memory and compaction are other examples where the harness summarises history and pushes it into context without feedback.
In contrast, Tardigrade's log library uses a closed-loop retrieval approach. It lets an agent query its own event log and run FTS5 search on events until enough task-relevant information is gained. This design will be discussed in greater detail in the setup section.
Letta is another great example of a closed-loop system. In addition to getting context from a git backed memory store using shell tools, Letta agents can directly modify their system prompt by editing markdown files within the designated /system directory.
Summary
| System | Store | Encoding | Consolidation | Retrieval |
|---|---|---|---|---|
| Compaction | Summary checkpoint | Open-loop (context-limit summary) | None | Open-loop (prepended summary) |
| Mastra | Dated summary | Open-loop (observer) | Open-loop (reflector) | Open-loop (prepended summary) |
| Mem0 | Atomic fact vectors | Open-loop (per-turn extraction) | None | Open-loop (top_k search) |
| Supermemory | Facts + temporal graph | Open-loop (batched extraction) | Open-loop (background dreaming) | Open-loop (profile + hybrid search) |
| Codex | Summaries + raw transcripts | Open-loop (idle rollout summaries) | Open-loop (root-session index) | Hybrid (open-loop summary + closed-loop reads) |
| Letta / Claude | Git files or linked wiki | Closed-loop (shell / file tools) | Open-loop (sleep / dreaming) | Closed-loop (pinned files + agentic search) |
| Raw logs | Immutable event log | None (append-only) | None | Closed-loop (agentic FTS5 + SQL) |
Experimental setup
Memory system
For our research, we were interested in finding how much engineering a memory system needs. If the bitter lesson were to hold true, simpler systems that use more of model capabilities should outperform hand-crafted ones.
In this direction, we tested a memory system without any encoding or consolidation step. For retrieval, we let the agent run SQL queries and FTS5 search on its own event logs. The complete code for our setup can be found here.
We used two main variations of the system, depending on the benchmark we tested against. Some of the benches used context across sessions, while others were within a single session.
For benchmarks that used context from across sessions, the agent had a Tardigrade library that gave it access to all past sessions. It exposed four tools:
| Tool | Description |
|---|---|
sessions_list | List past sessions with IDs, dates, and turn counts, with optional date filtering. |
sessions_search | Run SQLite FTS5 full-text search across all past sessions, returning ranked snippets with session IDs and turn indices. |
sessions_read | Read a verbatim window of turns (fromSeq to toSeq) directly from a single session's SQLite database. |
sessions_query | Run read-only SQL queries against the global sessions index (sessions and turns tables). |
For benchmarks that used context from within a single session, the agent used the log library, which exposes three tools. In both variations, the search tool lets the agent run FTS5 search on the event log and the query tool lets the agent run SQL queries.
| Tool | Description |
|---|---|
describe | Inspect event types, field schemas, and sample records in the event log. |
search | Run SQLite FTS5 full-text search across events in the log, returning ranked snippets. |
query | Run read-only SQL queries directly against the event log. |
We modelled our dreaming setup after Anthropic's approach: after every task, and before the next task, we ran a reflection loop to let a dreaming agent create notes and wiki using the event log and task feedback.
| Tool | Role | Description |
|---|---|---|
wiki_list | Both | List wiki page titles and summaries. |
wiki_read | Both | Read a markdown wiki page along with its links and journal source citations. |
wiki_search | Both | Search wiki pages using SQLite FTS5 full-text search. |
wiki_links | Both | Browse outgoing links and backlinks for a wiki page. |
wiki_note | Task agent | Attach a short note to a journal event for the dreaming agent to revisit. |
wiki_notes | Dreamer | Read notes attached to journal events across a sequence range. |
wiki_write | Dreamer | Create or replace a wiki page with links and journal source citations. |
wiki_set_index | Dreamer | Publish the ordered list of top-level topic pages injected into context. |
Benchmarks
Drawing from cognitive science, we classify memory tests into recall and transfer. Recall tests whether an agent can retrieve information from past events verbatim, while transfer tests whether it can apply general rules or concepts learned from those events to a new situation.
Memory benchmarks typically provide history from user-assistant conversations or agent task trajectories and evaluate recall or transfer over that past. For this research, we chose five benchmarks spanning different history types, sizes, and tests:
| Benchmark | History | Size / Scope | Tests | Setup |
|---|---|---|---|---|
| DolphinBench | Conversations | 600 tasks (~500K tokens) | Recall & preference transfer | log |
| LongMemEval V1 | Multi-session conversations | S (~115K) & M (~1.5M), 500 Qs each | Episodic recall | sessions |
| LongMemEval V2 | Web & enterprise trajectories | Small (451 Qs, with screenshots) | Semantic & procedural recall | sessions |
| BEAM | Long conversation threads | 100K, 500K, 1M, 10M tokens | Long-horizon recall | log |
| Continual Learning Bench | Stateful SQL trajectories | 40 episodes (database_exploration) | Cross-session transfer | sessions (+ wiki arm) |
We tuned our prompts for BEAM-100K, 500K, 1M using 20 questions from the BEAM-100K dataset since the grading rubrics are non-obvious from the questions. We found this to be consistent with how other systems run their benchmarks.
To compare how scores vary with model intelligence, we ran this across three models within OpenAI's frontier model family: GPT-6.1 Sol, GPT-6.1 Terra, and GPT-6 Luna. For Continual Learning Bench, we also included Anthropic's frontier model family: Opus 5.5, Sonnet 5.5, and Haiku 5.5 to compare our results against Anthropic's.
An example of a task from DolphinBench, which tests recall and transfer of preference, looks like this:
An example of a task from Continual Learning Bench, which tests transfer of knowledge across sessions, looks like this:
Results
Agentic search beats specialised systems
Letting an agent run SQL queries and FTS5 search over raw event logs sets the Pareto frontier on cost and accuracy, beating or matching both bare in-context learning (ICL) and specialised memory systems.
On DolphinBench, using the leaderboard's GPT-5.6 Luna model, the raw-log approach scores 85.7% at $4.73, beating Graphon (84.0% at $11.84) at less than half the cost and outperforming memory stores like Mem0 (70.7% at $96.21) at a twentieth of the cost. It also leads LongMemEval V1 (94.6% on S, 92.2% on M) and all four BEAM context sizes up to 10M tokens.
On LongMemEval V2, our system scores 79.8%, close behind AgentRunbook-C at 81.2%, which also uses agentic search over raw transcripts (grep over files rather than SQL over events).
Agentic search scales with intelligence
Holding all else constant, scores improve with model capability across every benchmark. On DolphinBench, moving from GPT-6 Luna to GPT-6.1 Terra and GPT-6.1 Sol lifts accuracy from 87.2% ($2.47) to 90.5% ($20.32) and 93.8% ($36.38), beating bare 500K in-context learning at every model tier for roughly a tenth of the cost.
The advantage of stronger models increases as context size grows. Moving from GPT-6 Luna to GPT-6.1 Sol adds +6.4 points on BEAM-100K, +9.9 points on BEAM-1M, and +13.8 points on BEAM-10M (53.2% to 67.0%), and grows from +8.8 points on LongMemEval V1-S to +10.8 points on V1-M. Stronger models are better at writing SQL queries and this translates directly into recall scores.
Dreaming adds no gain over logs on strong models
On Continual Learning Bench's database_exploration suite (40 stateful SQL episodes with a mid-run schema migration), raw logs alone roughly double the stateless baseline on frontier models, lifting mean reward from 0.422 to 0.768 on Opus 5.5 and from 0.282 to 0.727 on GPT-6.1 Terra.
Adding sleep-time wiki consolidation helps smaller and mid-tier models (+0.227 on Sonnet 5.5, +0.134 on Haiku 5.5, and +0.118 on GPT-6 Luna), reduces to +0.039 within run-to-run spread on GPT-6.1 Sol, and disappears on the strongest models (-0.004 on GPT-6.1 Terra and -0.011 on Opus 5.5). Wikis act as a scaffold for weaker models, while stronger models reconstruct what they need better from the raw event log.
Discussion
Deferring compression until query time
Encoding and consolidation in memory systems compress raw events into a store, aiming to reduce uncertainty in future queries during retrieval. However, this approach loses valuable information by trying to guess future queries.
In contrast, agentic search over an event log defers compression of information until query time. As model capabilities increase, they get better at finding task-relevant information directly from the raw logs.
For example, one of the tasks in Continual Learning Bench involves searching a database of a store inventory to find the mean deviation of electronics price. The trap is that the relevant table has three price columns after migration: prc, prc_usd, and prc_v2.
Sonnet 5.5, even with logs and dreaming wiki, uses four DB queries and gets the wrong answer. Its notes hadn't saved the correct column to look at post-migration for this particular query and it resorts to guessing a wrong answer.
Meanwhile Opus 5.5 with raw logs gets the answer in a single query. It searches for "electronics price" in the event log, spots items_g2 and prc_v2 around event positions 67-68. Then it runs a query ("SELECT ... FROM events WHERE position >= 76 OR record LIKE '%prc_v2%'") to read the exact post-migration tail. After that it gets the right answer in a single DB query:
SELECT
COUNT(*),
AVG(prc_v2) / 100.0 AS avg_d,
AVG(ABS(prc_v2 - (SELECT AVG(prc_v2) FROM items_g2 WHERE prc_v2 > 0))) / 100.0 AS mad
FROM items_g2
WHERE prc_v2 > 0;Letta's sleep time compute paper noticed similar results. They found that offline pre-computation of a memory store helped most when queries were predictable from context. When queries are hard to predict, they conclude that test-time compute is preferable. They also found that on Stateful GSM-Symbolic and on their agentic SWE-Features benchmark, standard test-time compute over raw context outperformed pre-computed stores when given higher test-time budgets.
Maximising the epistemic value of search
Does this mean we do not need memory systems at all? While letting a model search the event log for every query might in principle lead to better performance, it might not be practical for all tasks. For user-facing applications where latency matters, we often want less inference compute within turns.
Active inference gives us a useful framework for thinking about memory systems and optimising them. Epistemic foraging refers to the active search for information in closed-loop systems (like agentic search) to reduce uncertainty about the world. Epistemic value is the expected reduction in task-related uncertainty afforded by a given action.
The goal of a memory store is to maximise the epistemic value of search over an event log. There are two ways to do this: eliminate search hops for frequently accessed information by caching it, and reduce the hops needed for everything else by increasing information scent.
Memory as a cache over past events
One way to reduce the cost of searching events is by caching frequently accessed information. This could be viewed as a materialised view of a frequent search that affords zero hops to find relevant information.
For example, take the case of a personal assistant that handles a user's day to day tasks. Knowing where the user stays might be useful information possibly revealed through conversation events.
It is expensive to always search the event log for any future task that requires the user's location (e.g., setting the timezone when booking a meeting). In this case, the user's location could be cached with reference to the events where this information was derived from and stored within the context window.
When a new event contradicts something stored in cache (e.g., user moves to new location), it could be invalidated and linked to the new event. This design also allows for more sophisticated patterns like invalidating certain information when an event happens (e.g., invalidate after a certain time period).
A similar bind is observed in the transformer architecture. Linear attention layers compress past tokens into a fixed-size state matrix before future queries are known. Full self-attention keeps the full KV history and waits until a query arrives to attend over it. Hybrid models like Kimi K3 use linear attention for speed, backed by full attention layers for exact recall.
Memory as an index over past events
Information scent refers to proximal cues that a searcher can use to find information they want. High information scent reduces the cost of information by reducing the number of hops it takes to reach it. Information scent also prevents the class of problem where an agent gives up search too early.
FTS5 search snippets, query results, and table names are examples of information scents. In addition to these, summaries of logical episodes in the event logs could also act as an index. Codex's hierarchical organisation of a memory summary and session summaries linked to raw sessions is an example of this approach.
A bitter-lesson friendly memory system
We propose a design for a memory system that's built as a hierarchy of derived views over an immutable event log. Notice how it mirrors a computer's memory hierarchy from fast, small CPU caches down to RAM and disk.
L0 (Hot Cache): Materialised views, zero hop. Sized by access frequency.
L1 (Index): High scent pointers into the event log, one hop.
L2 (Event Log): Lossless source of truth, unlimited capacity.
This essay doesn't go deeper into an implementation of this approach and how it performs. That will be for a future one.
Conclusion
If Nolan's Shelby had access to every single frame of his life recorded and stored as a video, he might have been better off searching the recordings to accomplish his goals.
In designing memory systems for agents, we've carried over some of the implicit constraints of biological systems, which are resource constrained and organised to make the most of available space. Raw sensory events are ephemeral and can't be accessed again. Hence, every event has to be encoded in a compressed form, decoded and consolidated later.
The same constraints don't apply to computers, where we have practically unlimited storage space for events within an agent's lifetime. Memory systems should focus on reducing the cost of search over an immutable event log.
ps: If you're building or evaluating agent memory systems and want to run custom benchmarks over your own tasks and traces, try Hatchery.
Cite this article
@article{the-bitter-lesson-for-agent-memory,
title = {The bitter lesson for agent memory},
author = {Arjun Kumar},
year = {2026},
url = {https://hatchery.build/blog/the-bitter-lesson-for-agent-memory},
date = {2026-12-02}
}