Join our Newsletter — 33% off our NHI Course

How should teams test AI agents that can use tools and change state?

Test the decision path, not just the final answer. Score tool selection, argument quality, execution order, and final state across repeated runs, because agents can reach the same outcome through different valid trajectories. Use controlled dependencies for anything state-changing, then promote real production failures into the regression suite so the test set keeps pace with live behaviour.

Why This Matters for Security Teams

Testing AI agents that can call tools and change state is not the same as testing a chatbot response. The risk is operational: an agent can make the right-looking decision, execute the wrong action, or leave behind an unsafe state that only shows up later in production. That means validation has to cover tool choice, parameter quality, sequencing, rollback behaviour, and repeated-run consistency, not just answer quality. Guidance from the NIST AI Risk Management Framework is useful here because it treats trustworthiness as a lifecycle concern, not a one-time release gate.

Teams often miss that agent failures are frequently hidden by apparently successful outcomes. A workflow may complete, but do so by overprivileged access, brittle retries, or an unsafe side effect that was never asserted in test. The testing model therefore needs to simulate realistic tool permissions, state transitions, and dependency failures, while also checking whether the agent can recover without escalating risk. That is especially important when agents sit near identity, secrets, or privileged workflows, where a single bad action can become an access-control incident. In practice, many security teams encounter these failures only after an agent has already modified state in a way the original test never observed, rather than through intentional negative testing.

How It Works in Practice

A useful test plan starts by treating each agent run as a sequence of decisions and side effects. The test harness should log the prompt, retrieved context, tool selection, arguments, response order, and final state so reviewers can see where the trajectory diverged. This is consistent with the intent of the OWASP Top 10 for Agentic Applications 2026, which emphasises agent-specific failure modes such as excessive autonomy, tool abuse, and insecure orchestration. For threat modelling, the MITRE ATLAS adversarial AI threat matrix helps map where prompt injection, data poisoning, or execution manipulation might surface during testing.

Practical coverage usually includes:

  • Golden-path tests for expected tool calls and approved state changes.
  • Negative tests for prompt injection, malformed arguments, permission denials, and partial failures.
  • Replay tests that rerun the same scenario several times to catch nondeterministic tool choice or state drift.
  • Dependency isolation for databases, ticketing systems, cloud APIs, and any workflow that mutates production-like data.
  • Regression cases built from real incidents so the suite evolves with live behaviour.

Where state changes are involved, best practice is to assert both the intended outcome and the absence of unintended side effects. That means checking records created, permissions changed, messages sent, or secrets accessed, not just whether the final user-facing answer was plausible. For higher-risk agentic systems, the CSA MAESTRO agentic AI threat modeling framework is helpful for structuring scenarios around autonomy boundaries and control points. These controls tend to break down when agents are allowed to reach live SaaS, cloud, or identity systems during tests because real side effects make failures expensive and hard to unwind.

Common Variations and Edge Cases

Tighter state-control often increases test complexity and maintenance overhead, requiring organisations to balance realism against repeatability. There is no universal standard for how much nondeterminism to tolerate, but current guidance suggests that teams should define acceptance windows for variation before release, rather than arguing over individual runs after the fact. That matters because two agent traces can both be “successful” while only one is safe.

One common edge case is the agent that behaves correctly in a sandbox but fails when real tool latency, rate limits, or permission scopes change. Another is hidden coupling between retrieval content and tool choice, where the agent appears stable until a document update alters the decision path. In those cases, test coverage should include provenance checks for retrieved context, authorization checks for each tool call, and separate assertions for state before and after execution. The NIST AI Risk Management Framework remains useful as a governance layer, while the Anthropic AI-orchestrated cyber espionage campaign report is a reminder that agent misuse is not theoretical. For teams testing identity-adjacent agents, the real issue is often not whether the model answered well, but whether it preserved least privilege and left no durable unsafe state behind.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10, MITRE ATLAS and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Agentic AI Top 10 LLM01 Agentic apps need tests for tool misuse, unsafe autonomy, and bad actions.
NIST AI RMF GOVERN AI RMF governance requires lifecycle risk controls and traceable evaluation.
MITRE ATLAS AML.T0016 Prompt injection and execution manipulation are central adversarial AI threats.
CSA MAESTRO MAESTRO models autonomy boundaries and control points for agentic systems.
NIST CSF 2.0 DE.CM-1 Continuous monitoring is needed to detect unsafe agent actions and drift.

Instrument agent runs so security teams can detect anomalous tool use and state changes.