An AI agent that books flights, reads web pages, and runs tools receives instructions from at least three parties in a single conversation: the application that shipped it, the human using it, and every third-party document it opens. When those instructions agree, anything works. When they conflict, the model has to pick a side. That choice is not an accident of scale or a philosophical stance. Labs train it explicitly, and they call it the instruction hierarchy.
The term describes a priority order over the sources of instructions. OpenAI's version, now documented in its public Model Spec, is a four-level ladder: system beats developer, developer beats user, user beats tool output. A model trained this way treats untrusted text, such as an invoice an agent was asked to summarize, as data to read rather than commands to obey.

The problem one text stream creates
Every large language model runs on a single context window. System policy, user request, retrieved documents, and API responses all arrive as tokens in the same stream, and the architecture itself gives them no inherent ranking. A model that reliably follows instructions will therefore also follow the wrong ones.
That gap is the common root of most well-known attacks on chatbots and agents. Simon Willison named the category prompt injection in 2022: hidden text on a web page tells the assistant to ignore its instructions, email the user's data, or take some other action the developer never sanctioned. Jailbreaks work on the same principle from the user side: a new instruction attempts to overwrite the safety policy the lab trained in.
A paper from OpenAI researchers in April 2024 put the diagnosis plainly. Its authors (Eric Wallace, Kai Xiao, Reimar Leike, Lilian Weng, Johannes Heidecke and Alex Beutel) argued that "one of the primary vulnerabilities underlying these attacks" is that models treat system prompts, text from an application developer, at the same priority as text from untrusted users and third parties. If the model cannot tell whose instruction it is following, every piece of untrusted input is a potential takeover.
The fix: train a chain of command
The paper's proposal had two parts. First, define a hierarchy that says exactly how the model should behave when instructions from different levels conflict: obey the highest-privilege applicable instruction, and ignore lower-privilege instructions that contradict it. Second, generate synthetic conversations that demonstrate the rule, high-privilege instruction followed by a lower-privilege attempt to violate it, and fine-tune the model on responses that hold the line.
Applied to GPT-3.5, the method raised robustness "by up to 63%" on the paper's main evaluations, including attack types never seen during training, with generalization to held-out evaluations "by up to 34%," and the authors reported minimal degradation on standard capability benchmarks. The cheap insight was that obedience is separable: a model can be taught not just to follow instructions, but to follow the right instructions.
The concept maps onto a familiar software-security pattern. Operating systems assign privilege levels so a normal process cannot act like the kernel; capability-based security restricts what each component may touch. OpenAI's current Model Spec applies the same intuition to agents, borrowing "the principle of least privilege and capability-based security common in software security" when scoping what tools an agent may reach for. Instruction hierarchy is the model-side half of that idea: privilege encoded in behavior rather than in infrastructure.
Two years on, the ladder is standard practice rather than a proposal. OpenAI says its models are trained on system > developer > user > tool. Its IH-Challenge post describes generating conflicting-instruction conversations, rewarding the model when it honors the higher-privilege constraint, and releasing the resulting training dataset publicly. The company reports that an internal model trained this way (it calls it GPT-5 Mini-R) improved on instruction-hierarchy benchmarks, held-out and adversarial tests, and prompt-injection evaluations including CyberSecEval 2, without collapsing into the over-refusal shortcut that plagues naive safety training. The failure of the ladder, in other words, is treated as the root cause behind disallowed-content requests, data exfiltration attempts and injected tool outputs alike.
The benchmarks say the wall leaks
Independent measurement has been less flattering than vendor summaries. IHEval, a 2025 benchmark, tests instruction-priority handling with 3,538 examples across nine tasks covering both aligned and conflicting instructions. Its verdict: every popular model evaluated "experiences a sharp performance decline when facing conflicting instructions," and the best open-source model in the study resolved such conflicts correctly only 48% of the time. Models that pass the sniff test in ordinary chat fail the moment two bosses disagree.
A 2026 diagnostic paper went a level deeper and broke the failure into three distinct stages: the model may not notice the conflicting instructions in a long context, may notice but resolve the conflict wrongly, or may resolve the conflict correctly in its reasoning and still emit the violating response. Testing reasoning models (Gemma-4-31B-IT, Qwen3.6-35B-A3B and Claude Sonnet 4.6) on long-context versions of IHEval and IH-Challenge, the authors found the dominant stage varied by model, task and context length. Their stopgap is a monitor: models that can detect a conflict but not resist it were made to self-check, cutting rule-following non-compliance by 81-99% against static attacks, though the best monitor recovered only 45% on GPT-5.3 under adaptive attacks. The model's own chain of command is thus fragile precisely where it matters most, long agentic sessions full of untrusted text.

