Context Window Reference: Where the Tokens Actually Go
A context window is the maximum number of tokens a model can attend to in one request. It is shared by the system instructions, the conversation history, any tool or retrieval output, and the reply you want back. Remaining budget equals the context limit minus the prompt tokens minus the reply reserve. Requests that exceed the limit are truncated or rejected, so a budget is a correctness control, not just a cost control.
The formula
Remaining tokens equal the context limit, minus everything already in the prompt, minus the reserve you leave for the reply. Utilisation is prompt tokens divided by the context limit.
The reserve is the part most often forgotten. If you fill the window with retrieved documents and leave nothing for the answer, the model truncates mid-sentence or the request fails. Reserve at least the expected answer length plus headroom for reasoning.
What competes for the window
Four things share the budget: the system prompt, the conversation so far, any tool results or retrieved passages, and the reply. The system prompt is fixed and usually small; conversation grows monotonically; retrieval is the most variable and the most common cause of overflow.
Because conversation history only grows, a long session eventually fails no matter how large the window. The fix is summarisation or eviction of old turns, decided before the limit is reached rather than after a failed request.
Sizing a request before sending it
Estimate tokens from characters rather than words when the input is code or structured data, because whitespace and punctuation tokenise densely. English prose runs near four characters per token; JSON and identifiers run closer to two to three.
Measure once per document type and keep the ratio. Sampling a real payload is worth more than any general rule: tokenise one representative document, divide characters by tokens, and use that factor for everything of the same shape.
Token estimation factors by input shape (measure your own to confirm)
| Input shape | Approx chars per token | Approx tokens per 1,000 chars |
|---|---|---|
| English prose | 4.0 | 250 |
| Technical prose with numbers | 3.5 | 286 |
| JSON / structured data | 2.5 | 400 |
| Source code | 3.0 | 333 |
| Non-Latin script | 1.5 | 667 |
Worked budget at a 128,000 token window
| Component | Tokens | Running remaining |
|---|---|---|
| Context limit | 128,000 | 128,000 |
| System prompt | 1,200 | 126,800 |
| Conversation history | 18,000 | 108,800 |
| Retrieved documents | 60,000 | 48,800 |
| Tool results | 8,000 | 40,800 |
| Reply reserve | 8,000 | 32,800 spare |
When the window becomes the constraint
| Symptom | Likely cause | Control |
|---|---|---|
| Answers cut mid-sentence | No reply reserve | Reserve output length before filling |
| Late-session failures | History grows unbounded | Summarise or evict old turns |
| Retrieval overflow | Too many passages injected | Rank and cap passages, not top-k blindly |
| Cost rising faster than usage | Prompt re-sent every turn | Prompt caching, or trim history |
Frequently asked questions
Does a larger context window cost more?
Per request, yes: most providers bill input tokens, so a fuller window costs more. A larger window does not by itself raise the per-token rate; what raises the bill is sending more tokens per call.
Can I just truncate old messages?
Truncation works but loses information abruptly. Summarising evicted turns preserves the decisions and drops the verbatim text, which is usually the better trade for long sessions.
More in tools
Sources and read dates
- Riven models - lane list and per-lane multipliers (read 2026-11-26)
- Riven docs - Riven Pricing Brain, base rate and tier multipliers (read 2026-11-26)
- Riven pricing - plans, credits and pay-as-you-go base rate (read 2026-11-26)