Guide AI architecture

Context windows and why long prompts fail

What a context window is, how tokens are counted, and why stuffing more text into a prompt often makes answers worse.

Overview

A context window is the maximum number of tokens an LLM can consider at once: your system prompt, the conversation so far, retrieved documents, and the model’s reply. Exceed it and the oldest tokens are dropped or the request is rejected.

Tokens are not words

English often averages a bit under one token per word, but code, URLs and other languages can be much less efficient. Both input and output usually count. A 20-page PDF pasted into a chat can consume the window before the user asks a question.

Why “just paste everything” fails

  • Cost and latency scale with tokens. See AI cost optimization.
  • Lost in the middle. Models often attend more to the start and end of a long prompt than to the middle.
  • Noise. Irrelevant paragraphs dilute the instruction.

Design that respects the window

  • Retrieve 3–8 focused chunks instead of a whole handbook (RAG).
  • Summarise history; do not replay every turn forever.
  • Put hard constraints (format, safety, “do not invent IDs”) at the end as well as the start if the prompt is long.
  • Measure actual token use in staging. Marketing “128k context” does not mean you should fill it.

Last verified: August 2026. Technology and pricing change — always confirm current details with the vendor.

#LLM#tokens#context window#cost

About Elysian Editorial Team

Editorial & engineering team

The Elysian Tech Leverage editorial team writes and reviews technical content on AI, automation, software, cloud and business systems. Every guide is fact-checked against primary sources and every tool and calculator is tested before publication.

AI & automationCloud architectureAPIs & integrationsDataCybersecurity fundamentals