The context window is the amount of text an AI model can “see” at one time. Think of it as the model’s working memory. Everything outside the context window is invisible to the model.
For most modern models, the context window is large - hundreds of thousands of tokens. That sounds like a lot. And for a single conversation, it is. But for production systems that need to operate consistently over weeks and months, it is a fundamental constraint.
Why Context Windows Break Production Systems
Here is the scenario: You build an AI agent and give it a 50-page operations manual as its system prompt. It works perfectly in testing. But three months later, the operations manual has grown to 200 pages. Now it doesn’t fit in the context window. The agent starts ignoring the parts that get cut off. Your carefully designed system starts producing inconsistent output.
Or: You have a customer service agent that needs to know your entire product catalog. The catalog has 500 products. The product descriptions alone exceed the context window. The agent can’t see all the products at once, so it starts making up information about products it can’t see.
The Solution: Retrieval-Augmented Generation
RAG (Retrieval-Augmented Generation) solves the context window problem by storing your knowledge in a vector database and retrieving only the relevant pieces at query time.
Instead of loading your entire operations manual into the context window, you store it in a vector database. When the agent needs to answer a question, it first searches the database for the relevant sections, retrieves only those sections, and loads them into the context window alongside the user’s question.
The agent never needs to see the entire manual at once. It only sees what is relevant to the current task.
The Practical Rule
Never design a system that requires an AI to hold all context in a single window. Design for retrieval. Store knowledge in a vector database. Query it dynamically. Build systems that scale with your knowledge, not systems that break when your knowledge grows.
Related reading:
- Why Your AI Forgets Everything
- Obsidian as an AI Knowledge Capture System
- Supabase pgvector: Fixing the RPC Error
Found this useful? Check out the Learn section for structured micro-lessons on building AI systems, or read more on the blog for more practical guides.
Find me across the web
Stay curious, my AI friend. It's the secret sauce - think like you are seven. - Ryan
