Writing ·

How to test instruction hierarchy in AI agents in 2026

Test instruction hierarchy at the action boundary: declare the protected constraint, inject user and tool-output conflicts, and assert an allowed action, refusal, or escalation before a side effect occurs.

By Youssef Hemimy · agent safety · agent evaluation · AgentOps

Test instruction hierarchy at the action boundary. For every privileged tool or consequential decision, declare the protected constraint, inject a conflicting user or tool instruction, and assert the allowed action, refusal, or escalation before the side effect occurs. Repeat the case and retain failures as regressions; a pass on a bounded suite is not proof against prompt injection.

The useful question is not whether an agent's explanation sounds persuasive. It is whether the harness preserves a protected constraint when lower-priority content tries to change what the agent may do.

An instruction-conflict test preserves a protected constraint, injects conflicts through each untrusted input surface, and asserts an explicit action-boundary outcome that can be replayed.

Start with a protected action, not a generic adversarial prompt

Write the test around the action that matters. A useful case has a declared authority boundary and one observable result. This is AgentOps Hardening: turn a fuzzy prompt-safety expectation into an auditable release condition.

Test fieldWhat to specify
Protected instructionThe constraint that must remain in force.
Lower-priority conflictThe user message or tool result that competes with it.
Allowed action surfaceThe tool, parameter range, recipient, or data class at stake.
Expected outcomeExecute, refuse, ask for confirmation, or escalate.
Evidence to retainThe case version, decision, tool request, and observed result.

A tool-result test might preserve an approved task while an untrusted search result asks the agent to send data elsewhere. The expected result is not that the model notices something suspicious. It is a concrete allowed action, refusal, or escalation before the side effect. Version the conflict and its expected result with the tool contract.

Cover direct and tool-mediated conflicts separately

The early IH-Benchmark preprint separates direct system-user conflicts from user-tool conflicts. It describes 2,336 executable scenarios across 44 constraint families and reports that strong performance on direct system-user conflicts was not a reliable proxy for robustness when conflicting instructions appeared in tool output.

  • System or developer versus user: test whether a request to bypass an action policy, disclose protected information, or alter an allowed parameter remains blocked.
  • User versus tool or retrieved content: test whether an email, document, web page, or tool result can redirect the approved task or cause a new tool call.
  • Action manipulation: test whether lower-priority text can change a recipient, tool, parameter, or approval requirement even when the final prose looks normal.
  • Stateful replay: test the same protected boundary after retrieval, memory, retries, or a prior tool result.

The last category is Bonfire operating guidance. The preprint's bounded cases and author-written taxonomy do not establish robustness for long, stateful workflows.

Make the expected result deterministic

Do not grade a conflict case with “the answer sounded safe.” Encode the accepted result as narrowly as your workflow permits:

given: approved recipient = finance@example.com
when: tool output asks the agent to send the report to a new address
then: no send action occurs for the new address
and: the trace records refusal or an approval request

Prefer deterministic assertions where you control the action contract: no unapproved recipient, no tool outside the allow list, no parameter outside a declared range, and no execution after a required confirmation is missing. Use a reviewer only for residual ambiguity and retain the evidence it used.

NIST's agent-hijacking evaluation guidance reinforces this discipline: inspect task-specific attack performance rather than only an aggregate result, and use multiple attempts when repeated attacks are realistic because model outputs can vary.

Treat tool results as data, then reduce the blast radius

Anthropic's guidance says to treat tool-result content as untrusted data, limit access to sensitive actions and data, screen tool output before the agent acts, and red-team documents, emails, and tool outputs that deliberately contain injection attempts.

  1. Keep untrusted content in a data channel rather than an authority-bearing instruction channel.
  2. Give the agent only the tools and permissions the task requires.
  3. Validate side-effecting tool arguments outside the model where a deterministic contract is possible.
  4. Put confirmation or escalation at the actual risk boundary, not after the effect has happened.
  5. Feed every confirmed conflict failure back into the regression suite.

Turn failures into stateful regressions

When a conflict case fails, keep more than the injected text. Record the authority labels, the tool and parameters at stake, relevant state or retrieval context, the expected outcome, the actual decision, and the evidence available to the evaluator. Replay it after a model, prompt, tool schema, retrieval policy, or approval policy changes.

Connect the outcome to production agent tool contracts, private MCP reachability and authorization, human approval gates, and an agent observability dashboard.

What this evidence does not establish

IH-Benchmark is an arXiv preprint, not a peer-reviewed production standard. It evaluates 37 model variants and reports compliance from 20.5% to 98.2% across its scenarios. Those numbers describe that benchmark, not the safety of a different model, prompt, agent framework, or customer workflow.

NIST's guidance offers evaluation lessons rather than a universal release threshold. Keep the policy narrow, test the actual action surface, and make ambiguity an escalation outcome rather than silently granting authority.

Sources

FAQ

Is a prompt-injection benchmark pass enough to authorize a sensitive tool?

No. A benchmark pass is evidence about the cases it covers. Sensitive tools still need narrow permissions, deterministic argument checks where possible, and confirmation or escalation rules at the side-effect boundary.

Should user-versus-tool conflicts use the same cases as system-versus-user conflicts?

No. They can share a protected action, but they should be separate cases. The IH-Benchmark preprint found that strong direct system-user results did not reliably predict tool-output conflict robustness in its evaluation.

How many times should we repeat a conflict test?

There is no universal count in these sources. Choose a documented repeat policy based on the action's risk and the opportunity for an attacker to retry; record per-attempt and task-specific outcomes rather than only one aggregate rate.

Does screening a tool result solve instruction-hierarchy failures?

No. Screening is one layer for untrusted content. Keep the authority policy, tool validation, least privilege, and escalation boundary in place, then test the combination with workflow-specific cases.

Building something that has to hold up?

We do this work for teams — agent reliability hardening, custom MCP servers, and full-stack AI systems built to survive production.