liveBook · Manning

Context window

As explained in AI Agents and Applications

A context window is the maximum amount of input and conversational context a language model can process in one interaction.

A long document or an extended chat can outgrow what an LLM can receive at once. The context window is the model’s maximum prompt size: the text supplied in one prompt, including instructions and context. Models have different limits, measured in tokens, which are often parts of words. section 3.1

When the available text will not fit, choose what the model needs:

  • For document summarization, split the text into token-sized chunks, summarize each chunk, then summarize those results. TokenTextSplitter can help control chunk size. section 3.1
  • For a continuing chat, compress or summarize earlier turns to preserve useful memory while staying within the limit and managing cost. section 1.1.2
  • For knowledge-base Q&A, retrieve the content relevant to the question instead of putting every company document in the prompt. Focused context can improve speed, cost-efficiency, and accuracy. section 6.1.2
Figure 3.1 Summarizing a document bigger than the LLM’s context window involves splitting the document into smaller chunks, summarizing each chunk, and then summarizing the combined chunk summaries.
figure

The diagram shows the staged path for a document that exceeds the context window: split it, summarize the chunks, then summarize their combined results. section 3.1

A larger window admits longer prompts and documents, but can increase cost and processing overhead. Choose a model and a context-management approach that fit the application rather than assuming the largest window is always best. section 1.5

How AI Agents and Applications covers it

How deep it goes
Defines the limit in tokens and outlines chunked summarization, without detailing model internals.
Examples
Uses an oversized document and company information spread across intranet pages and files as concrete cases.
What it assumes
Defines context windows and tokens before describing chunking; states no explicit prerequisite.
What you can do after
Apply it via TokenTextSplitter to size document chunks for staged summarization.
How it connects
Connects tokenization and MapReduce summarization with retrieval-augmented generation as ways to handle limited context.

Also explained in

Compare how 22 books explain context window →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents and Applications. The section links point to the parts of the book it draws on.