Definition

What is context window?

Quick definition

The maximum number of tokens an AI model can process in a single interaction, including both input and generated output.

A context window defines the fixed memory capacity of a language model during one conversation turn. It's measured in tokens (roughly 4 characters each) and represents the total amount of text the model can read and understand before generating a response. For example, Claude 3.5 Sonnet has a 200,000-token context window, meaning it can process up to 200,000 tokens of combined input and maintain that understanding when writing its output.

Context windows are critical for AI agents, agentic workflows, and autonomous-coding systems because larger windows enable processing of longer documents, codebases, or task histories without losing information. When your input exceeds the context window, the model cannot access earlier content, forcing developers to implement chunking strategies, summarization, or retrieval-augmented generation (RAG) approaches. This limitation directly impacts how MCP servers and MCP clients exchange information and how AI-coding-agents maintain state across multi-turn interactions.

Understanding context window constraints is essential when designing multi-agent systems or orchestrating complex agentic workflows. Exceeding the limit forces token truncation, which degrades model reasoning. Developers must carefully manage prompt injection risks and task-decomposition strategies to fit within available window limits while maintaining sufficient context for accurate tool-calls and decision-making.

Example

How it shows up in practice

If you send a 100,000-token codebase review request to an AI model with a 200,000-token context window, you have 100,000 tokens remaining for the model's output and any system instructions.

Frequently asked questions

What happens when my input exceeds the context window?

The model cannot process tokens beyond the limit. Text is typically truncated from the beginning, causing the model to lose earlier context and potentially produce inaccurate responses. Use summarization or chunking strategies to stay within limits.

How does context window affect AI agents and autonomous coding?

Larger context windows enable agents to maintain state, access full codebases, and handle complex task-decomposition without information loss. Smaller windows require more frequent re-prompting and reduce reasoning capability in agentic workflows.

How can I optimize for limited context windows?

Implement retrieval-augmented generation (RAG), break tasks into smaller chunks, summarize irrelevant content, and prioritize the most critical information. Use tool-calls strategically to offload information processing.

Is context window the same as memory?

No. Context window is temporary working memory for a single turn, while memory typically refers to persistent storage between sessions. Agents often combine context windows with external memory systems for long-term state.

Related terms

Want to turn this concept into a board?

Browse templates that use this vocabulary in real workflows.