Infinite context for OpenAI agents, explained.
What happens to a conversation that outgrows the context window, the ways to deal with it, and how to add memory to the agent you already have. Every guide is also served as markdown at its path plus .md.
The problem
- AI agent memory: long-term memory for agents explained
What long-term memory for AI agents is, the memory types, how it is written, recalled and forgotten, why a bigger window can't replace it, and the tools.
- Infinite context for LLMs: what it is, how to get it
No model has an infinite context window. What infinite context means in research (Infini-attention, EM-LLM) and how agents get it in practice today.
- Does the OpenAI API have memory? Adding it in 3 calls
No. The API has no memory endpoint and ChatGPT's memory is not exposed. What OpenAI keeps for you, what it costs, and how to add long-term memory.
- Chat history too long for OpenAI? How to trim or stop it
Fix a chat history that no longer fits: count tokens, trim safely (keep tool-call pairs), summarise old turns, or stop resending the history at all.
- Context window management for LLM agents: 4 strategies
How to keep a long agent conversation inside the context window: truncation, summaries, retrieval and keeping what matters, with token budgets, caching, costs.
- Why AI agents should forget: less context, better answers
Why resending the whole conversation hurts an agent: cost, latency and worse answers from long, noisy context. Keep what matters; bring back what is relevant.
- Agent memory vs RAG: differences and when to use each
RAG retrieves from documents; agent memory writes, updates and forgets what a conversation learned. A side-by-side table, examples, and when you need both.
How to
- OpenAI Responses API memory: conversation state and beyond
Does the Responses API remember earlier turns? How previous_response_id, store and the Conversations API keep state, and how to add long-term memory to it.
- Add memory to a chatbot (OpenAI, streaming included)
How to add memory to an OpenAI chatbot, streaming or not: where history lives, when to save the reply, how to get usage from a stream, and per-user memory.
- Let the model write its own notes: the note-tool pattern
The model that was in the conversation writes better facts than a summariser. How the note tool works, what a good fact is, and how to handle note calls.
- Memory per conversation, not per user
How to scope agent memory: why a Threadless AI memory is one conversation, how to map it to your ids, and what to do about edits, branches and user facts.
- What happens to your agent when memory is down
A memory layer in front of every model call must fail open. How the Threadless AI SDK falls back to a local tail, and which errors it still surfaces.
- Fix OpenAI context_length_exceeded errors
What OpenAI's context_length_exceeded error means, how to count tokens, trim chat history without breaking tool calls, summarise, or stop resending it.
Compared
- OpenAI compaction vs a memory layer: what each keeps
How Responses API compaction works: compact_threshold, the /responses/compact endpoint, what the encrypted item keeps, what it costs, and when memory fits.
- previous_response_id cost and the OpenAI Conversations API
Is previous_response_id cheaper? No: every earlier input token is billed again. How chaining, caching and the Conversations API work, and what they cost.
- Threadless AI vs Mem0: differences and when to choose each
Mem0 is a memory store you add to and search; Threadless AI returns the whole OpenAI request with history managed. Design, pricing, benchmarks, migration.
- Threadless AI vs Zep: differences and when to choose each
Zep builds a temporal graph per user and returns a context block; Threadless AI returns the whole OpenAI request for one conversation. How they differ.
- Threadless AI vs Supermemory: differences and when to choose
Supermemory is a memory store you add content to and search; Threadless AI returns the whole OpenAI request for one conversation. How they differ.
- Threadless AI vs Letta (MemGPT): when to choose each
Letta runs your agent on its own server and manages its memory there; Threadless AI manages memory for the OpenAI agent you already run. How they differ.
- Mem0 vs Zep vs Letta: agent memory compared (2026)
Mem0 vs Zep vs Letta compared. Vector store, temporal graph and agent runtime; self-hosting, pricing, the benchmark dispute, and when to pick none of them.
- Mem0 alternatives (2026): 8 agent memory options compared
Mem0 alternatives compared on design, self-hosting, graph and time awareness, pricing and benchmarks. Zep, Letta, Supermemory, Cognee, LangMem and more.
- Zep alternatives (2026): 8 agent memory options compared
Zep alternatives compared now Community Edition is no longer maintained. Self-hosting, graph databases, credit pricing, and when simpler fits.
- Supermemory alternatives for developers: memory APIs
Supermemory alternatives for agent memory APIs. Mem0, Zep, Letta, Cognee, Honcho and Threadless AI compared on open source, self-hosting and pricing.
- Letta alternatives (2026): agent memory and runtimes
Letta (MemGPT) alternatives, split by what you need. A memory layer (Mem0, Zep, Threadless AI) or an agent runtime (LangGraph, OpenAI Agents SDK, CrewAI).
Reference
- Agent memory glossary: 53 LLM memory terms defined
Plain definitions of agent memory terms. Context window, episodic, semantic and procedural memory, RAG, compaction, recall and supersession.