Architecture · LLM Systems

The Context Window Is a System Boundary, Not a Capacity Parameter

Every architectural decision in an LLM-backed system flows from how you treat the context window. Engineers who think about it as a size limit make different, worse decisions than engineers who think about it as a trust surface, a cost boundary, and an accuracy constraint.

Arjun Jaggi  ·  September 1, 2026  ·  14 min read
2 Coined frameworks: Context Boundary Contract, Positional Degradation Zone
4 System boundary dimensions: knowledge, trust, cost, accuracy
6 Research citations grounding the technical claims

The Wrong Mental Model, and Its Consequences

Ask an engineer what the context window is and they will say: "It is how many tokens the model can process at once." That is not wrong. It is also not useful for making architectural decisions.

The context window is better understood as a system boundary - the surface through which everything the model knows, everything it can be manipulated by, and everything it pays attention to enters the computation. Every token in the context window is a decision. What content gets in, in what order, from what source, with what trust level: these are design choices with measurable consequences for accuracy, security, cost, and latency.

Teams that treat the context window as a capacity parameter ask: "Is this under the limit?" Teams that treat it as a system boundary ask: "What have I let into the model's reasoning, and what does that imply for correctness, trust, and cost?" The gap between these two questions is where most LLM reliability problems live.

This post introduces two formal constructs for reasoning about the context boundary: the Context Boundary Contract and the Positional Degradation Zone. Both are directly actionable. Both fill gaps that existing LLM deployment frameworks, including NIST AI RMF [1] and the EU AI Act [2], do not address at the architectural level.

Internal Cross-Reference

This builds on the trust surface analysis in The AI Context Window Is a Security Boundary and the architectural debt framing in The AI Expectation Velocity Gap. The constructs here are designed to be applied at the system design stage, before the governance debt accumulates.

The Four Dimensions of the Context Window as a System Boundary

Understanding the context window as a boundary means being precise about what it controls. There are four distinct dimensions.

1. Knowledge Boundary

The model knows exactly what is in its context window, plus what was baked in during pretraining. Nothing else. Every architectural question about what the model should know reduces to a question about what enters the context: through the system prompt, through retrieval, through conversation history, or through tool outputs. The knowledge boundary is the design surface for RAG systems, memory architectures, and agent state management.

2. Trust Surface

Every token in the context window has a source: developer-controlled system prompt, user input, retrieved document, tool output, or conversation history. These sources do not all deserve equal trust. Retrieved documents can contain adversarial content inserted to manipulate model behavior, a class of attack studied formally by Greshake et al. [3] under the term indirect prompt injection. Tool outputs can be malformed or compromised. Conversation history can be manipulated by a prior turn. The context window is the single surface through which all of these trust levels mix, and the model has no native mechanism to distinguish them.

3. Cost Boundary

Input tokens are billed per token. A context window architecture that fills 100K tokens on every request costs linearly more than one that fills 8K tokens. The decision to "just put everything in context" is a cost architecture decision, and at scale it compounds quickly. The retrieval-vs-stuffing tradeoff is fundamentally a cost-quality optimization problem, and the context window is where that tradeoff is resolved.

4. Accuracy Constraint

Model attention is not uniform across the context window. Liu et al. [4] demonstrated empirically that retrieval accuracy degrades for content placed in the middle of long contexts, a phenomenon now referred to as "lost in the middle." Shi et al. [5] showed that irrelevant content added to the context degrades model performance even when the relevant content is still present. The context window is not a neutral container: its structure affects what the model reasons about and how accurately.

Fig. 1: Context Window as System Boundary
CONTEXT WINDOW BOUNDARY SYSTEM PROMPT ZONE developer-controlled, highest trust RETRIEVAL ZONE external content, variable trust, PDZ risk CONVERSATION HISTORY user-controlled, audit trail required TOOL OUTPUTS system-generated, validate before trust USER TURN (current) Developer RAG / Docs User Tools / APIs Model Response Knowledge Trust surface Audit trail Validate PDZ = Positional Degradation Zone (retrieval zone middle content)

