By NHI Mgmt Group Editorial TeamBased on Braintrust: “How to test AI agents: A practical guide” (August 16, 2026)

TL;DR: AI agents can reach the same valid outcome through different tool paths, so exact-match assertions miss real failures in tool choice, argument construction, execution order, and state changes, according to Braintrust. Reliable evaluation needs trace-based scoring, repeated trials, regression suites, and production feedback loops that turn observed failures into new cases.


At a glance

What this is: This guide argues that AI agent testing needs trajectory scoring because valid agent runs can differ in path while still reaching the right outcome.

Why it matters: It matters because teams governing AI agents need tests that evaluate tool use, sequencing, and state changes, not just final text, or they will miss real production risk.


Context

AI agent testing is not the same as testing deterministic software because the system can choose among multiple valid actions, tools, and execution orders. That creates a governance problem for teams that need confidence in outputs that also change external state, especially where AI agents interact with workflows, data stores, or customer-facing services.

The identity angle emerges when an agent is allowed to call tools, issue state-changing actions, or operate with delegated access. In those cases, evaluation has to prove that the agent stayed inside its intended authority and completed the right sequence, not simply that it produced a plausible answer.


Key questions

Q: What should teams do when an AI agent can reach the right outcome through different tool paths?

A: They should stop using exact-match checks as the main pass or fail signal and score the agent on tool choice, argument quality, dependency order, and final state. Multiple valid trajectories are normal for agentic systems, so the test must allow variation while still rejecting unsafe or incorrect decisions. That usually means trace-based evals with defined thresholds and repeated trials.

Q: Why do AI agents need trajectory testing instead of only output testing?

A: Output testing only checks the final response, but agent failures often begin earlier in the run. A trajectory test shows whether the agent selected the right tool, used the correct arguments, followed required sequencing, and left external state in the expected condition. That makes it possible to detect hidden failures that a good-looking final message would otherwise conceal.

Q: How can security teams tell whether an AI agent test suite is good enough?

A: A useful suite covers happy paths, edge cases, adversarial inputs, and known failures, then runs those cases repeatedly under controlled conditions. It is strong enough when critical behaviours are represented, regression checks block risky changes, and production failures are regularly promoted into new cases. If the suite does not change as the agent changes, coverage is already decaying.

Q: What is the difference between unit tests and evals for AI agents?

A: Unit tests verify deterministic code contracts, such as whether a function rejects invalid input, while evals measure model-driven behaviour where several outputs or paths may be acceptable. Agent systems need both because a unit test cannot judge decision quality and an eval cannot prove the underlying tool or service is correct. Use each for the type of risk it can actually detect.


Technical breakdown

Why exact-match assertions break for AI agent testing

Exact-match checks assume one input has one acceptable output, which is true for deterministic code but false for agentic systems. An agent may reach the same valid end state through different tool orders, different wording, or different intermediate decisions. That means the test has to score the trajectory, not just the closing message, and it has to tolerate multiple correct paths while still rejecting wrong tool choice, incorrect arguments, or an unsafe sequence. The practical unit of evaluation becomes the decision and its effect, not the final sentence.

Practical implication: Use scored criteria for tool choice, sequence, and final state instead of asserting one fixed response.

How trajectory scoring captures state-changing behaviour

Trajectory scoring evaluates the full run from user request to final system state. Each step in the loop can be traced, scored, and compared against expected behaviour, which is essential when the agent repeats calls, skips a required dependency, or completes the wrong action in a seemingly successful run. This approach is stronger than a single end-state check because it can show where correctness failed, whether in tool selection, argument construction, or ordering. It also makes regression testing useful for agent behaviour that is non-deterministic by design.

Practical implication: Instrument agent traces so every tool call and state transition can be scored independently and in sequence.

Why production failures must become new eval cases

Agent behaviour changes as prompts, tools, and external services change, so a static test suite quickly goes stale. The guide’s core testing model treats reviewed production failures as new evaluation cases, which keeps the suite aligned with real usage rather than synthetic assumptions. That matters because the highest-value cases are often the ones that exposed a failure in live traffic, not the ones imagined in advance. In practice, the evaluation programme becomes a feedback loop between production observation, curated datasets, and pre-release gating.

Practical implication: Feed reviewed production traces back into the regression suite so the test set keeps pace with observed failures.


NHI Mgmt Group analysis

Trajectory scoring is the right control because agentic failure is often path-dependent. The central testing mistake is to treat an agent like a traditional function with one correct output. Once tool choice, step order, and mutable state enter the flow, the same task can have several acceptable trajectories, so the control must evaluate the path as well as the result. Practitioners should treat scored traces as the primary evidence of correctness.

Agent testing becomes an authorisation problem as soon as the model can act on external systems. When a test run can issue refunds, alter records, or send messages, the concern is no longer only accuracy. The real governance question is whether the agent is constrained to the right tool set, the right arguments, and the right state changes, which is an identity and privilege issue as much as a testing issue. Practitioners should align evaluation with delegated authority.

