Context EngineeringContext assembly and efficiencyStaff
How would you select a sufficient evidence set when only six of eighty retrieved passages fit in context?
By Amit Kumar4 min readWorked answer includedReviewed 26 Sept 2026
The question
Interview question
A documentation assistant retrieves eighty passages but can fit roughly six into its next model call. Design the context-selection step. Explain what it should optimize beyond similarity, how it should handle a highly ranked passage that lacks the answer, and how you would evaluate the result. Some questions require a rule, an exception and a product-version condition from different passages.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
The selected passages must work together to support the answer. Six individually relevant passages can still be a poor set if they all repeat the same general explanation and omit the one exception that changes the user's decision. Selection therefore needs to consider what each passage adds to the evidence already chosen, rather than simply taking the first six search results.
The context is the input the model receives for this call. Retrieval finds plausible candidates. A reranker may score those candidates more carefully. Context selection decides which material actually reaches the model within the input budget. Each stage can lose useful evidence. A high similarity score says that a passage resembles the query in the retrieval model's representation. It does not establish that the passage answers the question, is current, or is permitted for this user.
Consider a hypothetical question: “Can version 8.4 roll back a data migration in the EU region?” The highest-ranked release note introduces migrations but says nothing about rollback. A lower-ranked runbook explains the rollback procedure. Another passage says the procedure is unavailable for EU deployments on that version. Selecting the release note and five similar announcements gives the model plenty of topical language and none of the decisive restriction.
Break the question into material conditions: product version, operation and region. Use these to identify evidence requirements rather than to guess the answer. A useful selected set might contain the runbook, the regional restriction and a source establishing the applicable version. The release note belongs only if it contributes a needed premise. A current passage can be unnecessary, while an older source may remain authoritative for an older product version. Authority and applicability need to be represented explicitly.
Before private text reaches downstream scoring or generation, enforce the current user's permission to receive it. Carry document identity, revision, effective date, source location and access scope into selection. If a retrieved sentence relies on a table heading or adjacent exception, expand it within the same source revision. Expansion must also respect access boundaries. A permitted child passage is not permission to expose a restricted parent section.
For each proposed addition, ask what gap it closes. Does it establish a missing condition, provide the exception, resolve a source conflict, or merely repeat a chosen passage? This is marginal value: the contribution relative to the current set. A diversity rule can reduce near duplicates, but diversity is not an end in itself. Two adjacent passages from one manual may be necessary, while six independent summaries may all omit the answer. Use source caps as heuristics that can be overridden by a demonstrated evidence need.
The real constraint is tokens, not six fixed slots. A table with headers may be longer than a paragraph, yet removing its headers can reverse the meaning. Reserve space for instructions, the user's question, source labels and the requested output. Estimate passage token costs using the deployed tokenizer. When useful evidence exceeds the budget, prefer coherent support for a bounded answer over many fragments whose qualifiers were cut away. If the task cannot be answered safely in that budget, use another retrieval or processing step rather than pretending all requirements fit.
The top hit lacks the answer. Search again using the missing condition, such as the exact version and region, or follow an authoritative link from the runbook. Bound this investigation by latency and tool budgets. Additional retrieval is justified when it seeks identified missing evidence, rather than continuing because the model says it wants more confidence. If the missing restriction cannot be established, qualify the answer or explain what remains unknown. Do not fill the gap from an attractive but inapplicable source.
Evaluation should locate failures precisely. On reviewed cases, record where each required supporting span appeared among the eighty candidates and whether the selector retained it. Compare the selected set with an oracle set of reviewed evidence under the same token budget. If the evidence never appeared in retrieval, the selector cannot recover it. If it was present but discarded, increasing search volume may only make the selection problem harder.
Measure coverage of material claims and qualifiers, citation support, unsupported assertions, false abstentions, latency and token cost. Include multi-source questions, conflicting revisions and heavy duplication. A model's confidence statement cannot certify evidence sufficiency. High-impact unresolved conflicts need an explicit review or abstention path. The result should be a small, attributable evidence set that lets the model answer the actual question, even when that means using fewer than six passages.
Related questions
Keep practising context engineering
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux