Staying out of the LLM dumb zone with the Memento Pattern
Why the best AI agents work like Guy Pearce in Memento (and what that means for your next project)
This article was originally published on Substack.
I was reading Anthropic’s post about their best practices for long running agents and this line stopped me:
We developed a two-fold solution to enable the Claude Agent SDK to work effectively across many context windows: an initializer agent that sets up the environment on the first run, and a coding agent that is tasked with making incremental progress in every session, while leaving clear artifacts for the next session.
→ https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents
So you’ve got an agent doing its thing in its limited time, then passing everything to another agent who wakes up knowing absolutely nothing. That second agent picks up where the first one left off based purely on whatever notes got left behind.
Does that sound familiar?
If not, you probably need to watch Christopher Nolan’s Memento.
The Guy With No Memory

In Memento, Guy Pearce plays this guy (hehe) trying to solve his wife’s murder, but here’s the catch: he can’t form new short-term memories. Every time he wakes up, he’s basically starting from scratch. It’s like with me and errands my wife asks me to take care of.
So he came up with this whole system. He takes Polaroid photos of people he meets, writes notes on everything and even tattoos the really important clues on his body. It’s the only way he can keep investigating without forgetting everything he learned.
The whole movie plays backwards too, which puts you right in his headspace. You’re just as confused as he is, constantly trying to piece together what the hell is happening from these scattered clues.
Besides being a great film, Memento basically teaches you everything about how to run AI agents successfully.
Why One Agent Can’t Do Everything
You might wonder: Why can’t a single agent just handle a complex task from start to finish? Why do we need all these sub-agents and specialized tools and complicated workflows?
The answer is one of the principle rules of context engineering: LLMs get dumb when their context window fills up.
Dex Horthy from HumanLayer calls it “entering the dumb zone”. Doesn’t matter if your model has a 100k or 200k token window: once you start filling it up past a certain point, the quality of reasoning just tanks. Usually happens somewhere around 50-60% capacity.
There’s actual research backing this up. Fiction.liveBench benchmarks show models like Claude Sonnet 4 see performance drops around 60-120k tokens. Even more interesting, research on working memory in LLMs found that even with million-token windows, models regress to near-random guessing on tasks that need substantial working memory.
You start seeing it when the model can’t keep track of variables across long code files, or when it forgets what you discussed earlier in the conversation, or when it needs to connect distant pieces of information to reason about something complex.
It’s one of those not-so-rare moments where I, a fellow gold-fish memory owner, can sympathize with an LLM.
Keep It Small
So the natural consequence is: you want to use as little context as possible to get your task done.
The closer you are to an empty context window, the sharper the AI’s reasoning. As you move from 0% toward 50% full, things start getting worse. It’s like a loss function you’re trying to minimize: less context equals better output.
Which creates an obvious problem: what if what you’re trying to do is too complex to fit in one small context window?
That’s where the “Memento pattern” comes in.
How the Pattern Actually Works
Just like the guy in Memento waking up each day, your agents need to:
- Start fresh with a clean context
- Quickly get oriented from the previous session’s notes
- Make progress on one specific thing
- Leave really clear notes for the next session
- Repeat until you’re done
This requires a workflow orthogonal to what most people do. Usually, the first instinct to improve one’s AI results is to write these elaborate prompts:
“You are a senior frontend developer with 10 years of experience in React, expert in TypeScript, Matt Pocock’s lost twin brother…”
I’ve never gotten anywhere with one of these. What actually works is having agents that know specific parts of your codebase and do specific phases of work (like research, then planning, then building). Once done, they pass structured documents between each other instead of trying to keep everything in memory.
What This Looks Like in Practice
The basic idea is pretty simple: split your work into phases where each one produces a document for the next. Those phases can line up something like this:
Research → Plan → Implement → Validate
One agent researches your codebase and writes up what it found. Another reads that research and creates a plan. The next one implements a phase at a time, checking if it worked before moving on.
Each agent uses maybe 20-40% of its context window and produces one clear document. These documents get committed to enrich the context of future research.
You’re a Context Window Janitor Now
Next time you’re working with coding agents on something complex and it starts giving you weird, inconsistent results - check how full that context window is. You’re not a prompt engineer but a context window janitor. Keep your window nice and tidy.
Even though I am proud of that Memento metaphor, I have to admit this whole pattern isn’t anything fancy. It’s just recognizing that LLMs have limits on how much they can hold in context and still reason well. Work with those limits instead of fighting them, and suddenly everything gets a tad easier.
Arrived at 100% context window capacity. Compacting the message and sending it to another agent: