AI Agent Memory: Why Context Windows Aren’t Enough
How AI agent memory differs from context windows and RAG, with a token-cost model and proposed tests for reliable project continuity.
AI Agent Memory: Why Context Windows Aren’t Enough
We don't expect a processor to replace a database. Why should an LLM replace a memory system?
In my work on OSIX, Agent-Diary and CrazySkills, I want an agent to resume a project from durable records. The context window is its working input, not the source of truth.
Drag the figure to separate the blue knowledge records and green operational records from the amber working set. The violet model receives only the selected information.
01 / Why a million-token context window is not enough
On December 2, 2026, Lydia Hallie announced Claude Code’s earlier default compaction setting. The official documentation describes a 400K setting for current native 1M models, with exceptions. On this setting, compaction begins around 367K tokens. The full window is available with /autocompact 1m.
- Tokens
Unit · tokens
View chart data
| Category | Tokens |
|---|---|
| 1. Capacity | 1,000,000 |
| 2. Configured window | 400,000 |
| 3. Compaction ≈ | 367,000 |
I need large context windows to investigate complex bugs. But a summary can discard the constraint I need three days later. Lost in the Middle found that information retrieval performance varied with its position in the tested models’ inputs. I would test that separately on current models.
02 / Working context, RAG, durable memory and state
Working context holds the instructions and evidence for the current model request. Retrieval-augmented generation (RAG) selects material from canonical sources. Durable memory retains decisions and reviewed lessons between sessions. Operational state holds the current task and its acceptance evidence. Explicit approvals govern updates.
MemGPT explored hierarchical memory in 2023. My concern is also authority. A similarity score tells me which record might be relevant, not whether it is current or approved. A proposed change stays separate from verified state until the workflow accepts it.
03 / Context growth and inference token costs
Take 20 requests. The first carries 20,000 input tokens (B), each subsequent request adds 5,000 (Δ), and a hypothetical bounded context carries 30,000 (W) each time. Let n be the number of requests. The two formulas give the cumulative input, without compaction in the growing case.
\begin{aligned}T_h(n)&=nB+\frac{\Delta n(n-1)}{2}\\T_b(n)&=nW\end{aligned}The cumulative totals meet at request 5. At request 20, growing history has consumed 1.35 million logical input tokens, compared with 600,000 for bounded context. That is a difference of 750,000 tokens (55.6%).
- Bounded context
- Growing history
Unit · tokens
View chart data
| Category | Bounded context | Growing history |
|---|---|---|
| 1. 0 | 0 | 0 |
| 2. 2 | 60,000 | 45,000 |
| 3. 4 | 120,000 | 110,000 |
| 4. 6 | 180,000 | 195,000 |
| 5. 8 | 240,000 | 300,000 |
| 6. 10 | 300,000 | 425,000 |
| 7. 12 | 360,000 | 570,000 |
| 8. 14 | 420,000 | 735,000 |
| 9. 16 | 480,000 | 920,000 |
| 10. 18 | 540,000 | 1,125,000 |
| 11. 20 | 600,000 | 1,350,000 |
1-\frac{600\,000}{1\,350\,000}\approx 55.6\%This is arithmetic, not an OSIX benchmark. Caching changes actual billing. Retrieval and summarization add overhead. The smaller input must still support the same task quality before I can call it a useful optimization.
04 / Cost per verified task
Input tokens alone tell me little about the cost of finishing a project. I want to count the work that passes acceptance, including failed attempts.
C_{\mathrm{total}}=C_{\mathrm{inference}}+C_{\mathrm{retrieval}}+C_{\mathrm{memory}}+C_{\mathrm{review}}C_{\mathrm{accepted}}=\frac{C_{\mathrm{total}}}{N_{\mathrm{accepted}}}Use the same acceptance tests in both configurations. Record cache usage and human review time. If converting time to money, declare the rate. If nothing passes, report failure instead of dividing by zero.
If a memory layer costs more than the rediscovery it prevents, it is not an optimization.
05 / AI agent learning across sessions
I started Agent-Diary as an experiment for OSIX. I have seen the diary persist across sessions. It records introspection and changes over time.
Suppose an agent mistakes a preview for a deployment. On the next task, it should look for deployment evidence before claiming success. Retrieving the lesson is only the first step; the acceptance test is whether its next relevant action changes.
Applying lessons at initialization and during work remains an experiment I want to test. I am not claiming autonomous coordination already works. Lessons must remain correctable.
06 / Why a green preview is not a verified release
In my CrazySkills PostgreSQL release work, a successful preview or SQL readback is not proof of public activation. The desired path starts with a fresh installation and approved population, then guarded activation, real write/read and verification after restart.
Spec Kit gives development a structure. Anthropic’s long-running agent harness research uses artifacts to carry work across sessions. CrazySkills is where I want to make the transition rules explicit.
I have not established that this entire release sequence has passed.
07 / Local-first AI memory and data ownership
OSIX is under development. The direction is local-first retrieval and memory, portable knowledge, user-selected models and predictable inference costs. Local storage does not guarantee local inference. Sending data to a cloud model must be explicit.
Agent-Diary explores continuity and learning. CrazySkills addresses delivery verification. The planned Code OSIX workspace addresses coding-agent jobs across the user's own machines. Full integration is planned.
Anthropic’s context-engineering article asks what should go into a request. I also want to decide what survives that request and who can change it.
08 / Measuring agent memory and task resumption
Interrupt a task. Start a fresh session with another supported model and ask it to resume from the last verified result without replaying the conversation. Compare a conversation-only baseline against retrieval plus durable memory on identical tasks. Count a resumption as correct only when the agent recovers the applicable decision and outstanding work.
R=\frac{N_{\mathrm{correct}}}{N_{\mathrm{attempted}}}Introduce a contradictory decision and attempt an unauthorized approval. Inspect the sources and revision selected by the agent. Record missed constraints and human interventions. Calculate repeated errors against relevant opportunities rather than all messages. These are proposed measures, not results.
E=\frac{N_{\mathrm{repeated\ errors}}}{N_{\mathrm{opportunities}}}References and reading
09 / Context window ≠ memory
I still want bigger context windows. I just don't want the continuity of my work to depend on them.