What is context assembly?
Context assembly is the step between retrieval and generation where the final input to the model is put together. It decides which retrieved passages are included, in what order, with which labels and alongside which instructions. The model answers only from what it is given, so this step determines what the answer can draw upon and how easily it can cite the source.
Also called: Context packing, Prompt assembly
Why good retrieval still produces poor answers
Retrieval can surface every relevant passage and the answer can still be wrong if those passages are assembled carelessly. Duplicates waste the budget, passages lose the titles that explain them, and the most important evidence ends up in the middle of a long input where models attend least. Context assembly addresses all of this deliberately. It is also where source identifiers are attached, which is what makes accurate citation possible at all.
- The model can only cite sources that were labelled when they were supplied.
- Ordering affects which passages the model relies upon most heavily.
- Removing duplicates frees space for distinct evidence.
- A fixed budget keeps cost and latency predictable per question.
How context assembly works
- Reranked passages are taken in order until the token budget is reached.
- Near-duplicate passages are removed so each slot carries distinct evidence.
- Each passage is labelled with its document title and version identifier.
- Related passages from the same document are grouped together.
- Instructions and the question are placed where the model attends to them reliably.
- The assembled input is stored with the answer for audit and replay.
How context assembly is evaluated
Context assembly is evaluated by holding retrieval constant and varying only how its output is assembled. Compare the following across those variants:
- answer accuracy across different ordering strategies
- share of the budget consumed by duplicate material
- citation accuracy when sources are labelled and when they are not
- answers that relied on a passage placed in the middle of the context
- token count per question against the configured budget
Limitations, risks and common failure modes
- The budget is filled with marginal passages because space was available.
- Passages are truncated mid-sentence to fit, removing the qualifying clause.
- Source labels are dropped and the model cites documents it never saw.
- The assembled input is not retained, so a disputed answer cannot be replayed.