liveBook · Manning

Context assembly

As explained in Context Engineering

Context selection is the choice of which information enters an AI system's active context.

Context assembly, also called context selection or curation, decides what information enters an LLM’s context window for a specific invocation and where it is placed. The goal is useful, task-relevant context, not the largest possible prompt. Irrelevant tokens add cost and latency and can distract the model from critical instructions, evidence, or state. section 7.2 section 7.1 section 7.10

The surrounding application owns the sources: instructions, external knowledge, tools, memory, state, and the user prompt. A context manager, typically implemented in an agent harness or application code, assembles them for each call. The model receives a single token sequence; the source categories are distinctions maintained by the system, not the model. section 1.5 section 7.0

Figure 1.6 The context manager assembles the six context sources into the context window consumed by the AI agent at each turn, while the context orchestrator coordinates the execution with other agents and external systems
context types v23

The diagram shows the context manager assembling sources for each turn alongside an orchestrator that coordinates execution. section 1.5

Selection is one part of context management. Writing preserves useful information outside the prompt; compression reduces history; isolation separates work into bounded contexts. Orchestration decides which step runs next and routes context across steps, agents, tools, and interfaces. The context manager and orchestrator coordinate through shared state. section 7.10 section 1.5

For each invocation, assembly decisions include:

  • Choose relevant instructions, user constraints, evidence, and state. Decide whether to retrieve, read a full context, summarize, use a tool, consult memory, or abstain. section 7.10 section 12.2.1
  • Prioritize candidates under the token budget. Keep the active task and recent state prominent; include the latest tool result in full when the next decision depends on it, while summarizing or referencing older observations. section 7.2.2
  • Choose a representation as well as content: for example, a passage, list, file, or graph memory may suit different tasks. section 12.2.1
  • Apply authorization and data minimization to determine which records, memories, and tool outputs are eligible. Use controls such as redaction and audit traces to enforce governance requirements. section 9.5

Customer support

For a refund question, a support assistant can select the last three ticket exchanges rather than the entire thread, along with the refund policy clause for the customer’s region. If it has just called a tool, the latest result may need to remain in full for the next decision; older observations can be summarized or retained as references. section 7.2.2

Ignored instructions, contradictory statements, hallucinated tool arguments, or failure to use supplied evidence can signal distraction. A larger context is not automatically better: retrieval noise and accumulated irrelevant information can degrade reasoning. The right routing choice depends on the task, model, document length, retrieval quality, and evidence structure. section 7.2 section 12.2.1

How Context Engineering covers it

How deep it goes
Explains source assembly, routing choices, token-budget prioritization, and governance constraints.
Examples
Uses a customer support assistant selecting ticket exchanges, a regional refund policy clause, and tool results.
What you can do after
Evaluate context choices against relevance, token budget, retrieval noise, and eligibility constraints.
How it connects
Connects selection to context writing, compression, isolation, orchestration, and retrieval.

Also explained in

Compare how 2 books explain context assembly →

Related concepts

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