The Context Boundary Contract

Most LLM-backed systems have no explicit specification of what may enter their context windows. The system prompt gets written, the retrieval pipeline gets wired up, and the conversation history gets appended. This is not an architecture; it is an absence of one.

The Context Boundary Contract formalizes what the context window specification should look like. It is a per-system design document that answers four questions for each content source:

Coined Framework: Context Boundary Contract

A Context Boundary Contract is a formal per-system specification that defines, for each content source entering the context window: (1) the maximum token budget allocated to that source, (2) the trust level assigned to content from that source (developer, system, user, external, unverified), (3) the validation rule applied before content enters the window (schema check, length truncation, adversarial content scan, or none), and (4) the placement rule governing where in the window the content is positioned (top, bottom, or middle - with explicit acknowledgment of positional degradation risk for middle placement). A system without a Context Boundary Contract has an implicit one: unbounded, unvalidated, and unaudited.

The Context Boundary Contract is not a new technology. It is a discipline: making explicit what is currently implicit in most system designs. Teams that write one during system design catch placement errors, trust collisions, and cost overruns before they reach a pilot deployment. Teams that skip it discover these issues in production, where they are substantially harder to fix.

The closest analogue is an API contract: an explicit agreement about what enters a system boundary, in what format, with what trust assumptions. LLM-backed systems have API contracts for their external interfaces and nothing comparable for their model interface. The Context Boundary Contract fills that gap.

Related Reading

The data governance consequences of uncontrolled context boundaries, including what enters the model from retrieval pipelines without appropriate consent tracking, are covered in What AI Does to Your Data Governance Program, which introduces the Lineage Opacity failure mode this contract directly addresses.

The Positional Degradation Zone

Position in the context window matters. Liu et al. [4] demonstrated this formally: models perform reliably on content placed at the very beginning or very end of a long context, and measurably worse on content placed in the middle. This is an attention distribution phenomenon, not a bug that will be patched: it is a structural property of how transformer attention operates over long sequences.

Coined Construct: Positional Degradation Zone

The Positional Degradation Zone (PDZ) is the region of a context window where model retrieval accuracy is structurally weaker due to attention distribution across long sequences [4]. For a filled context window, the PDZ is approximately the middle third of the token sequence. Content placed in the PDZ that is critical to the correctness of the model's response carries elevated error risk compared to content placed at the top (highest attention) or bottom (second-highest attention) of the window. Mitigations include: top-placement of high-criticality retrieved content, re-ranking retrieved chunks by criticality rather than only by similarity score, and reducing total context length to bring the PDZ boundary closer to the edges.

The PDZ has immediate practical implications for RAG system design. When a retrieval pipeline returns multiple chunks and concatenates them into the context window, the chunks in the middle of that concatenation are in the PDZ. If any of those middle chunks contain the answer the model needs, accuracy degrades. A retrieval pipeline that ranks by similarity score alone and places results in score order will systematically put some answers in the PDZ.

This is not a retrieval quality problem. The retrieval pipeline found the right content. The context window architecture placed it where the model pays less attention.

Fig. 2: Positional Attention Effect: Retrieval Accuracy by Context Position
Directional illustration based on the positional effects documented in Liu et al. (2023) [4]. Values are structurally derived from published findings; exact numbers vary by model and context length. The key result is qualitative: accuracy is substantially higher at context edges than at the middle. This is not an artifact of chunk quality, a property of attention distribution over long sequences.

Decision Framework: Context Architecture Decisions

Given the four boundary dimensions and the two formal constructs, the following decision framework guides the key context architecture choices a team needs to make when designing an LLM-backed system.

