Agent Instruction Hierarchy: Precedence and Enforcement
An agent instruction hierarchy is the ordering rule that determines which input source, such as a system prompt, developer configuration, tool output, retrieved document, or end-user message, takes precedence when instructions conflict. Model providers have begun training models to respect this ordering, but published guidance from OWASP, NIST, and Microsoft consistently states that training-time precedence alone does not reliably enforce it. Enterprises need independent runtime mechanisms, including trust-boundary tagging, tool-call gateways, output filtering, and permission enforcement, to make instruction hierarchy an operational security control rather than a probabilistic behavior.
An enterprise AI agent rarely receives instructions from a single source. A typical deployment combines a system prompt written by the platform team, developer-defined configuration and permissions, output returned from connected tools and APIs, content pulled from retrieved documents, and direct input from an end user. Each of these sources can, intentionally or not, contain instructions that conflict with one another. Instruction hierarchy is the rule set that determines which source wins when that happens.
OpenAI has published explicit work describing an instruction hierarchy in which system prompts are trained to take precedence over user messages, which in turn take precedence over third-party or tool content. This represents a training-time approach: the model itself is fine-tuned to weight instructions differently depending on their declared source. Anthropic's documentation similarly describes system-level instructions as intended to take precedence over user turns, though without detailing a formally enforced runtime mechanism separate from model behavior. Across vendors, there is no single, cross-provider technical standard specifying how precedence should be encoded, transmitted, or verified.
Why Training-Time Precedence Is Not Enough
Training a model to prefer certain instruction sources over others reduces susceptibility to some attacks, but it does not eliminate the underlying risk. OpenAI's own reporting on its instruction hierarchy work notes that training-based enforcement reduced success rates for certain injection attacks in evaluation benchmarks without eliminating all bypass techniques. This matters because models remain probabilistic systems: a sufficiently crafted input, whether from a user or from injected content in a retrieved document, can still shift model behavior in ways the declared hierarchy was meant to prevent.
OWASP's Top 10 for Large Language Model Applications lists prompt injection as a top-ranked risk and distinguishes direct injection, where a user attempts to override instructions, from indirect injection, where malicious instructions are embedded in tool outputs or retrieved content the agent processes automatically. OWASP guidance is explicit that prompt injection cannot be fully prevented through model-level controls alone, and recommends application-layer mitigations such as privilege control, output filtering, and human approval for sensitive actions. NIST's Generative AI Profile reaches a similar conclusion, framing indirect prompt injection as a risk requiring monitoring, access control, and content provenance safeguards that sit outside the model itself.
Where Enforcement Needs to Live
Because instruction-following in a trained model is a statistical property rather than a guarantee, enterprises that need reliable precedence enforcement typically add architectural layers between the model and the systems it can affect.
Treating Tool Output and Retrieved Content as Untrusted
A recurring theme across OWASP, NIST, and Microsoft guidance is that content entering an agent's reasoning loop from tools, APIs, or retrieved documents should be treated as untrusted by default. OWASP notes directly that indirect prompt injection via tool outputs or retrieved documents can override intended system instructions if the application does not enforce trust boundaries between content sources. This is a structural application design problem, not something solved by improving the system prompt's wording.
Microsoft's guidance on securing AI applications recommends techniques such as spotlighting or delimiting untrusted content, restricting tool permissions, and applying content filtering classifiers at runtime, rather than relying solely on how the system prompt is phrased. NIST's Generative AI Profile adds that maintaining provenance and access-control metadata for ingested content supports the ability to differentiate trusted from untrusted instruction sources at runtime, which is a prerequisite for any enforcement layer that acts on that distinction.
Implementation Decisions for Security Teams
Translating instruction hierarchy from a concept into an enforced control involves several concrete decisions.
Governance Considerations
NIST's AI Risk Management Framework Generative AI Profile frames instruction manipulation and prompt injection as risks requiring documented organizational risk management processes, not solely technical fixes. OWASP's LLM Top 10 functions as a widely referenced baseline risk taxonomy for security teams, though it is not a formal regulatory standard, and no binding regulatory requirement specifically mandating instruction hierarchy enforcement was identified in current guidance.
In practice, this means enterprises deploying agents should document their trust boundaries and precedence assumptions as part of standard AI system risk assessments. This documentation should specify which sources are trusted, how that trust is established and revoked, and what runtime controls exist independent of the model to enforce the stated hierarchy. This is the kind of artifact security and compliance reviewers will reasonably expect before approving agent deployments with tool access or sensitive data exposure.
Instruction Sources in a Typical Agent Deployment
Each source below carries a different intended level of trust. Enforcing that order reliably requires controls outside the model itself.
System Prompt
Defines core behavior and constraints, generally intended to hold highest precedence.
Developer Configuration
Application-level instructions and permissions set by the deploying team.
Tool Output / Retrieved Content
Data returned from APIs, documents, or connected systems, treated as untrusted by default.
End-User Input
Direct requests from the person interacting with the agent.
Frequently Asked Questions
Is instruction hierarchy the same as a system prompt?
No. A system prompt is one instruction source among several. Instruction hierarchy is the broader rule set determining how system prompts, developer configuration, tool output, retrieved content, and user input are prioritized when they conflict.
Can model training alone enforce instruction hierarchy?
Evidence from OpenAI's own published work shows training-time approaches reduce but do not eliminate susceptibility to instruction override attacks. OWASP and NIST guidance both recommend application-layer and runtime controls as necessary complements.
What is indirect prompt injection?
Indirect prompt injection occurs when malicious instructions are embedded in content the agent processes automatically, such as a retrieved document or a tool's API response, rather than typed directly by a user. OWASP identifies this as harder to mitigate than direct injection.
Does a tool-call gateway replace the need for a good system prompt?
No. A well-defined system prompt remains part of establishing intended precedence. A tool-call gateway is a separate, independent control point that validates or blocks actions regardless of what the model outputs, compensating for cases where instruction-following fails.
Enforce Instruction Precedence at Runtime
Trussed AI provides runtime governance and security controls for enterprise AI agents, including runtime policy enforcement, tool approval workflows, agent permissions, and audit logging, to help enforce instruction hierarchy independent of model behavior.
Request a Demo