---
title: "Context Window"
slug: context-window
date: 2026-11-04T16:56:26+00:00
modified: 2026-11-04T16:56:26+00:00
permalink: https://brightdata.com/glossary/context-window
type: page
---

# Context Window

**TLDR:** A context window is the maximum amount of text, measured in tokens, that a language model can consider in a single request. It covers the input and the generated output together.

The **context window** is a hard architectural limit. Everything the model can reason about in one call must fit inside it: system instructions, conversation history, retrieved documents, the current question, and the response being generated. When the limit is reached, something has to be removed, and what gets removed determines what the model can no longer see.

### What Consumes the Window:

1. **System prompt**: Instructions, role definitions, formatting rules, and tool descriptions, all present on every request.
2. **Conversation history**: Prior turns, which accumulate continuously in a multi turn session.
3. **Retrieved context**: Documents injected by a retrieval system, usually the largest and most variable component.
4. **Current input**: The user’s immediate request.
5. **Output**: Reserved space for the response, which cannot exceed what remains.

The last point is often overlooked. A request that fills 98 percent of the window leaves almost no room for an answer, and the model will truncate mid sentence rather than refuse.

### Tokens, Not Words:

Windows are measured in tokens, which are subword units rather than words or characters. Common English words are typically one token. Rare words, technical terms, and names split into several. Whitespace, punctuation, and formatting all consume tokens.

For English prose, a rough working figure is around 0.75 words per token, though this varies by tokenizer and by text type. Code, JSON, and heavily formatted markup tokenize far less efficiently than plain prose, which is a direct reason to strip markup before sending content to a model.

For accurate counts, use the tokenizer that matches the target model rather than estimating. Estimation errors compound badly in pipelines that batch many documents.

### What Happens at the Limit:

HandlingBehaviorRiskHard errorRequest is rejectedVisible failure, easy to handleTruncate oldestEarliest history is droppedModel forgets earlier instructionsTruncate newestRecent input is cutThe actual question may be lostSummarize historyOlder turns compressedDetail loss, added latency and costDrop retrieved contextFewer documents includedAnswer loses groundingSilent truncation is the dangerous case. The model still answers, the answer still reads fluently, and nothing in the response indicates that half the supporting material was removed before it was generated.

### Budgeting the Window:

```
def build_prompt(system, history, documents, question, limit):
    reserved_output = 1000
    budget = limit - reserved_output

    used = count_tokens(system) + count_tokens(question)
    budget = budget - used

    # Documents get priority over old conversation turns
    included_docs = []
    for doc in documents:
        cost = count_tokens(doc)
        if cost > budget:
            break
        included_docs.append(doc)
        budget = budget - cost

    # Fill remaining space with history, most recent first
    included_history = []
    for turn in reversed(history):
        cost = count_tokens(turn)
        if cost > budget:
            break
        included_history.insert(0, turn)
        budget = budget - cost

    return assemble(system, included_history,
                    included_docs, question)
```

Output space is reserved first, then components are added in priority order. Which component holds priority is a design decision: retrieval heavy applications favor documents, conversational applications favor history.

### Larger Windows Are Not a Solution:

Model context windows have grown substantially, and the growth makes some problems disappear. It does not make context management unnecessary, for three reasons.

**Cost scales with usage.** Filling a large window on every request multiplies the price of every call, whether or not the extra content was useful.

**Latency scales with input.** More input means slower responses, which matters in interactive applications.

**Attention is uneven.** Published research has repeatedly found that models attend more reliably to information at the beginning and end of long inputs than to material buried in the middle. Placing critical content in a large window does not guarantee it will be used.

The practical consequence is that selecting the right context remains more valuable than supplying more of it, which is the subject of [context engineering](/glossary/context-engineering).

### Context Windows and Web Data:

Web content is the component most likely to overflow a window, and the one most responsive to preparation.

A raw HTML page can consume a large fraction of a window in markup alone. Converting through [HTML to Markdown](/glossary/html-to-markdown) and applying [boilerplate removal](/glossary/boilerplate-removal) typically reduces that by an order of magnitude, and [document chunking](/glossary/document-chunking) then allows only the relevant portion to be retrieved rather than the whole page.

Bright Data’s [Crawl API](/products/crawl-api) and [Search and Extract](/ai/web-access) return pre cleaned Markdown, which removes most of the avoidable token overhead before content reaches the model.

Start free trial[Start with Google](#)





 ## Trusted by 50,000+ customers worldwide



























































Welcome to the Scraping Cloud

## Maximum Control and Efficiency

 [Proxies

Premium proxy infrastructure. 100% ethically sourced IPs.

- Automated session management
- Target any city in 195 countries
- Unlimited concurrent sessions





 Proxy Services





 ](/proxy-types)

 [Unlocker

Say goodbye to blocks and CAPTCHAs with a single API.



 Unlocker





 ](/products/web-unlocker)

 [Browser

Scale dynamic scraping with built-in unblocking and proxies



 Scraping Browser





 ](/products/scraping-browser)

 [Functions

Run your scrapers as fully-hosted serverless functions.



 Functions





 ](/products/web-scraper/functions)

 [Scrapers

Extract parsed data on-demand with dedicated scraper APIs.



 Scrapers API





 ](/products/web-scraper)

 [Datasets

Get fresh, validated datasets from any public website.



 Datasets





 ](/products/datasets)

 [SERP API

Quick and easy search engine scraping on demand



 SERP API





 ](/products/serp-api)







### Ready to get started?

Start free trial
