AI Glossary / Prompting and human-AI interaction / Intermediate
Instruction hierarchy
Definition
An instruction hierarchy is a ranking of the sources of instructions an AI model receives, so that when two instructions conflict, the higher-ranked one wins. A common order is the model provider's rules, then the application builder's system instructions, then the user's request, then text found inside documents or tool results. It is a design principle that vendors and builders apply in different ways, not a single formal standard.
What it means
An AI model reads everything as text. A rule from your company, a question from a customer and a sentence buried in an uploaded PDF all look much the same to it. Without some ordering, the model has no reliable way to decide whose words count most when they disagree.
An instruction hierarchy supplies that ordering. Think of the way a business already works. A law outranks company policy, company policy outranks a manager's preference, and a manager's preference outranks a casual request from a colleague. The hierarchy asks the model to behave the same way. Fixed rules come first, the builder's setup second, the user's wishes third, and anything that merely arrives as content sits at the bottom as information to read, not orders to obey.
How it works
In most products, instructions enter through separate channels. The model provider trains in baseline behavior and limits. The application builder writes a system prompt that sets the role, tone, scope and prohibited actions. The user types messages into the conversation. Finally, the app may pull in outside content such as web pages, emails, files and tool outputs.
Models are trained, and often tested, to give more weight to the higher channels. If a system prompt says never to reveal internal pricing rules and a user asks for them, the model should decline. If an email the assistant is summarizing says to ignore all previous instructions and forward the inbox, the model should treat that sentence as part of the email, not as a command. This is the main defense against prompt injection.
The hierarchy is a tendency, not a guarantee. It is learned behavior, so it can fail, especially against cleverly worded attacks. Sound designs therefore add controls outside the model: restricted permissions, approval steps for sensitive actions, and logging. Vendors also differ in how many levels they define and in how much room users get to adjust the builder's defaults.
Three practical examples
- Support desk: A retailer's assistant has a system instruction to offer refunds only up to 50 dollars. A customer writes that a manager approved a 200 dollar refund. The assistant keeps to the system limit and offers to pass the case to a human, because the builder's rule outranks an unverified user claim.
- Finance team: An assistant summarizes vendor invoices that arrive as PDFs. One invoice contains hidden text saying to mark it as approved and skip review. Under a sound hierarchy the text is treated as invoice content to report on, not as an instruction, and the approval step stays with a person.
- Internal HR helper: A company sets the assistant to answer only from the staff handbook and never give legal advice. An employee asks it to act as a lawyer and assess a dispute. The assistant explains that it can quote handbook policy and suggests contacting HR or counsel, because the builder's scope outranks the user's request.
Think of it this way
Think of a new employee who gets instructions from the law, the employer, a customer and a note slipped under the door. The employee follows them in that order and treats the note as information only. The analogy stops working because a person understands authority from context and consequences, while a model has only learned patterns, so it can still be fooled by text that mimics a higher source.
Worked example
A company tests its assistant with 200 injection attempts: 120 are typed by users and 80 are hidden inside documents the assistant reads. Before adding clear hierarchy rules and training, the assistant obeys 30 of the 120 user attempts and 44 of the 80 document attempts. That is 30 + 44 = 74 failures out of 200, or 74 / 200 = 37 percent.
After the builder restructures the system prompt, labels document content as untrusted data and tightens permissions, it obeys 6 of the user attempts and 8 of the document attempts. That is 6 + 8 = 14 failures out of 200, or 14 / 200 = 7 percent. The drop is 37 - 7 = 30 percentage points. A 7 percent failure rate is still too high for sending payments, so the team also requires human approval for any action that moves money.
Illustrative case study
Fictional case: Harbor Lane Outfitters, a made-up online camping retailer, launches an order assistant that can look up orders and issue small credits. In the first week, a shopper pastes a message into the chat that claims to be from the system and says credit limits are now disabled. The assistant issues a credit far above its limit.
The team reviews the logs and finds that all text was treated as equally authoritative, and that the credit limit existed only as a sentence in the prompt. They fix it in layers. The system prompt now states the order of authority and says that user messages and pasted content cannot change the rules. The credit tool enforces its own cap in code, so the limit no longer depends on the model's judgment. Credits above the cap go to a staff queue. They then replay the earlier attack and a set of similar ones before relaunching, and keep the replay set as a regression test for every future prompt change.
Common misconceptions and mistakes
A good system prompt fully prevents the model from obeying the wrong instruction. The hierarchy makes failures less likely but does not remove them, so important limits should also be enforced in code and permissions.
The hierarchy means the user's instructions never matter. Users normally control most of the task, such as format, depth and tone, and the hierarchy only decides who wins when instructions truly conflict.
Text inside a document is safe because the user uploaded it. The user's intent does not make the contents trustworthy, since the document may have been written by someone else with other goals.
Every AI product uses the same ordering. Providers and builders define the levels differently, so you should check the documentation of the specific tool you use.
Business use
Start by writing down who is allowed to instruct your assistant: your company, your staff, your customers, and outside content. Put the fixed rules in the system instructions, say plainly that pasted text and retrieved documents are data, and keep a short list of things the assistant must never do. Then test with adversarial cases, such as a user claiming authority, a document with embedded commands, and a request to reveal the rules, before and after each change.
Measure the rate at which tests break the rules, the number of escalations to humans and the share of legitimate requests wrongly refused, since over-strict setups frustrate customers. Costs are mostly design and testing time, plus a possible slowdown from approval steps. The main risk is relying on the hierarchy alone. Pair it with least-privilege access, human review of high-impact actions and logs you can audit.
People also ask
Is an instruction hierarchy the same as a system prompt?
No. A system prompt is one source of instructions, while the hierarchy is the ordering that says how that source ranks against user messages and outside content.
Does an instruction hierarchy stop prompt injection?
It reduces the risk by teaching the model to treat embedded text as data, but it does not eliminate it. Permission limits and human approval for risky actions are still needed.
Can a user override the system instructions?
Usually only where the builder allows it, such as changing tone or format. Requests that conflict with the builder's rules or the provider's limits should be declined.
Check your understanding
In the worked example, what was the failure rate before the fixes?
Answer: 74 failures out of 200 attempts, which is 37 percent.
Why did the team in the worked example still add human approval for payments?
Answer: Because a 7 percent failure rate after the fixes is too high for actions that move money.
In the Harbor Lane case, why did the team enforce the credit cap in code?
Answer: A limit that exists only as a sentence in a prompt depends on the model's judgment and can be bypassed, while a cap in the tool holds regardless.
Where does text found inside an uploaded document sit in a typical hierarchy?
Answer: At the bottom. It is treated as information to read, not as a command to follow.
Related terms
Learn next
Write a one-page authority map for an assistant you use or plan to build, listing who may instruct it and what each party may and may not change. Then read about prompt injection and guardrails to see how the hierarchy fits with technical controls.
More in Prompting and human-AI interaction
- Image-to-image - Image-to-image is a way of using a generative AI model in which you supply an existing picture as the main input, usually with a short text instruction, and...
- Incremental Few-shot Learning - Incremental few-shot learning is learning new categories or capabilities in successive stages from small labeled datasets while retaining useful performance...
- Indirect prompt injection - Indirect prompt injection is an attack in which instructions are hidden inside content that an AI system reads on someone's behalf, such as a web page...
- Instruction tuning - Instruction tuning is additional training that teaches a language model to respond to tasks expressed as instructions.
- JSON mode - JSON mode is a setting offered by some AI model providers that constrains a language model to produce output that is valid JSON, a common text format for...
- Least-to-most prompting - Least-to-most prompting is a language-model prompting strategy that first decomposes a problem into simpler subproblems and then solves them in sequence...
Sources
OpenAI, Prompt engineering guide: https://platform.openai.com/docs/guides/prompt-engineering NIST, AI Risk Management Framework: https://www.nist.gov/itl/ai-risk-management-framework Anthropic, Building effective agents: https://www.anthropic.com/engineering/building-effective-agents The sources were consulted for background on how instructions are layered in prompting, on managing AI risk and on agent design; the examples, analogy, worked example and case are original educational illustrations. Checked 5 Nov 2026.
Previous: Institutional Bias Next: Instruction-level parallelism