Chapter 2 · Practice 2 of 4
Put long documents first and the question last, then confirm with tests
Why it matters
Where long context sits in a prompt changes results.
Anthropic recommends placing long documents near the top, above the query, instructions and examples. Its guide reports that putting the query at the end can improve response quality by up to 30 percent in its tests, especially with complex, multi-document inputs.
Google's Gemini 3 guidance agrees: long context first, instructions at the end, with critical constraints and output format stated near the beginning.
OpenAI's guide suggests a developer message order of identity, instructions, examples and then context, with context near the end.
The common ground: keep the specific question close to where the model will start answering, and keep long material in one clearly marked block. When the guides differ, run both orders on your eval set and keep the winner.
Example
<documents>
<document index="1">
<source>q3-report.pdf</source>
<document_content>{{report}}</document_content>
</document>
</documents>
Using only the documents above, answer: {{question}}