Context construction is assembling the retrieved chunks into the prompt you actually send.
It is often treated as string concatenation and deserves more care than that.
Order matters, since models attend most reliably to the start and the end.
The strongest chunk should not be buried in the middle of twenty others.
Label every chunk with its source and an identifier the model can cite.
Delimit them clearly so instruction and evidence never blur together.
State plainly that the chunks are reference material and not instructions.
Retrieved text is untrusted, since anything inside it may attempt an injection.
Budget the tokens across system prompt, chunks, question, history and the answer itself.
Running out of room usually truncates the answer rather than the context, which is the wrong end.
More chunks is not better, and adding weak ones measurably lowers accuracy.
Five good chunks beat twenty mixed ones on nearly every real benchmark.
Deduplicate, because near-identical chunks waste budget and inflate false confidence.
Include dates when recency matters, so the model can prefer the newer statement.
Log the assembled prompt in development, since most failures are obvious when you read it.