World’s largest virtual agentic engineering & quality conference
AI context is the information a model can reference in one request. Learn what fills the context window, real 2026 window sizes, and why accuracy drops.

Prince Dewani
Author

Sai Krishna
Reviewer
Last Updated on: August 9, 2026
AI context is everything a language model can reference while answering one request: the system prompt, the conversation so far, tool definitions, attached files, and its own reply. Anthropic's documentation states that accuracy and recall degrade as token count grows,[1] and the NoLiMa benchmark measured 11 of 13 long-context models falling below half their short-context accuracy at 32,000 tokens, with GPT-4o dropping from 99.3% to 69.7%.[2]
This guide covers what fills a context window, how tokens set its size, current model limits, why bigger windows do not mean better answers, and how to measure your effective limit.
Key Takeaways
A model's context is the complete set of tokens it reads before producing a response. Anthropic's engineering team defines context as the set of tokens included when sampling from a large language model.[3] That set is assembled fresh on every request and discarded when the request ends.
The reassembly is the part most explanations skip, and it drives both cost and behavior. A language model holds no state between API calls. Every turn of a chat re-sends the entire prior conversation, so turn 40 transmits turns 1 through 39 again.
Two consequences follow. Total input cost across a session grows faster than the turn count, because every turn pays again for all the turns before it. Any fact the model appears to remember was re-sent by the application on that call. Nothing persists inside the model between calls.
Five inputs fill a context window: the system prompt, conversation history, tool definitions, attached files, and the model's own generated reply. Anthropic's documentation confirms that tool definitions and extended thinking tokens draw on the same budget as user text.[1]

Tool definitions are the line item teams underestimate. They are loaded before the first user token and scale with the number of connected tools. An agent wired to a dozen servers can spend a large share of its window on schemas describing capabilities it will not use in that session.
Anthropic ships a tool search tool and separate tool-context guidance specifically to defer those definitions until a tool is needed.[1]
Tokens set context size because models measure input in text fragments, not words. Google's documentation puts 1 million tokens at roughly 50,000 lines of code at 80 characters per line, 8 average-length English novels, or transcripts of over 200 average-length podcast episodes.[4]
Tokenization is uneven, and that decides how much real material fits. Prose tokenizes efficiently because common English words map to single tokens. Code, JSON, and minified payloads do not.
The practical effect shows up in agent workloads. A 200-line JSON tool response can consume more of the window than a page of English, so a chatty API returning verbose objects becomes a context problem before it becomes a latency problem. Non-English text with heavy diacritics also splits into more tokens per visible character.
Frontier context windows now run from 200,000 to 1 million tokens. Anthropic lists a 1 million token window for Claude Opus 5 and Claude Sonnet 5, and 200,000 tokens for Claude Sonnet 4.5.[1] OpenAI lists a 400,000 token window for GPT-5.[5]
| Model | Context window | Max output |
|---|---|---|
| Claude Opus 5 and Claude Sonnet 5 | 1,000,000 tokens | 128,000 tokens |
| Claude Sonnet 4.5 | 200,000 tokens | Not stated in the context window documentation |
| GPT-5 | 400,000 tokens | 128,000 tokens |
| Gemini long-context models | 1,000,000 tokens or more | Varies by model |
Read the output column alongside the window, because they share one budget. Anthropic states that a single request to a 1 million token model can generate up to 128,000 output tokens, so the input and the reply compete for the same space and generation can stop mid-answer once the combined total runs out.[1]
No. A bigger window raises what a model will accept, not how accurately it reads. Chroma tested 18 models and reported that models do not use their context uniformly, and that performance grows increasingly unreliable as input length grows.[6]
Three independent results point the same direction. Chroma's July 2025 study by Kelly Hong, Anton Troynikov, and Jeff Huber covered GPT-4.1, Claude 4, Gemini 2.5, and Qwen3 models and found the decline is continuous rather than a cliff at the advertised limit.[6]
NoLiMa put numbers on the gap. Ali Modarressi and co-authors evaluated 13 models that claim support for at least 128,000 tokens, and at 32,000 tokens 11 of them dropped below half their short-length baselines.[2] The design detail matters: NoLiMa removes literal word overlap between the question and the target fact, which stops a model from succeeding through keyword matching alone.

