Two prompts with identical content in a different order will not produce identical answers. Attention across a long input is not uniform, and generation is sequential, so where something sits changes how much it influences the result.
Where is attention strongest?
At the beginning and the end. Material in the middle of a long input receives measurably less reliable attention, a pattern demonstrated repeatedly in research and present even in models with very large context windows.
The practical consequence is that anything important should not be buried. A crucial constraint in the middle of a page of instructions is the one most likely to be missed.
Why does the opening matter so much?
Because generation is sequential and everything produced is conditioned on what came before. The first sentence of the answer sets a direction, and that direction was set by the earliest part of your prompt.
This is why a prompt that opens with background and reaches the actual request three paragraphs later frequently produces an answer about the background.
What order works for most prompts?
- The task, stated plainly in one sentence.
- Context the model needs to do it.
- The material, clearly marked.
- Format and constraints.
Task first because it frames everything after it. Constraints last because that position is attended to reliably and sits closest to where the answer begins.
When should the material go first?
For very long documents, there is an argument either way, and the structure that works best is to bracket it: a short instruction, the document, then the full instruction again.
Read the contract below and answer the questions that follow it.
[document]
Now: list every obligation falling on us, with the clause number. Answer only from the document. If something is not stated, say not stated.
Repeating the instruction after the material costs a few tokens and measurably improves compliance.
Why does recency win in conversations?
Because the same effect applies across a whole exchange. Your latest message sits at the end of the input and carries more weight than an instruction given forty messages ago, which may also have fallen out of the context window entirely.
Restating a constraint in the message where it matters is the reliable fix, and it is why this feels like nagging.
Does example order matter?
Slightly. Models are influenced more by later examples than earlier ones, so placing the case most similar to your real input last is a small free improvement. Consistency of formatting across examples matters more.
Where should the most important constraint go?
Last, and stated on its own line. The final instruction before generation begins is the one followed most reliably, which makes it the right place for whatever you would be most annoyed to see ignored.
Putting it first as well costs nothing and helps on long prompts, where the beginning and end are both attended to and the middle is not.
How should you structure a long prompt visually?
With clear separation between sections. Headings, labels or a line of dashes between the instruction, the material and the constraints all help, because the model has to work out where one ends and the next begins.
Unstructured walls of text are where instructions get read as content and content gets read as instructions.
Does this apply to files as well as text?
Yes, and it is the same effect. An attached document occupies a position in the input, so a question asked before the file and a question asked after it are not equivalent requests.
Asking afterwards generally works better, since the question then sits at the end where attention is reliable. Where several files are attached, naming which one a question refers to matters more than order, because otherwise the model has to infer it from content.
What is worth testing yourself?
Take a prompt you use regularly and move the constraints from the middle to the end. Run both several times. For anything with more than a few instructions the difference is usually visible, and it costs five minutes to find out which arrangement your task prefers.