Short-Term Memory, Long-Term Memory, and the Context Window
A customer success team at a logistics SaaS shipped their first onboarding agent in February 2026. It greeted new customers, asked them three setup questions, then helpfully forgot the answers about twenty minutes into the conversation. The CS lead opened a ticket with the platform vendor titled "Lindy is broken." Lindy wasn't broken. The context window had simply rolled. The agent had no memory layer. The conversation had grown past 12,000 tokens of back-and-forth and the platform's default behavior was to truncate the oldest messages first. This lesson is about predicting that exact moment โ when your agent stops sounding smart โ and choosing, on purpose, where memory lives and how it gets retrieved. It is not a magic feature. It is a system you design.
Three Kinds of Memory, and Why Mixing Them Up Breaks Agents
The single most common mistake operators make in 2026 is talking about "memory" as if it were one thing. It isn't. There are at least three distinct memory systems in any production agent, each with different cost, latency, persistence, and failure modes. Knowing which one is responsible for which kind of recall is the difference between an agent that feels coherent and one that feels brain-damaged.
Short-term memory: the context window
This is what most operators mean when they say "the agent remembers." It's the running conversation that fits inside the model's context window โ the system prompt, the conversation history, any tool outputs, and the current user message. In May 2026, Claude Sonnet 4.5 ships with a 200,000-token context window, GPT-5 with 256,000, and Gemini 2.5 with a full 1,000,000. Sounds infinite. It isn't. Context windows are working memory, not storage. They are wiped clean at the end of the session. And โ this is the part that surprises everyone โ long before they hit the limit, attention starts thinning out across the haystack.
Session memory: the rolling buffer
Most agent platforms maintain a session-level buffer that survives across model calls within one conversation but doesn't persist beyond it. Lindy, Sierra, Decagon, Cognosys, and Cassidy all do this. The agent "remembers" what the user said five minutes ago because the platform is faithfully appending each turn to a buffer and re-injecting it into the next prompt. When that buffer overflows the context window, something has to give: oldest-first truncation, summarization, or selective retention. Different platforms make different choices, and most don't document them clearly.
Long-term memory: the persistent store
This is what actually makes an agent feel like it knows you. Zapier Memory, Lindy's persistent context feature, Mem0 (the open-source memory layer that's emerged as a de facto 2026 standard), and any vector-store-based custom solution all fit here. The agent writes facts to a durable store ("user prefers email over phone," "their renewal date is March 15"), retrieves them at the start of future conversations, and uses them to ground responses. This is the layer that turns one-shot helpers into actual ongoing relationships. It is also the layer where most teams have no governance, no expiration, and no audit trail. We'll come back to that.
An agent that "remembers" without a persistent memory layer is performing memory inside the context window. The moment that window rolls โ and it will โ the illusion ends. Every operator should be able to predict that moment for their own agent.
Predicting When the Thread Breaks
The most useful skill in this lesson is the ability to look at any conversational agent and predict, within a turn or two, when it will lose the thread. The mechanics are deterministic once you understand them.
Step 1: Count the per-turn cost
For any agent, estimate how many tokens each conversation turn consumes. A turn is one user message and one agent response, plus any tool calls. For a basic customer support agent: maybe 200 tokens of user input, 300 tokens of agent response, 150 tokens of system prompt that gets re-injected every turn, and 800 tokens of retrieved context if it's RAG-backed. That's 1,450 tokens per turn at the floor.
Step 2: Add the fixed overhead
System prompt, tool definitions, persona description, format rules โ all of these sit at the top of the prompt every turn. A modern agent with 6-10 tools and a detailed persona easily eats 4,000-8,000 tokens of fixed overhead before the conversation even starts. This part doesn't grow; it just lives there, occupying budget.
Step 3: Multiply by the limit
If your fixed overhead is 5,000 tokens and each turn costs 1,500 tokens, you fit roughly (200,000 - 5,000) / 1,500 = 130 turns before a 200K context window technically overflows. But this is misleading. The platform will start summarizing or truncating long before 130 turns. And the model's attention will degrade well before that.
Step 4: Account for attention degradation
This is the part vendors don't talk about. Even at 50% context fill, performance on certain tasks โ particularly multi-fact recall โ starts to drop. The phenomenon is widely known as "needle in a haystack" or "lost in the middle." A fact buried in the middle of a long context gets less attention than the same fact placed at the start or end. The 2025 "Lost in the Middle" research from Stanford showed the U-shaped curve clearly, and 2026 long-context models are better but not immune. Practical rule of thumb: design your agent assuming it can reliably use the first 20% and the last 20% of its context; everything in the middle is a coin flip on recall.
The diagnostic question
Ask yourself: "At what conversation turn does my agent stop being able to recall facts from turn 1?" If you don't know, you have an agent that will mysteriously stop working at a specific point and you won't be able to explain why. If you do know, you can design around it โ with summarization, with persistent memory, or with re-retrieval.
When "Just Stuff It in Context" Actually Works
The 2025-2026 explosion of context window sizes โ 200K with Claude Sonnet 4.5, 256K with GPT-5, 1M with Gemini 2.5 โ produced an entire cohort of engineers and operators who concluded that memory was a solved problem. Just stuff it in context, ride the model's attention, ship the thing. Sometimes this works. Often it doesn't. Here's the honest decision matrix.
Context-stuffing works when:
- The session is bounded. A 45-minute customer support call doesn't need persistent memory; it needs reliable short-term recall within a single conversation.
- The corpus is small. A 30-page policy document fits comfortably in 50K tokens and can be re-injected each turn. No retrieval needed.
- The information is non-recurring. You're answering a one-time question against a one-time document. No future session will need this.
- Cost is not load-bearing. Stuffing 100K tokens of context per turn at $3 per million input tokens (Claude Sonnet 4.5 standard pricing) is $0.30 per turn. For a high-value enterprise agent, fine. For a high-volume consumer agent, lethal.
Context-stuffing fails when:
- You're paying for the same context every turn. Without prompt caching, you reread the same documents on every turn. Prompt caching helps a lot (Anthropic and OpenAI both ship it in 2026), but you still pay the cache-write cost.
- The agent needs to retrieve specific facts from the middle. Lost-in-the-middle is real. If your agent needs to reliably pull a single sentence out of 80K tokens, you're better off with retrieval than with context stuffing.
- Persistence across sessions is required. Context doesn't survive session end. If "this user's preferences" needs to outlive the conversation, you need a persistent store.
- You have hundreds or thousands of documents. Even a million-token context doesn't fit a company's entire knowledge base. Retrieval is unavoidable above a few hundred pages.
The 2026 hybrid pattern that actually ships
Most production agents in 2026 use all three memory tiers in concert:
- System prompt and tools live at the top of context, cached.
- The current session's conversation lives in the rolling buffer, occasionally summarized.
- Persistent facts about the user and their account get loaded from a memory store at session start, formatted as a small "what we know about this user" block.
- Knowledge-base content gets retrieved on demand via RAG, scoped to the specific query.
The mistake is treating these as substitutes. They are complements.
The Needle in a Haystack Problem at Scale
Around mid-2024, model vendors started publishing "needle in a haystack" benchmarks โ embed a specific fact in a long document, ask the model to retrieve it, and measure accuracy across context positions. Early Claude 3 and GPT-4 Turbo showed dramatic degradation past 50% fill. By 2026, the headline accuracy numbers look great โ Claude Sonnet 4.5 and Gemini 2.5 both hit 99%+ on the standard NIAH benchmark across their full context windows. The trap is that "needle in a haystack" measures recall of a single random fact. Real agent workflows ask for something harder.
Multi-needle and reasoning-over-context
The real failure mode in 2026 isn't "find this sentence in 200K tokens." It's "given these 47 separate facts scattered across the conversation, reason about their combined implications." Multi-needle benchmarks โ find 8 needles in one haystack and synthesize โ drop accuracy by 15-30 points across all frontier models. Reasoning-over-long-context tasks drop further. The bigger your context, the more the model is being asked to do, and the more places things go quietly wrong.
What this means operationally
If your agent's job is to maintain a coherent picture of an ongoing situation โ a sales conversation that develops over weeks, a support case that touches five departments, a project that spans 100 tickets โ context stuffing is the wrong tool. You need a memory architecture that distills the situation into structured facts, stores them durably, and re-injects only what's relevant. This is exactly what Mem0, Zapier Memory, and the persistent-context features in Lindy and Sierra are built for.
The 2026 Memory Platforms, Named and Compared
Operators need to pick a memory layer. Here's the honest 2026 lay of the land.
Zapier Memory
Tightly integrated with Zapier's automation platform and Zapier Agents. Memory entries are scoped per-agent and per-user, queryable from any Zap. Best when your agent ecosystem is already on Zapier and your memory needs are simple key-value or short text. Pricing rolls into the Zapier subscription, which is operator-friendly. Weakness: not a great fit for very high-volume conversational agents.
Lindy persistent context
Lindy lets agents store and retrieve user-specific context that survives across conversations. It's the simplest "just enable it" memory experience on the no-code side in 2026 โ toggle it on, write to it via the standard agent flow, retrieve at session start. Weakness: less flexible than a custom solution; you live within Lindy's data model.
Mem0 (open-source memory layer)
The breakout open-source project of 2025-2026. Mem0 sits between your agent and an underlying vector store (it supports pgvector, Pinecone, Qdrant, and others), and provides a clean memory API with automatic deduplication, fact extraction, and decay. It's become the default for engineering teams building custom agents who don't want to roll memory from scratch but also don't want to be locked into a no-code platform. If you're shipping a custom agent on Claude, GPT, or Gemini and need real memory, Mem0 is the 2026 first stop.
Letta (formerly MemGPT)
The other open-source memory framework worth knowing. Letta implements the "agent operating system" pattern โ the agent has self-managed memory blocks that it reads and writes via tool calls. More opinionated than Mem0; powerful when the model is allowed to genuinely curate its own memory; less of a fit for tightly governed enterprise agents.
Roll your own with a vector store
The DIY path: write facts to a vector store at write time, retrieve top-k facts at query time, format them into a "what we know about this user" prompt block. Total control. Maximum operational responsibility. Reasonable if you already run a vector store for RAG and want one less dependency. Painful if you have to build it before you have customers.
The decision tree
- If you're on a no-code agent platform (Lindy, Sierra, Decagon, Cassidy, Cognosys): use the platform's native persistent memory. Don't fight the platform.
- If you're on Zapier Agents: use Zapier Memory.
- If you're building a custom agent and need a real memory API: Mem0.
- If you want the agent to self-curate memory like an OS: Letta.
- If you're already running pgvector for RAG and want one less moving part: DIY with the same vector store.
The Re-Retrieval Pattern
There's a fourth option that most operators forget about: don't store the memory at all. Just re-retrieve from source on every session.
If the user's account state is the source of truth in Salesforce, you don't need to "remember" their renewal date. You retrieve it from Salesforce at session start. If their support history is in Zendesk, you fetch the last 5 tickets via MCP. If their product usage is in Mixpanel, you query it.
Re-retrieval is underrated because it has three big operational advantages:
- No data duplication. The source system is the source of truth. Your memory layer can't go stale because there is no memory layer.
- Permissions inheritance. If the user lost access to a record in the source system, the agent inherits that loss automatically.
- Auditable. The retrieval call is logged in the source system's audit log. Compliance teams love this.
The trade-offs:
- Latency. Every session pays the cost of an API round-trip.
- Rate limits. High-volume agents can saturate the source system's API.
- Source system availability. If Salesforce goes down, your memory goes with it.
The 2026 pattern: re-retrieve facts that exist in a source system; persist only the facts that don't. User preferences ("prefers email") are persisted. Account state ("renewal date") is re-retrieved. This rule alone will save your operations team hours of debugging stale data.
The Incident That Taught the CS Team Everything
Back to the logistics SaaS. The actual root cause took two hours to find because everyone assumed the platform was buggy. Here's what actually happened.
The agent had a 6,000-token system prompt โ persona, format rules, eight tool definitions, a detailed onboarding script. The first three turns of onboarding gathered company name, team size, and primary use case (about 500 tokens of conversation). Then the agent started walking customers through configuration, which involved tool calls returning JSON blobs of 1,500-3,000 tokens each. By turn 12, the conversation buffer was at 28,000 tokens โ well within the 200K context window. By turn 25, it was at 60,000 tokens, and the platform's default summarization kicked in. The summarizer dropped the original three answers because they hadn't been "referenced recently."
The fix was a single architectural change: at the end of the onboarding intake, the agent wrote those three facts to Lindy's persistent memory. From then on, they were re-injected at session start. Not stored in the conversation buffer; stored in the memory layer. The "agent that forgets" was an agent without a memory architecture, performing memory inside the rolling buffer until the buffer rolled.
The rule: if a fact matters past the current conversation, write it to persistent memory the moment you have it. If it matters only inside the current conversation, keep it in the buffer but expect to summarize. Conflating these two failure modes is the most common cause of agents that "mysteriously forget."
Memory Governance: The Part Everyone Skips
One last thing operators ship without: governance. Persistent memory is data. It has retention policies, access controls, audit logs, and right-to-deletion obligations. In 2026, with the EU AI Act's Article 26 deployer obligations binding from August, this stops being optional.
Memory hygiene checklist
- Expiration. Does every memory entry have a TTL? Renewal dates expire after the renewal. Preferences live longer. "User is having a bad day" should expire in hours.
- Confidence. Does each fact carry a confidence score? A fact extracted from one off-hand mention should not have the same weight as one the user explicitly confirmed.
- Source attribution. Where did this fact come from? Which conversation, which turn?
- User visibility. Can the user see what the agent remembers about them and correct or delete it?
- Cross-user contamination. Are you sure memory is isolated per user and per tenant? This is the most catastrophic possible bug.
- PII rules. Are you storing data you shouldn't? Health, financial, or political opinion data has heavier obligations under GDPR and the EU AI Act.
An agent that helpfully remembers everything its users say is one breach away from a regulatory event. Treat persistent memory as a database. Because that's what it is.
Key Takeaways
- Memory in agents is three distinct systems: short-term (context window), session (rolling buffer), and long-term (persistent store). Don't conflate them.
- The May 2026 context window state: Claude Sonnet 4.5 at 200K, GPT-5 at 256K, Gemini 2.5 at 1M. Big, but still working memory โ wiped at session end.
- Predict the breaking point: count fixed overhead, per-turn cost, and account for the 20%/middle/20% attention pattern. Know which turn your agent loses the thread.
- "Lost in the middle" and multi-needle reasoning failures are the real 2026 failure modes. Single-needle benchmarks understate the problem.
- Context-stuffing works for bounded sessions, small corpora, and one-time questions. It fails when you need persistence, cross-session continuity, or specific-fact retrieval at scale.
- The 2026 memory platforms: Zapier Memory (Zapier ecosystem), Lindy persistent context (no-code default), Mem0 (open-source default for custom agents), Letta (agent OS pattern), DIY vector store.
- Re-retrieval is the underrated fourth option: don't store what already lives in a source system. Re-retrieve from Salesforce, Zendesk, Mixpanel on demand.
- The architecture rule: re-retrieve facts that exist in a source system; persist only the facts that don't.
- Persistent memory is data with retention, access control, and right-to-deletion obligations. Build governance from day one.
- Most "the agent forgot" complaints are not platform bugs. They're architecture choices the operator didn't make explicitly.
Skill.re