Zenaique

When does it pay to repeat key instructions near the bottom of the user turn instead of trusting the system prompt?

Flashcard·Medium·4.0 · 0·~30s·Asked atOracle
Attempt it
TL;DR

Mirror one or two critical rules at the bottom of the user turn. This uses the recency slot and punches through the lost-in-the-middle trough, while the bulk of the policy stays in the cached system prompt.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a meeting where you spent 20 minutes laying out the agenda at the start, then talked through a long set of slides, then asked the team to act. The agenda is at the top, the slides are in the middle, and the action ask is at the bottom. By the time people are about to act, the slides are fresh in their minds and the agenda is fading. So when you need them to remember one specific rule, you say it again right before the action. A prompt works the same way. The system prompt is the agenda from the start of the meeting. The retrieved chunks are the slides. The user turn is the action ask. Repeating the critical rule right before the model generates is the equivalent of saying "and remember, this one thing matters most" right before people start working.

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.

Where you put an instruction in a prompt matters as much as what the instruction says. Position controls how strongly the model attends to a rule during generation. The strongest position is the bottom of the input immediately before the model starts producing tokens. Experienced context engineers use this fact deliberately. They mirror one or two critical rules at the bottom of the user turn, even though those rules are already stated in the system prompt at the top.

Recency, primacy, and the lost-in-the-middle trough

Three position effects shape how a model attends to instructions in a long prompt.

Recency is the strongest. This is an empirical effect, not a built-in rule of self-attention. Part of it likely comes from training data, where next tokens correlate strongly with what was just said. Whatever the precise mechanism, the empirical result is that instructions in the recency slot are the hardest for the model to ignore.

Primacy is the second-strongest position. The top of the prompt has high attention weight because the model has to establish the framing for everything that follows. This is why system prompts at the top of the input are reasonably effective, even though they are far from the generation start. The model establishes the persona and the rules early.

The middle is the weakest position. The lost-in-the-middle effect was documented in the 2023 Liu et al. paper on multi-document QA and key-value retrieval. Key information placed in the middle of a long input is used much less reliably than the same information placed at the boundaries. The paper found the U-shape even in models built for long contexts. Newer models score better on long-context benchmarks, but position still matters.

A typical RAG or agent prompt arranges itself naturally into this shape. The system prompt sits at the top (primacy slot), accumulated retrieval or tool-call history fills the middle (the weak zone), and the user turn is at the bottom (recency slot). A critical rule stated only in the system prompt has to compete with everything in between to reach the model's attention at generation time. Take a 32K-token prompt with the system prompt at position 0 and the user turn at position 31000. The system-prompt instruction there is in a structurally weaker position than a freshly stated instruction at the bottom of the user turn.

When mirroring earns its tokens
Discipline: selectivity, source of truth, cache awareness
Composition with other position engineering tricks
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Anthropic advises putting long documents near the top and the query at the end, and reports that this can improve response quality by up to 30 percent on complex multi-document inputs.
  • For GPT-4.1, OpenAI recommends placing instructions at both the beginning and the end of long provided context, and above the context if they appear only once.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does this pattern interact with provider-side prompt caching (Anthropic, OpenAI, etc.)?
A

The cached portion of the prompt is typically the system prompt plus the long static retrieval block, depending on provider semantics. The mirrored rules at the bottom of the user turn live outside the cache boundary, so they cost a few extra tokens per call but do not invalidate the cache. This is the cost-aware way to deploy the pattern: the bulk of the prompt remains cache-friendly while the mirrored rule does its work at the recency slot.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating instruction repetition as a sign that the system prompt failed. The repetition is a deliberate use of the recency slot, not a workaround for a broken system prompt.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Define the recency slot and explain why it gets the most attention weight

  • Define the lost-in-the-middle effect and explain when it dominates

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
List the trace spans a context engineering pipeline should emit per call
Flashcard·Medium