Decision Variables Right answer when Wrong answer risk
Retrieval vs. context stuffing Document corpus size, query distribution, cost SLA Corpus changes frequently, or full-context cost is prohibitive at scale: use retrieval. Static corpus under 32K tokens and cost is acceptable: stuffing may be simpler. Stuffing a large corpus inflates cost and pushes critical content into the PDZ. Retrieval that returns low-quality chunks fails silently.
Content placement order Criticality of each content source, total filled tokens Place the highest-criticality content at the top (system prompt zone) and the most recent, task-relevant retrieved content nearest the end. Never place must-use content in the middle third of a long context. Middle placement of critical retrieved content degrades accuracy due to the PDZ without any visible signal in model outputs. Errors look like model failures, not placement failures.
Trust level assignment Content source type, validation capability Developer-controlled content (system prompt) at highest trust. User input and retrieved external content at lower trust with validation applied before entry. Treating retrieved external content as trusted enables indirect prompt injection [3], where adversarial instructions in a retrieved document manipulate the model.
Context window length target Task complexity, cost SLA, latency SLA Use the minimum context length that achieves the required accuracy on your test set. Larger is not better: it widens the PDZ and increases cost linearly. Defaulting to maximum available context length optimizes for coverage at the cost of accuracy and budget. The PDZ scales with total context length.
Validation before entry Content source trust level, injection risk profile Apply length truncation, schema validation, and adversarial content scanning to all external content before it enters the context. Log what enters and from what source. Unvalidated external content creates an injection surface. At scale, even a low percentage of adversarially crafted inputs causes measurable harm at the aggregate level [3].

Build / Buy / Configure: Context Management Components

A Context Boundary Contract requires tooling to implement. The following breakdown covers what a team builds, buys, and configures for each component.

Three Enterprise Scenarios

Legal / Contract Review

General Counsel, Global Manufacturer

A contract review system retrieves relevant clauses from a 40,000-clause corpus. Without a Context Boundary Contract, the system places all retrieved clauses in the middle of the context window. Key obligations are in the PDZ. The model misses a material indemnification clause on 12% of reviewed contracts: not because retrieval failed, but because placement failed. The fix: re-rank by clause criticality (liability clauses score highest), place critical clauses at the bottom of the retrieval zone (nearest the user query), and set a per-source token budget that keeps total context under 16K tokens.

Customer Service / Support

VP of Customer Experience, Financial Services

A customer service agent retrieves policy documents from an external knowledge base. A small percentage of that knowledge base was poisoned by a third-party integration that appended adversarial instructions to several document chunks [3]. Without content validation before context entry, these instructions override the system prompt and cause the model to provide incorrect account information. The Context Boundary Contract assigns "unverified" trust to external knowledge base content and routes it through an adversarial content scanner before entry. The injection is caught at the boundary before it reaches the model.

Analyst / Research

Chief Data Officer, Asset Management Firm

A research synthesis agent processes 200-page fund prospectuses by stuffing the full document into a 200K-token context window. Input token costs compound at scale: 50 prospectuses per day at full-context stuffing is directionally 10-15x more expensive than a retrieval-based approach at equivalent accuracy. The Context Boundary Contract sets a 12K-token retrieval budget per query, enforcing retrieval over stuffing. Accuracy is validated against a human-labeled test set before the architecture is approved for pilot deployment. Cost per query drops substantially.

Context Window Architecture: Three Implementation Phases

Phase 1: Weeks 1-4

Audit and Contract

Document the existing context assembly logic. Write the Context Boundary Contract for each content source currently entering the window. Measure actual per-source token usage in production. Identify any content landing in the PDZ.

Phase 2: Weeks 5-10

Enforce and Instrument

Implement per-source token budgets. Add placement logic to keep critical content out of the PDZ. Add adversarial content scanning to all external sources. Build the context assembly audit log. Run accuracy benchmarks against a PDZ-aware placement strategy.

Phase 3: Weeks 11+

Optimize and Govern

Tune retrieval re-ranking by criticality. Validate cost reduction from retrieval-over-stuffing. Integrate context audit logs with AI governance reporting. Review the Context Boundary Contract quarterly as model versions and content sources change.

Cost of Getting This Wrong

Accuracy Cost

Critical content placed in the PDZ degrades model accuracy silently. The model returns an answer; the answer is wrong; no error is raised. The failure is invisible until audit or downstream consequence reveals it.

Security Cost

An unvalidated external retrieval source is an injection surface. A single compromised document chunk can override system prompt instructions and alter model behavior for every user querying that chunk [3].

Cost at Scale

Context stuffing architectures that work in development become expensive at scale. At millions of queries per month, the difference between an 8K-token and 100K-token context window is a cost difference that is directionally an order of magnitude.

Governance Cost

Without a context assembly audit log, you cannot demonstrate what the model saw when it produced a regulated output. This creates an evidence gap for AI audits under the EU AI Act [2] and emerging enterprise AI governance frameworks [1].

Fig. 3: Context Architecture Patterns: Relative Cost and Accuracy Tradeoffs
Directional illustration of relative cost and accuracy across four common context architecture patterns. Values are structurally derived from token pricing mechanics and documented retrieval accuracy effects; specific numbers vary by model, corpus, and query distribution. This chart is not empirically calibrated: use it to identify which quadrant your current architecture occupies, not to estimate exact cost or accuracy values.

The Executive Checklist: Context Architecture Review

1. Does each content source entering the context window have a documented token budget?
Good: per-source budgets are enforced in code and reviewed when content volume changes.
Red flag: total context length is checked but no per-source limit exists.
2. Has your team verified that high-criticality retrieved content is not landing in the Positional Degradation Zone?
Good: retrieval results are re-ranked by criticality, and critical content is placed at context edges.
Red flag: retrieved chunks are concatenated in similarity-score order with no placement logic.
3. Is external content validated before it enters the context window?
Good: external content passes through a length truncation and adversarial content check before assembly.
Red flag: retrieved content is passed directly to the context with no validation step.
4. Is there a runtime audit log recording what enters the context window for each request?
Good: source, token count, trust level, and placement position are logged for every inference request.
Red flag: context assembly logic has no logging; the only record is the final model output.
5. Has context window cost been benchmarked against a retrieval-based alternative at projected production volume?
Good: cost-per-query has been measured for both approaches against a labeled accuracy test set.
Red flag: the architecture that worked in development has not been costed at the projected production query rate.
6. Is your Context Boundary Contract versioned and tied to model version?
Good: when the underlying model changes (new version, new provider), the Context Boundary Contract is re-validated.
Red flag: the context architecture was designed for a specific model version and has not been reviewed since.

Excited about AI, innovation, and growth?

Start a conversation

References

  1. National Institute of Standards and Technology. "Artificial Intelligence Risk Management Framework (AI RMF 1.0)." NIST AI 100-1, January 2023.
  2. European Parliament. "Regulation (EU) 2024/1689 on Artificial Intelligence (EU AI Act)." Official Journal of the European Union, June 2024.
  3. Greshake, K., Abdelnabi, S., Mishra, S., Endres, C., Holz, T., Fritz, M. "Not What You've Signed Up For: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection." arXiv:2302.12173, 2023.
  4. Liu, N. F., Lin, K., Hewitt, J., Paranjape, A., Bevilacqua, M., Petroni, F., Liang, P. "Lost in the Middle: How Language Models Use Long Contexts." arXiv:2307.03172, 2023.
  5. Shi, F., Chen, X., Misra, K., Scales, N., Dohan, D., Chi, E., Schuster, T., Borgeaud, S. "Large Language Models Can Be Easily Distracted by Irrelevant Context." arXiv:2310.01848, 2023.
  6. Liang, P., Bommasani, R., Lee, T., et al. "Holistic Evaluation of Language Models (HELM)." arXiv:2211.09110, 2022.