Long context, and the ordering rule with a number on it
If you memorise one number from this entire course, make it this one.
For prompts of roughly 20k tokens and up, put the longform data at the TOP, above the query, above the instructions, above the examples. The docs claim that queries at the end can improve response quality by up to 30 percent.
That is unusual. Almost all prompting advice is qualitative. This one arrives with a percentage attached, which makes it the single most quotable and most examinable fact in the prompt-engineering domain. It will be on the exam in some shape.
Why it feels wrong
Every instinct says the opposite. If you handed a human 200 pages and a question, you would give them the question first so they know what to look for. Front-loading the ask is basic courtesy.
Closer to home: it is the opposite of how you write a function. Signature first, body after. Guard clauses at the top. Every convention you have for laying out code says state the contract before the detail.
Prompting does not work like that at this scale, and the guidance is explicit: data first, query last.
The exam trap writes itself. An option that says "put the question first so the model reads with purpose" is a perfectly reasonable-sounding distractor, and it is the one most people pick.
The document envelope
Long context also has a documented structure for the data itself, and it is more specific than "paste it in".
Three things are doing work here.
The index gives the model a stable handle. It can say "document 2" and you can resolve that to a real file.
The <source> element is separate from the content on purpose. Provenance is metadata, and mixing it into the body means the model has to guess which lines are the document and which are your labelling.
The <document_content> wrapper gives an unambiguous end marker for text you did not write and cannot predict. This is the same boundary argument from Module 1, and at 60k tokens of pasted-in material it stops being pedantry.
Ground answers in quotes first
The last piece of long-context guidance is a technique rather than a layout: have the model pull relevant quotes out before it answers.
Ask for the quotes, then the answer built from them. You get two things out of it. The model's answer is anchored to text that actually exists in the context rather than to a plausible-sounding blend. And you get an audit trail: when the answer is wrong, you can see whether it retrieved the wrong passage or reasoned badly from the right one.
That distinction is most of debugging a retrieval system, and it is free if you ask for the quotes. It is also the single change here most likely to pay for itself in your own work this month, because it converts an unfalsifiable answer into one with a citation you can go and check.
What this costs you
Nothing, structurally. There is no long-context pricing premium: the tokens cost what tokens cost. The economics of long prompts are entirely a caching question, which is the next lesson.
Try it yourself
Where the query goes
You are building a prompt with 60k tokens of source documents plus a question about them. Where does the question go?
Spot the bug in this prompt
A retrieval prompt, abridged. The envelope is correct and the tags are all closed properly. Something else is wrong.
<instructions>
Answer the question using only the documents provided.
</instructions>
<query>Which supplier raised prices in Q3, and by how much?</query>
<examples>
<example>...three worked examples, about 900 tokens...</example>
</examples>
<documents>
<document index="1">
<source>supplier-contracts-2024.pdf</source>
<document_content>...48k tokens...</document_content>
</document>
<document index="2">
<source>q3-price-changes.md</source>
<document_content>...12k tokens...</document_content>
</document>
</documents>
What is the defect?
The document envelope
Four element names and one attribute. This is the kind of detail that is trivially lookup-able and still worth holding, because you write it far more often than you look it up.
What is the documented XML structure for supplying multiple documents in a long-context prompt?
The threshold
There is a number attached to this guidance and a number attached to its payoff. This card is about the first one, the point where the advice switches on.
At roughly what prompt size does the long-context ordering guidance apply, and what changes?
What the big window costs
You move a feature from a 15k-token prompt to a 300k-token prompt. Same model, same output length, no caching in play. What happens to the input cost per call?
Grounding in quotes
Look at a retrieval-augmented prompt you have actually written. This one is a habit worth stealing for your own work regardless of the exam.
Your instructions ask the model to pull relevant quotes out of the supplied documents before it answers, rather than answering directly from the documents. If they do not, you have skipped the grounding step that makes long-context answers checkable.