Observed failures should be promoted into the control baseline, not handled as one-off defects. A mature agent programme does not just fix a bad run and move on. It converts the failure into a repeatable test case, links it to a threshold, and uses regression scoring to prevent reintroduction. That creates a living control surface rather than a static test suite, which is the only way to keep pace with changing agent behaviour.

Testing AI agents requires a new mental model for quality assurance. The article shows that teams need layered evaluation across unit-level decisions, end-to-end trajectories, and production monitoring. That model fits agentic AI better than legacy software QA because the system can behave correctly in multiple ways while still failing at the decision level. Practitioners should build evaluation around behaviour, not just output.

From our research library:

What this signals

AI agent QA needs to move from response checking to decision assurance. The operational lesson for practitioners is that a clean final answer can still hide the wrong tool, the wrong sequence, or an unsafe state change. The test programme therefore has to evaluate authority at the point of action, not only at the point of reply.

Decision assurance becomes more important as agents are given broader delegated access. When a system can call APIs, modify records, or trigger workflows, the control objective is no longer just correctness but containment of action scope. That is where agent identity, tool permissions, and test scoring intersect, and where evaluation should be treated as a governance control rather than a QA convenience. According to the 2026 Infrastructure Identity Survey, 53% of security leaders expect AI to run major portions of their infrastructure autonomously within the next three years.

Trajectory-based testing is a practical way to reduce evaluation debt. Teams that keep adding ad hoc checks without promoting real failures into the suite eventually end up with tests that look comprehensive but miss the behaviours that matter. The more agentic the workflow, the more important it becomes to keep the dataset, scorer, and production traces in step with one another.


For practitioners

  • Define scored criteria for each critical agent decision Separate tool selection, argument validation, output format, and response quality into distinct scorers so a run can pass one check and fail another without losing diagnostic value.
  • Trace every state-changing tool call Record tool inputs, outputs, and errors in the execution trace so the failed step can be tied back to the prompt, schema, or tool description that caused it.
  • Build regression suites from reviewed production failures Promote failed real-world traces into the dataset, then rerun them in CI with blocking thresholds for release-critical behaviours such as task completion and safe tool use.
  • Stub external systems during offline evaluation Use controlled stand-ins for databases, APIs, and messaging systems so tests are reproducible and do not trigger live refunds, updates, or notifications.
  • Run repeated trials on high-variation cases Use multiple trials for the same input when the agent has several valid trajectories, then measure consistency instead of trusting a single pass or fail result.

Key takeaways

  • AI agents can be correct through different trajectories, so tests must measure decisions and state changes, not only the final message.
  • Trajectory scoring, repeated trials, and controlled dependencies expose failure modes that exact-match assertions miss.
  • The strongest agent testing programmes turn production failures into new eval cases and use them as release gates.

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 and MITRE ATLAS 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.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI03 — Identity & Privilege AbuseAgent testing here is fundamentally about constraining delegated tool use and state-changing authority.
ASI02 — Tool MisuseThe article focuses on wrong tool choice, wrong arguments, and unsafe sequencing inside agent loops.
Recommendation — Score agent runs against ASI03 by validating tool authority, argument scope, and state-changing permissions. Use ASI02 to evaluate whether each tool call is appropriate, correctly formed, and sequenced.
NIST AI RMFMANAGE — AI Risk Management and MonitoringContinuous scoring, regression gates, and production feedback are core risk management practices for agents.
Recommendation — Apply MANAGE to monitor agent performance continuously and convert production failures into controls.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsAgent tool access and state-changing actions require explicit authorisation boundaries.
Recommendation — Enforce PR.AA-05 so agent permissions match the exact actions and data the workflow requires.
MITRE ATLASTA0006;TA0004 — Credential Access; Privilege EscalationAgent evals must catch paths where a model abuses tools or exceeds granted authority.
Recommendation — Map agent misuse and overreach to TA0006 and TA0004 when scoring delegated access.

Key terms

  • Trajectory Scoring: Trajectory scoring is a method for grading the full path an AI agent takes during a task, including intermediate steps and tool calls. It helps teams understand whether the agent reached the right outcome through the right process, which is essential for complex workflows with branching logic and external systems.
  • Evaluation Suite: A set of repeatable tests used to measure whether an AI system behaves as intended and stays within acceptable boundaries. In agentic coding, evals function like verification gates, showing whether generated changes improve the system or quietly introduce regressions.
  • Production Trace Review: The practice of examining live agent traces to confirm what data the system accessed, what action it took, and where it escalated. This turns quality assurance into an operational control that can detect drift after prompts, models, or connectors change.
  • Tool Selection Error: A tool selection error occurs when an agent chooses the wrong external action for the task, even if the final response looks plausible. These mistakes matter because the risk often sits in the action taken, not just in the text returned to the user.

Deepen your knowledge

NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, agentic AI identity, machine identity security, and secrets management. It helps security and identity teams build governance for delegated systems that act across tools and data.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 18, 2026.
Updated on October 12, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org