Glossary · 4 min read

Context window

What a language model's context window is, why long patient records strain it, what studies show about models missing information buried in long inputs, and what to ask about how a tool handles a full chart. As of September 2026.

The short version

  • A context window is the maximum number of tokens, pieces of words, that a language model can read and write in one exchange. Instructions, record excerpts, retrieved documents, and the answer all share it.
  • Clinical text fills windows fast: in one benchmark built from real hospital cases, the relevant information averaged 2,080 tokens per case and reached 15,023.
  • Bigger windows help, within limits. Models tend to use information at the start or end of a long input better than information in the middle.
  • In a 2024 study of open models, diagnostic accuracy was often best when models got a single exam result rather than all of them, and reordering the same information shifted accuracy by up to 18%.
On this page

A context window is the maximum amount of text, counted in tokens, that a language model can read and write in one exchange. Tokens are pieces of words; in one clinical study, a 4,096-token limit worked out to roughly 2,400 words 1. The instructions, the record excerpt, any retrieved documents, and the model's answer all share the same window.

Why does the context window matter in healthcare?

The limit is shared between input and output. As one research team put it, "if a model has a context length of 2,048 and receives an input of 2,000 tokens, it can only generate 48 new tokens" 1.

Patient records fill windows fast. In a clinical decision-making benchmark built from 2,400 real hospital cases, the relevant information averaged 2,080 tokens per case and reached 15,023 tokens at the maximum 1.

When input exceeds the window, something has to give. The text is cut, summarized, or retrieved selectively. That study's framework asked the model to summarize what it had gathered whenever the conversation neared the limit 1. Each approach decides what the model never sees, so the design of retrieval-augmented generation deserves as much scrutiny as the choice of model.

Is a bigger window always better?

Bigger helps, within limits. In clinical summarization, performance generally improved with more in-context examples, and the number of examples a model could take depended on tokens per example and the window size. The best configuration used GPT-4 with a 32,000-token window 2.

Position matters, though. Studying long inputs, Liu and colleagues found that models used relevant information best when it sat at the beginning or end, and worst when it sat in the middle 3.

Quantity and order matter clinically too. In Hager and colleagues' study of open models on abdominal pathologies, the models often diagnosed best when given a single diagnostic exam alongside the history, rather than every exam. Reordering the same information changed accuracy by as much as 18%, and showing only abnormal laboratory results generally improved performance 1. Those models had 4,096-token windows. Newer models are larger, and the lesson to test for still holds.

Common misunderstandings

If it fits, the model reads all of it. Information in the middle of a long input is the most likely to be missed 3.

More context is always safer. In the clinical study, the models tested diagnosed worse when given every relevant exam 1. Curated context can beat complete context.

Only the user's text counts. Everything in the window can steer the output, including text inside retrieved documents or pasted notes. That is how prompt injection works.

What to ask a vendor

  • What is the model's context window, and how much of it do your own instructions and retrieved material use?
  • What happens when a chart exceeds it: truncation, summarization, or retrieval? Which parts get dropped first?
  • Have you tested accuracy on long records, with key facts placed in the middle?
  • Does the tool tell the clinician when input was cut?
  • For an ambient scribe, how are long visits handled?

Questions and answers

  • What is a context window in an AI model?

    It is the maximum amount of text, counted in tokens, that a language model can handle in one exchange, covering both what it reads and what it writes. If a model has a 2,048-token window and receives 2,000 tokens of input, it has room to generate only 48 tokens of answer.

  • If a patient record fits in the window, will the model use all of it?

    Not reliably. Research on long inputs found models use information at the beginning or end better than information in the middle, and a clinical study found accuracy changed with both the amount and the order of the information provided.

Sources

  1. Hager P, Jungmann F, Holland R, et al. Evaluation and mitigation of the limitations of large language models in clinical decision-making. Nature Medicine. 2024;30(9):2613-2622. doi.org/10.1038/s41591-024-03097-1
  2. Van Veen D, Van Uden C, Blankemeier L, et al. Adapted large language models can outperform medical experts in clinical text summarization. Nature Medicine. 2024;30(4):1134-1142. doi.org/10.1038/s41591-024-02855-5
  3. Liu NF, Lin K, Hewitt J, Paranjape A, Bevilacqua M, Petroni F, Liang P. Lost in the Middle: How Language Models Use Long Contexts. Transactions of the Association for Computational Linguistics. 2024;12:157-173. doi.org/10.1162/tacl_a_00638

Every claim on this page is tied to a numbered primary source above. Read how we source and review at our editorial policy.