Your Context Window Has Two Limits: What Fits and What Still Works
A model can accept a huge prompt long before your application can use that prompt reliably. Measure an effective context limit with task-specific evals, evidence-position tests, and latency/cost budgets instead of treating the provider maximum as usable capacity.
On this page
A long context window removes an obvious failure mode.
The request no longer gets rejected because the prompt is too large.
That feels like progress until the application starts failing in a much less visible way: the request succeeds, the answer looks normal, and the model quietly misses the one piece of evidence that mattered.
That is the long-context problem I care about in production.
The provider gives me one number: how much input the model will accept.
I need a second number: how much context this application can use before the behavior I depend on starts degrading.
Those are not necessarily the same limit.
I think of them as the hard context limit and the effective context limit.
The first comes from the model API. The second has to come from my evals.
I have written separately about what belongs in an agent's context window and about budgeting and compacting long-running agent context. This article focuses on the question that should come before both of those decisions:
How much context can this model use reliably for the task I actually ship?
The API accepting the prompt is not a quality test
Suppose an internal support assistant can now accept the entire product manual, a year of release notes, several account policies, and the full conversation history in one request.
Nothing stops me from sending all of it.
That does not prove sending all of it is a good design.
Long-context research has repeatedly shown that where relevant information appears can matter, not just whether the information is technically inside the context window. The *Lost in the Middle* study found substantial position sensitivity on long-context retrieval and multi-document question answering: relevant information placed near the middle could be harder for models to use than information near the beginning or end.
That result should not be turned into a universal rule that every model always gets worse at exactly the same length. Models improve, tasks differ, and prompt structure matters.
The engineering lesson is narrower and more useful:
presence is not the same as effective use.
A document can be inside the request and still fail to influence the answer when I need it to.
That means a successful HTTP response tells me almost nothing about whether the context length is safe for my product.
I want an effective limit per task, not one number for the company
A context limit is not only a model property.
It is a property of the combination of:
- model;
- prompt structure;
- task;
- retrieval strategy;
- amount of distractor information;
- evidence position;
- output requirement.
A summarizer may work well over a document length at which an exact-fact workflow starts missing critical details. An agent choosing among tools has a different failure mode again. A RAG answer that needs three pieces of evidence may behave differently from a request that needs one sentence copied from a contract.
So I would not create a company-wide rule saying:
Our models support 500K useful tokens.I would create a task-specific statement closer to:
support-policy-answering-v4model: candidate-modelquality floor: 98%validated context range: <= 96K input tokensvalidated evidence positions: beginning / middle / endThe exact numbers here are illustrative. The important part is that they come from a repeatable evaluation rather than a model card.
Build the eval around the workload you actually have
A simple needle-in-a-haystack test is useful because it answers a clean question: can the model recover a known piece of information from increasingly long input?
I would not stop there.
The RULER benchmark was created partly because simple needle retrieval can make long-context capability look better than it is. It adds tasks such as multi-hop tracing and aggregation, where the model has to do more than locate one string.
That is closer to how I would test an application.
For a support agent, for example, I might build cases where the model must:
- find one policy fact;
- combine two sections of the policy;
- distinguish the current rule from an outdated rule;
- refuse to answer when the required evidence is absent;
- choose the correct tool only when the evidence supports the action.
Then I would run those cases at several context sizes and move the important evidence around.
The matrix might look like this:
| Context bucket | Evidence position | What I measure |
|---|---|---|
| Small | beginning / middle / end | correctness, latency, tokens |
| Medium | beginning / middle / end | correctness, latency, tokens |
| Large | beginning / middle / end | correctness, latency, tokens |
| Near provider limit | beginning / middle / end | correctness, latency, tokens |
I care about the shape of the curve more than one benchmark score.
If quality is flat through the first three buckets and then drops sharply when evidence is in the middle, that is useful production information. It tells me where I need to reduce or restructure context before users find the boundary for me.
Make context length a first-class eval dimension
I prefer representing the experiment explicitly instead of burying context size inside test fixtures.
type EvidencePosition = "beginning" | "middle" | "end";type LongContextCase = { id: string; targetTokens: number; evidencePosition: EvidencePosition; question: string; expectedAnswer: string; context: string;};function placeEvidence( filler: string, evidence: string, position: EvidencePosition,): string { if (position === "beginning") { return `${evidence}\n\n${filler}`; } if (position === "end") { return `${filler}\n\n${evidence}`; } const midpoint = Math.floor(filler.length / 2); return [ filler.slice(0, midpoint), evidence, filler.slice(midpoint), ].join("\n\n");}In a real benchmark I would use the provider/model tokenizer rather than estimating tokens from character count.
I would also use representative documents instead of repeating synthetic filler everywhere. Repetition can create an artificial benchmark that looks nothing like the prompt shape in production.
The goal is not to produce a beautiful long-context leaderboard.
The goal is to discover where my application becomes unreliable.
Test more than recall
Exact recall is easy to score, which makes it tempting to use as the entire test suite.
For many production systems, recall is only the first step.
Suppose the context contains:
Policy from 2025:Refunds above $500 require finance approval.Policy from 2026:Refunds above $300 require finance approval.The model can successfully retrieve both passages and still make the wrong decision if it applies the stale rule.
So I would grade the behavior the application needs, not just whether the model can repeat the hidden fact.
For different workflows, that may include:
- exact-answer correctness;
- groundedness against the supplied evidence;
- choosing the current version of a policy;
- structured-output validity;
- correct tool selection;
- correct no-tool behavior;
- multi-hop reasoning across several pieces of evidence;
- abstaining when the necessary evidence is missing.
This is why I prefer the term effective context limit over something like “maximum recall length.”
The limit I care about is where the complete task stops meeting its quality bar.
Find the degradation point, then leave headroom
Once I have eval results, I do not want application code to use the provider maximum automatically.
I want a policy for the workload.
type ContextPolicy = { providerHardLimitTokens: number; effectiveLimitTokens: number; reservedOutputTokens: number;};function assertContextWithinPolicy( inputTokens: number, policy: ContextPolicy,): void { const hardInputLimit = policy.providerHardLimitTokens - policy.reservedOutputTokens; if (inputTokens > hardInputLimit) { throw new Error("Context exceeds the provider hard limit"); } if (inputTokens > policy.effectiveLimitTokens) { throw new Error( "Context exceeds the validated effective limit", ); }}I deliberately keep the two checks separate.
The provider hard limit answers:
Will this request fit?
The effective limit answers:
Is this request still inside the range we have evidence works?
Crossing the second limit is a product-quality decision even if the API is perfectly happy to accept the request.
I also leave output headroom explicitly. A context budget that consumes every available input token and leaves no room for the required answer is not really a budget.
Do not solve overflow with blind truncation
Once the prompt crosses the validated range, the next question is what to remove.
The worst answer is usually:
slice the last N tokens and hopeThat can remove the system instructions, the current task, a tool result, or the one piece of evidence that justified the answer.
I would rather reduce context according to its meaning.
Conversation history can often be compacted. Large tool results can be stored outside the prompt and fetched by handle. A knowledge base can be searched instead of pasted wholesale. Old retrieved evidence can be replaced when the user's question changes. Independent investigations can move into separate workers with clean context.
The important part is that overflow becomes a context assembly problem, not a tokenizer accident.
That is also why a larger window does not make retrieval obsolete.
Retrieval is not only a workaround for models that cannot fit a corpus. It is a way to decide which evidence deserves attention on this request.
A large context window gives the retriever more room to return difficult cases. It does not remove the value of selecting relevant information.
Position tests catch failures that token counts miss
Imagine two prompts that are both 80K tokens.
The first places the active task, current policy, and supporting evidence near the parts of the prompt the model uses reliably.
The second buries the current policy between pages of stale logs and old conversation history.
The token count is identical.
The behavior may not be.
That is why I keep evidence position as a dimension in the eval rather than testing only prompt size.
For a real application I would test at least:
important evidence near the beginningimportant evidence around the middleimportant evidence near the endmultiple relevant passages at different positionsrelevant passage surrounded by plausible distractorsold and new versions of the same factI would also randomize document ordering in some cases so the benchmark does not reward one fixed prompt layout.
The point is not to optimize every prompt around one academic benchmark. It is to make position sensitivity visible before the system depends on an accidental ordering.
Long context is still useful
I do not think the conclusion should be “large context windows are bad.”
They are extremely useful.
There are tasks where seeing a large amount of source material together is genuinely better than aggressively reducing it too early. Examples include reviewing a long contract with cross-references, reasoning over a large conversation, comparing several documents, or inspecting a substantial set of code after an initial search has identified the relevant area.
The larger window also gives an agent more room to recover when a request unexpectedly needs extra evidence.
What I would avoid is converting available capacity into mandatory prompt size.
If a 20K context solves the task as reliably as a 200K context, I prefer the 20K version. It is easier to inspect, usually cheaper, and leaves more headroom for the cases that actually need it.
Anthropic's context-engineering guidance makes a similar point at the architectural level: context should be treated as a finite resource, and agents benefit from curating a high-signal working set rather than continuously accumulating everything they encounter.
Trace the effective-limit utilization in production
The eval gives me a policy before deployment. Production telemetry tells me whether the application is drifting toward the edge of that policy.
I would record metadata such as:
type ContextTelemetry = { runId: string; inputTokens: number; effectiveLimitTokens: number; utilization: number; retrievedChunkCount: number; historyMessageCount: number; modelRelease: string; contextPolicyVersion: string;};function buildContextTelemetry(input: { runId: string; inputTokens: number; effectiveLimitTokens: number; retrievedChunkCount: number; historyMessageCount: number; modelRelease: string; contextPolicyVersion: string;}): ContextTelemetry { return { ...input, utilization: input.inputTokens / input.effectiveLimitTokens, };}I would not put raw prompts or user text into metric labels. Token counts and version identifiers are enough for aggregation; detailed prompt inspection belongs in appropriately protected traces or debugging storage.
Then I can answer useful operational questions:
- What percentage of requests run above 80% of the effective limit?
- Which workflow is growing its context fastest?
- Did a retrieval change increase average prompt size?
- Did a model migration move the quality cliff?
- Are high-context requests also showing worse latency or task success?
Without that visibility, context growth becomes a slow reliability regression that looks like random model behavior.
Re-run the long-context eval when the runtime changes
The effective limit is not permanent.
A model upgrade can change it. So can a new system prompt, different tool descriptions, a retrieval change, a new document format, or a different context ordering strategy.
That means the long-context suite belongs next to the rest of the behavioral evals for the AI runtime.
I would version results by the complete release, not just the model name.
For example:
support-agent-2026-09-09.1model: model-v2prompt: prompt-v14tools: tools-v8retrieval: retrieval-v5context-policy: long-context-v3If the new release improves normal cases but starts failing the middle-position slice at large context sizes, I want the release gate to catch that.
A bigger advertised context window is not automatically an upgrade if my application becomes less reliable inside the range it actually uses.
The test should fail on a regression, not on a marketing number
A simple release assertion can compare each important context slice against its own quality floor.
type ContextEvalResult = { bucket: string; evidencePosition: EvidencePosition; passRate: number;};function assertContextEval( results: ContextEvalResult[], minimumPassRate: number,): void { const failed = results.filter( (result) => result.passRate < minimumPassRate, ); if (failed.length > 0) { throw new Error( `Long-context regression in ${failed.length} eval slices`, ); }}In a higher-risk workflow I would normally use different thresholds for different behaviors rather than one global pass rate. A tool-authorization failure should not be averaged away by improvements on easy summarization cases.
The important part is that the decision is based on application behavior at the lengths and positions that matter.
The takeaway
A context window has two limits.
One is the maximum request size the provider accepts.
The other is the largest working set your application can use while still meeting its quality, latency, and cost requirements.
Only the first one comes from the provider.
Measure the second one.
Run the task you actually ship across increasing context sizes. Move relevant evidence through the beginning, middle, and end. Include distractors. Test multi-hop behavior when the application needs it. Track latency and token usage alongside correctness. Set an effective limit below the point where the behavior starts to fail, and make crossing that boundary a visible application event rather than a silent prompt-growth problem.
Then use the larger provider window for what it is genuinely good at: headroom.
More room is useful.
It just does not remove the need to decide what deserves to be in the room.
References
KEEP READING
Related engineering notes
A Failover Route Is Not a Recovery Path: Proving Independence in AI Infrastructure
Two LLM providers can share the same failure domain. Build an evidence-backed recovery graph that checks cloud, networking, identity, control-plane and capacity dependencies before admitting fallback routes, then test correlated outages without weakening safety.
Read articleAn Eval Platform Sunset Can Erase Your Release Evidence: Build an Evidence-Escrow Migration Gate
When a hosted LLM evaluation platform retires, switching runners is not enough. Preserve the historical evidence, reconstruct grader semantics, validate scoring parity, and enforce a fail-closed release gate that survives the service shutdown.
Read articleWhen the Package Runs Before Your App: Quarantining AI Framework Releases
The 2026 agent-framework PyPI compromise exposed a blind spot in AI build pipelines: Python startup hooks execute before application imports. Design an artifact-quarantine gate, inspect wheels without installing them, separate credentials, and recover from suspected exposure.
Read article