Position compounds length. Nelson F. Liu and co-authors at Stanford found performance is often highest when relevant information occurs at the beginning or end of the input context, and degrades significantly when models must access relevant information in the middle of long contexts.[7] A fact buried at 50% depth is the hardest one for a model to use.
In the Reddit thread "Exposing the True Context Capabilities of Leading LLMs" on r/LocalLLaMA, practitioners compared effective context lengths from NVIDIA's RULER benchmark across GPT-4, Command-R, Yi-34B, Mixtral 8x7B, and LongChat-13B. The post notes that RULER omitted Gemini and Claude 3, and commenters pressed for the methodology paper. The thread concluded that all models experience a performance drop as context length increases, without exception.
Treat window size as a capacity figure and set the working limit from measurement. Anthropic names the effect context rot and states plainly that curating what sits in context matters as much as how much space is available.[1] The four ways context degrades in agent systems are broken down further in why AI agents forget.
Note: Validate how your AI agents handle long conversations with TestMu AI. Try free!
Context is temporary working memory for one request, while training data is fixed in the model's weights. Anthropic's documentation draws the line directly, stating the context window is different from the corpus the model was trained on and instead represents working memory.[1]
Persistent memory features are the row that causes confusion. A memory feature is a retrieval step that re-injects selected facts into the same token budget, so enabling memory makes every subsequent request larger and moves the workload closer to the degradation curve.
This distinction changes how you debug. When a model gets a fact wrong, check whether the fact was in the window on that specific call, and whether it sat in a position the model actually reads.
Four mechanisms put information into a context window: the prompt itself, retrieval augmented generation, tool call results, and file attachments. Each one writes tokens into the same budget before the model begins reading. Anthropic's documentation confirms that tool results, images, and documents all count against that budget alongside user text.[1]
Long context does not retire retrieval. Google Cloud's guidance states that long context is not ideal when data updates frequently or requires pulling from multiple sources, and recommends context caching to control the latency and cost of repeated queries over the same material.[8] Choosing between the two is a retrieval-quality decision, and the trade-offs are covered in RAG evaluation tools.
Model Context Protocol changes the plumbing, not the ceiling. It standardizes how a tool describes itself and returns data, but every schema and every response still lands in the same window, which is why connecting many servers has a measurable token cost. Selecting servers with that budget in mind is covered in MCP servers for test automation.
Exceeding the context window produces an error or a silent truncation unless the application compacts the conversation first. Anthropic's API returns a 400 invalid_request_error reading prompt is too long when the input alone exceeds the window.[1] On Claude 4.5 and newer, a request that runs out during generation stops with stop_reason model_context_window_exceeded instead.
Three distinct behaviors hide behind the phrase running out of context, and they fail in different ways.
Rolling truncation causes the most support tickets because it has no error to alert on. A user watches the assistant contradict something agreed 30 turns earlier and concludes the model is unreliable, when the earlier turn was evicted before the request was ever sent. Compaction and summarization strategies that trade detail for room are covered in advanced techniques for production ai.
Measure the effective limit by running a retrieval test on your own inputs at increasing lengths and recording where accuracy falls. Chroma's method places a target fact inside inputs of growing size, varies the depth at which that fact sits, and scores recall at each step.[6]
Writing the question without shared wording is the step teams get wrong. A needle test whose question repeats the needle's distinctive words measures string matching, not comprehension, and it will report a flattering limit. NoLiMa was built to strip that lexical overlap, and under its needles GPT-4o fell from a 99.3% baseline to 69.7%.[2]
Test for multiple facts, not one. Google's documentation notes that where you have multiple needles or specific pieces of information to find, the model does not perform with the same accuracy as on a single retrieval.[4] Most real prompts need several facts at once, so a single-needle pass says very little about production behavior.
In the Reddit thread "How can I fine-tune a LLM to increase effective context?" on r/LocalLLaMA, a developer reported that LLaMA 3.1 8B, which advertises a 128,000 token context length, degraded severely on a JSON output task once input passed 5,000 tokens. The practical takeaway is that the gap between advertised and usable length is task-specific, so measure it against your own task rather than the model card.
Instrument the run as well as the result. Anthropic exposes a token counting API for estimating a request before sending it, and every response reports actual consumption in its usage field, which turns context budgeting into a measured quantity instead of a guess.[1]
Test context handling with multi-turn scenarios that plant a fact early and require it many turns later. A single-turn assertion cannot catch context loss, because the failure only appears once the conversation grows long enough for the early fact to fall out of reach.
The failure has a recognizable shape in production. A customer gives an account number in turn 2, the conversation runs another 15 turns, and the agent asks for the account number again. Nothing throws an error and no assertion fails, so the regression reaches users intact.
TestMu AI's agent testing platform scores that behavior as a standard metric instead of leaving it to manual review, so a context regression shows up as a number that moves between runs.
You can explore the official documentation to get started with agent testing.
Behavioral scoring suits non-deterministic systems, and the wider evaluation approach is covered in AI agent testing and in LLM testing.
Measure before you upgrade. Run a retrieval grid across the input lengths you actually ship, record the length where recall drops, and use that number rather than the model card to set your prompt budget.
Treat AI context as a budget you spend on purpose. Put the decisive instruction at the start or the end of the input, keep tool definitions lean, retrieve the few passages that matter instead of attaching everything, and re-run the grid after every model upgrade because the curve moves. The published ceilings keep rising, and the published evidence keeps showing that accuracy falls well before the ceiling does.
If your product puts an agent in front of customers, add a multi-turn context-retention check to the release gate and score it on every build, the same way you would score a flaky test rate. The testmu-a2a-cli documentation covers wiring that check into a pipeline.
Author
Prince Dewani is a Community Contributor at TestMu AI specializing in AI agents, software testing, QA, and SEO. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI, and presented academic research on AI agents at PBCON-01. At TestMu AI, he has also carried out extensive cross-browser research on the support of modern web technologies such as WebGPU, WebAssembly, WebXR, WebGL2 and other web technologies, validating their compatibility and feature parity across major browsers and rendering engines through rigorous hands-on testing. Prince has hands-on experience building AI agent workflows using Anthropic Claude, Google Antigravity, n8n, LangChain, and other agentic frameworks, and works regularly with MCP and A2A protocols. He shares his work with 5,500+ QA engineers, developers, DevOps experts, tech leaders, and AI agent practitioners on LinkedIn.
Reviewer
Sai Krishna is Director of Engineering at TestMu AI (formerly LambdaTest), where he leads agentic AI for quality engineering, building AI agents that autonomously drive mobile and conversational test automation. His current focus is Agent Testing and Model Context Protocol (MCP) support for mobile. He is a core contributor and member of the Appium open-source project and the creator of AppiumTestDistribution and appium-device-farm. With over 14 years of experience including more than 9 years at Thoughtworks as a Principal Consultant, he holds a BSc in Electronics and speaks regularly at TestMu and Appium Conf on Appium, mobile automation, and agentic AI in testing.
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance