liveBook · Manning

Context window

As explained in AI Agents in Action, Second Edition

The finite amount of input and conversational context that an agent can retain or process in one interaction.

A context window is the maximum number of tokens a model can attend to at once. For an agent, it limits what can fit into the current prompt: recent conversation, instructions, retrieved information, and tool results. Text length is not the same as token length, so measure tokens when planning the budget. section 1.3.4 section 2.6

Think of the window as working space, not a permanent archive. Recent turns can live directly in it; information needed across sessions belongs in external storage and is retrieved when relevant. Calling these short-term and long-term memory is useful shorthand, but the practical distinction is whether information is inside the current prompt or outside it. section 1.3.4 section 6.4.1

When the working space gets crowded, decide what earns a place:

  • Summarize or remove older conversation turns rather than keeping the entire history. section 1.3.4
  • Filter or chunk tool output; rank and trim retrieved results before inserting them. section 1.3.4
  • Measure the token budget instead of estimating it from visible text length. section 2.6

Divide a task by context

If one agent cannot hold everything needed for a large task, several agents can each work with the relevant slice. This makes context management one reason to distribute work, alongside specialization and parallelism. section 1.4

A larger window reduces pressure but does not remove the need to select carefully: longer contexts cost more, slow inference, and can eventually hurt reasoning quality. Ask what the agent needs for this call, what can be retrieved later, and what can be left out. section 1.3.4

How AI Agents in Action, Second Edition covers it

How deep it goes
Defines the token limit and explains selection trade-offs, while deferring detailed memory architectures and context strategies.
Examples
Uses older conversation turns, tool outputs, retrieved results, and task distribution among agents to illustrate context choices.
What it assumes
Introduces the window as a token limit and distinguishes it from external storage without relying on human-memory categories.
What you can do after
Operate/configure it by measuring tokens and selecting which history, tool output, and retrieval results enter each call.
How it connects
Connects conversational memory, external storage, retrieval, and multi-agent systems through the distinction between current context and information held elsewhere.

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 in Action, Second Edition. The section links point to the parts of the book it draws on.