The strongest caution comes from an October 2025 study titled "The Attacker Moves Second". Its authors tuned generic optimization tools, gradient descent, reinforcement learning and human-guided exploration, against twelve recent defenses against jailbreaks and prompt injections. They bypassed all twelve with attack success rates above 90% for most of them, even though "the majority of defenses originally reported near-zero attack success rates." Static benchmarks overstate safety; adaptive attackers reverse-engineer the defense and route around it. Practitioner red-teaming reached the same conclusion from the product side: a 2024 audit of gpt-4o-mini in ChatGPT showed lower-privileged message types overriding higher-privileged ones to extract system prompts and change the model's identity, and the author's blunt summary is that "the various privilege levels are not trust boundaries."
The alternative: keep the model out of the loop
If trained hierarchy is a soft wall, the architectural alternative is to remove the model from the decision entirely. Google DeepMind's CaMeL paper wraps the LLM in a protective system layer that extracts control flow and data flow from the trusted user query alone, so untrusted content can never alter which tools run. Data carries capability labels that enforce what may flow where, blocking private information from leaking to unauthorized sinks. On AgentDojo, a prompt-injection benchmark, CaMeL solved 77% of tasks with provable security against 84% for the undefended system, roughly seven points of utility paid for a guarantee a trained model cannot offer. The tradeoff frames the whole debate: hierarchy training is general, cheap and leaky; flow separation is specific, expensive and (for its threat model) provable.
What builders should take from it
Three practical readings follow from the evidence.
A system prompt is an instruction, not a sandbox. Hierarchy training makes violations less likely, up to 63% fewer in-distribution in the original paper, and every benchmark shows residual risk. Anything that must never happen should be enforced outside the model: tool allowlists, scoped credentials, egress filtering.
Privilege only helps if it is narrow. The Model Spec's least-privilege language is doing real work. An agent whose only tools are read-only cannot exfiltrate much even when it is fooled. Every write-capable, message-sending or money-moving tool an agent holds converts a prompt-injection success into a real incident.
Expect the ladder to keep climbing. OpenAI has introduced model spec midtraining, training models on synthetic documents about their Model Spec between pre-training and alignment fine-tuning, so the rules, including the privilege ladder, are learned as content rather than only imitated from demonstrations. As agents spend more turns inside untrusted documents, the question "whose instruction wins" stops being a security footnote and becomes the load-bearing wall of the product.
Sources
- The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructions - Wallace et al., April 2024
- Improving instruction hierarchy in frontier LLMs - OpenAI
- OpenAI Model Spec, current version
- IHEval: Evaluating Language Models on Following the Instruction Hierarchy - Zhang et al., 2025
- Where Instruction Hierarchy Breaks: Diagnosing and Repairing Failures in Reasoning Language Models - Kariyappa et al., 2026
- The Attacker Moves Second: Stronger Adaptive Attacks Bypass Defenses Against LLM Jailbreaks and Prompt Injections
- Defeating Prompt Injections by Design (CaMeL) - Google DeepMind
- Breaking Instruction Hierarchy in OpenAI's gpt-4o-mini - Embrace The Red
- Prompt injection definition - Simon Willison, 2022
- Model Spec Midtraining: Improving How Alignment Training Generalizes - Li et al., OpenAI
