Spot the context engineering bug in this evidence block assembly
Click any words you think contain an error. Click again to unmark.
Two compounding bugs, alphabetical ordering throws away the relevance signal, and skipping per-chunk ids forces the model to confabulate citations from chunk text.
Picture handing a kid five flashcards to study for a quiz. Two mistakes here. First, you sorted the cards alphabetically by which book they came from, instead of putting the most useful card first or last where the kid will actually remember it. Second, you ripped the corner stickers off the cards, so when the kid says which card they used they have to describe what was written on it, and they will get the description wrong. Fix one: put the strongest card at the start, the second strongest at the end. Fix two: leave the stickers on so the kid can just say S1 or S2.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
The described assembly compounds two independent errors. Each one would be a quality regression on its own; together they produce a context block that is both poorly ordered for the lost-in-the-middle curve and broken for citation linkage.
This card pulls the two errors apart, explains why each one fails, and walks through what a correct evidence-block assembly looks like in a 2026 production stack.
Error one, sorting by document title
Alphabetical sort by document title has no relationship to query relevance. Whatever ranking the upstream retriever and reranker produced gets discarded when the assembler imposes title order.
The consequence interacts directly with the lost-in-the-middle effect documented by Liu et al. 2023. Models attend most strongly to content at the start and end of a long context block and least to content in the middle. The empirical drop on retrieval and reasoning tasks when a critical chunk lands in the middle is consistently in the 10-30 percent range across modern frontier models and across the RULER and BABILong long-context benchmarks.
Why title sort is the worst case
If the strongest chunk's document happens to start with 'A', it ends up at the head, fine, by accident. If the strongest chunk's document starts with 'M', it ends up in the dead middle. The placement is uncorrelated with relevance, which is the textbook worst case for any positional bias.
The fix
Order by relevance score. The reranker (Cohere Rerank 3.5, BGE Reranker v2, Voyage Rerank-2) returns a score per candidate; sort descending and assemble in that order. If you want to exploit position bias more aggressively, head-load the top chunk and tail-load the second-best, a head and tail pattern that puts the two strongest chunks into the two highest-attention positions.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Anthropic's 2026 RAG cookbook for Claude Opus 4.7 assembles evidence blocks with [S1]-style tags and orders by Cohere Rerank 3.5 score.
- OpenAI's Responses API for GPT-5 ships first-class document-id citations, the SDK builds the assembly with stable ids by default.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you decide between head-loading the top chunk versus head and tail loading?
Head-only is enough when the top chunk dominates relevance; head and tail helps when the top two are close in score and the model otherwise misses the second one.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Sorting evidence blocks by document title rather than by relevance score. Useful chunks land in lost-in-the-middle positions and the model misses them.
60 second bullets to scan on the way to the call.
State the two errors and one fix for each
Explain why alphabetical sorting interacts badly with lost-in-the-middle
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.