CLOUD CONCEPT

Context Windows

Context windows define how much information a foundation model can consider within a single inference request, typically measured in tokens.

Cloud Concepts Hub →

What is Context Windows

A context window bounds the information available to a model when it generates a response, including instructions, conversation history, retrieved documents, and tool results. Context engineering selects and organizes that information so the model receives relevant evidence without exceeding its limits or introducing unnecessary cost, latency, and distraction.

A context window is the finite capacity within which a foundation model processes information during inference. For language models, this capacity is usually expressed in tokens rather than words or characters. Tokens can represent words, word fragments, punctuation, or other encoded content. Multimodal models also consume capacity for inputs such as images and audio, using model-specific accounting rules. Context limits differ across models and versions, so applications must use the limits and token-counting behavior of their selected model.

The context supplied to a model can include system instructions, the current question, earlier conversation turns, examples, retrieved passages, tool definitions, and tool results. Many models have a combined input-and-output context limit, along with a separate maximum output length. Applications must reserve sufficient capacity for the generated response and check the provider's specific rules. For example, with a hypothetical 32,000-token combined limit, allocating 28,000 tokens to input leaves at most 4,000 tokens for generation, subject to any lower output limit.

Context engineering is the broader practice of deciding what information enters this limited space, how it is structured, and when it is refreshed. Prompt engineering focuses primarily on instructions and examples; context engineering also addresses retrieval, conversation state, tool outputs, and application data. In a cloud application, an orchestration layer can assemble these inputs before calling a hosted foundation model. It should count or estimate tokens, enforce budgets, and handle oversized requests explicitly rather than assuming the endpoint will truncate them safely.

Consider an internal support assistant answering a question about a database backup policy. Instead of placing an entire operations library into the prompt, the application retrieves a small set of relevant passages, includes their document identifiers, and asks the model to answer using that evidence. This retrieval-augmented generation approach supplies current, task-specific information without changing model weights. Retrieval does not expand the context window: the selected passages still occupy space within it.

Conversation history creates a similar challenge. A long-running troubleshooting session may exceed the model's capacity even when each individual message is short. The application can retain recent exchanges, preserve essential facts in a structured summary, and retrieve older details when needed. Summarization saves space but can omit constraints or introduce errors, so important facts such as resource identifiers and approved actions should be preserved and validated. Stored conversation history is not automatically available to the model; the application or service must supply the relevant portions.

Larger windows can accommodate more evidence, but they do not guarantee better reasoning or factual accuracy. Irrelevant passages, contradictory instructions, and poorly positioned evidence can reduce answer quality. More input commonly increases token charges and processing time, although pricing, caching, and latency behavior vary by model and service. Engineers should evaluate retrieval relevance, answer correctness, token consumption, and response latency together rather than choosing a model solely for its advertised window size.

Context boundaries are also security boundaries. Retrieved documents and tool responses can contain malicious instructions, so applications should treat them as untrusted data, distinguish evidence from authoritative instructions, and enforce authorization before retrieval. Sensitive information should be minimized before it reaches the model. For certification scenarios, distinguish context engineering from fine-tuning: context engineering changes the information available for a particular request, whereas fine-tuning changes model parameters through additional training. Neither a large context window nor retrieval alone eliminates hallucinations.

Key aspects of Context Windows

Effective context-window use combines token budgeting, relevant evidence selection, conversation management, and security controls to support reliable inference.

Model-specific token capacity

Context limits depend on the selected model and version, not simply the hosting service. Use compatible token counting and account for message formatting, tool definitions, and multimodal inputs where applicable.

Input and output budgeting

Allocate capacity across instructions, history, evidence, tool results, and the expected response. Check both the model's context limit and its separate output limit before sending a request.

Relevant context selection

Include the information necessary to answer the current question rather than filling the window indiscriminately. Retrieval, filtering, deduplication, and reranking can improve the usefulness of the supplied evidence.

Conversation state management

Persisted history and model-visible context are different things. Use recent messages, validated summaries, and selective retrieval to preserve continuity without repeatedly sending an entire conversation.

Quality, cost, and latency trade-offs

A larger window provides capacity but does not ensure that the model will use every detail reliably. Test answer quality and operational performance with representative context sizes and document arrangements.

Trust and authorization boundaries

Apply access controls before adding retrieved content to a request, and treat external text as evidence rather than trusted instructions. Minimize sensitive data and validate consequential outputs or actions outside the model.

Cloud services for Context Windows

Amazon Bedrock or Amazon SageMaker AI supplies the model inference layer, while Amazon OpenSearch Service can provide relevant passages from an indexed document collection. An application orchestration layer combines those passages with instructions, selected conversation history, and tool results, then checks the request against the chosen model's token budget. Knowledge Bases for Amazon Bedrock can manage retrieval and context assembly for supported workflows. Across these architectures, retrieval quality and authorization determine which evidence enters the request, while the model and serving configuration determine how much information can be processed.

Amazon Bedrock

Amazon Bedrock provides access to foundation models with model-specific context and output limits. Applications can assemble request context directly or use Knowledge Bases for Amazon Bedrock to retrieve supporting material for generation; retrieved material still consumes the selected model's available context.

Open Amazon Bedrock →
Amazon OpenSearch Service image Amazon OpenSearch Service

Amazon OpenSearch Service supports vector and lexical retrieval for selecting relevant document passages before model invocation. It helps applications use limited context efficiently but does not itself enlarge a foundation model's context window.

Open Amazon OpenSearch Service →