By NHI Mgmt Group Editorial TeamDomain: Cyber SecuritySource: BraintrustPublished June 26, 2026

TL;DR: Stateful agents cannot be evaluated with single-prompt replay because memory, live systems, and multi-step trajectories create failure modes that only appear over time, from wrong-but-consistent narratives to stale assumptions, according to Braintrust. The practical problem is not just scoring quality, but governing state, side effects, and regression risk as agent workflows move into production.


At a glance

What this is: This is a Braintrust analysis of why stateful agents need trajectory-aware evaluation because their memory, tool use, and dependence on live systems create failures that single-turn prompts miss.

Why it matters: It matters because IAM, PAM, and NHI teams increasingly have to govern agents that hold context, act across systems, and leave state behind, which changes both access risk and validation practice.

By the numbers:

  • When AWS credentials are exposed publicly, attackers attempt access within an average of 17 minutes and as quickly as 9 minutes in some cases.

👉 Read Braintrust's guide to evaluating stateful agents


Context

Stateful agents are not just chat interfaces with memory. Once an agent can retain context, call tools, and act on live systems, the evaluation problem shifts from response quality to state governance, because the same prompt can lead to different paths, side effects, and end states depending on what happened earlier in the run.

For IAM and NHI practitioners, the interesting intersection is that these agents behave like privileged software entities with persistent context and external reach. That means access, authentication, and lifecycle controls matter even when the article is about evaluation rather than classic identity administration.

The starting point in this article is typical for teams moving from prototype testing to production agent operations: the limits of prompt replay become obvious only after agents start doing work in real environments.


Key questions

Q: How should security teams evaluate agents that change state across multiple steps?

A: They should test the full trajectory, not just the final response. That means logging every tool call, validating intermediate decisions, and checking the environment left behind after the task completes. A stateful agent can be wrong in ways that only emerge after several steps, so evaluation must cover path quality, side effects, and end state together.

Q: Why do stateful agents create more governance risk than stateless ones?

A: Because they can carry forward mistaken assumptions, stale context, and side effects into later steps. A stateless error is usually confined to a bad answer, but a stateful error can alter records, trigger actions, or lock the agent into a flawed path that looks coherent until the damage is already done.

Q: What do teams get wrong when they try to test agent memory with simple replay?

A: They assume the same prompt will produce the same meaningful test case. In practice, live systems change, intermediate state matters, and tool sequences vary. Replay misses the dependency on current state, so it cannot tell you whether the agent still behaves correctly when the environment has moved on.

Q: Who is accountable when a stateful agent creates an unsafe side effect?

A: The organisation operating the agent remains accountable, because the agent is acting as a governed software entity inside a controlled workflow. That makes ownership, logging, approval boundaries, and rollback capability part of the control model, not optional operational extras. If the agent can act, the programme must be able to explain and contain that action.


Technical breakdown

Why prompt replay fails for stateful agents

A prompt replay test assumes the model can be judged from a single input-output pair. Stateful agents break that assumption because each step modifies the working context, consumes external state, and changes what later actions are even possible. The evaluation surface is therefore a trajectory, not a turn. A good eval has to account for memory persistence, state drift in connected systems, and the fact that the same input can produce a different downstream chain when the environment has changed.

Practical implication: build evals around multi-step traces and state transitions, not isolated responses.

State, side effects, and external systems

Stateful agents become consequential when they create tickets, update records, send messages, deploy code, or provision resources. Those are side effects, not just outputs. Once side effects exist, a failure is no longer confined to a bad answer because the agent may have already changed an identity record, configuration, or workflow state. That is why evaluation must inspect both the action taken and the environment left behind. The control problem is less about correctness in the abstract and more about verifying that each action is authorised, reversible, and consistent with current system state.

Practical implication: validate both the action and the resulting system state before accepting an agent run.

Trajectory sensitivity and non-determinism

Trajectory sensitivity means early choices shape every later option. A stateful agent that selects one tool, record, or branch in step two can lock itself into a path that looks internally coherent but diverges from the intended task. Non-determinism makes this harder, because repeated runs can generate different tool sequences and different outcomes even when the task is unchanged. That is why outcome-only scoring is insufficient. Teams need explicit checkpoints for decision quality, path validity, and consistency against live policy and data conditions.

Practical implication: score decision points and final outcomes separately, then compare them across repeated runs.


NHI Mgmt Group analysis

Stateful agents are becoming privileged software identities, not just models with memory. Once an agent can hold context, call tools, and modify records, the governance question moves from prompt quality to control of persistent operational authority. That intersects directly with IAM and NHI because the agent is acting like a software identity with memory, permissions, and a lifecycle. Practitioners should treat these systems as governed entities, not transient interfaces.

Trajectory-aware evaluation is the right control model for agentic workflows. The article correctly shows that a single response score cannot capture whether the agent chose safe intermediate steps, preserved context correctly, or left state in a defensible condition. This is analogous to evaluating privilege use by session, not by static entitlement. The practical conclusion is that security teams need to judge action chains, not just outputs.

State corruption is a control gap, not just an engineering bug. When agent memory is stale, inconsistent, or overwritten by concurrent tasks, the failure mode is governance drift because the agent continues acting from invalid assumptions. In identity terms, that resembles an over-retained trust decision that outlives the state it depended on. The specific concept here is trajectory integrity: the requirement that an agent's decision path remain aligned with current state, policy, and intent. Practitioners should measure whether the agent can preserve that integrity under change.

Resettable environments matter because state is part of the security boundary. Braintrust's point that evals need real enough systems but also reproducible reset conditions maps neatly to identity governance problems. If the environment cannot be restored cleanly, regression testing becomes unreliable and access-side effects leak across runs. That means evaluation infrastructure needs the same discipline as production control planes: explicit state, bounded scope, and auditable rollback.

What this signals

Stateful agent programmes will push security teams toward trace-first governance, because the relevant evidence is no longer a prompt but a sequence of decisions and side effects. That makes agent observability, rollback, and state reset capabilities part of the control surface rather than debugging conveniences.

Trajectory integrity: the useful question is not whether an agent can answer correctly once, but whether it can preserve alignment with current state across an entire work session. That is where identity governance, operational controls, and evaluation design meet, especially when the agent has access to tools that can alter records or provision resources.

For identity teams, the practical signal is that agent-connected credentials should be managed like other privileged non-human identities, with tight scoping and clear offboarding. The lifecycle problem is visible in the NHI Lifecycle Management Guide, and the same discipline now applies to stateful agents that outlive a single prompt.


For practitioners

  • Instrument every agent step as a trace span Capture tool calls, intermediate outputs, metadata, and the before-and-after state of any record the agent touches. That gives you evidence for why a trajectory succeeded or failed, instead of relying on a final answer alone.
  • Promote real failures into regression datasets Convert bad traces from production into versioned eval cases so the next release is tested against the same failure mode. Prioritise cases where the agent took a harmful but plausible path, not just cases where it answered incorrectly.
  • Separate step scoring from end-to-end scoring Use span-level checks for tool choice and argument quality, then add trace-level checks for task completion and final environment state. This exposes agents that arrive at the right outcome through the wrong and potentially unsafe route.
  • Make the eval environment resettable Reset any stateful dependency between runs so one test cannot contaminate the next. That includes databases, ticketing systems, policy engines, and any mock or live service the agent relies on.
  • Control access to agent-connected systems Treat the agent's tool credentials like privileged non-human identities. Scope them tightly, review them regularly, and remove access paths the agent does not need for the evaluated workflow.

Key takeaways

  • Stateful agents cannot be judged safely by single-turn replay because their behaviour depends on memory, live systems, and step order.
  • The security issue is not only accuracy, but whether the agent leaves the right state behind after it acts.
  • Trace-based evals, resettable environments, and privileged access controls are now part of agent governance, not optional testing extras.

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 OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-53 Rev 5 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10NHI-03Stateful agent memory and action chains create agentic access and tool-use risk.
OWASP Non-Human Identity Top 10NHI-03The article's core issue is persistent non-human identity behaviour and lifecycle control.
NIST CSF 2.0PR.AC-4Access and privilege governance are central when agents can act across live systems.
NIST SP 800-53 Rev 5AU-2Trace logging and evidence capture are essential to validating agent trajectories.
NIST Zero Trust (SP 800-207)Continuous verification fits agents whose trust must be re-established each step.

Map agent permissions to least-privilege access and review them as part of change control.


Key terms

  • Stateful Agent: An AI system that preserves context across multiple steps, retries, or sessions instead of answering in a single pass. The state can include tool outputs, task history, and intermediate decisions, which makes the agent more capable but also much harder to audit and secure.
  • Trajectory: A trajectory is the full sequence of actions, tool calls, intermediate decisions, and recoveries an agent takes to complete a task. It is the right unit of analysis for long-horizon agents because the final output alone does not reveal whether the work followed an acceptable path.
  • Trajectory Integrity: The degree to which an agent's decision path remains aligned with current state, policy, and intended task objective. It is a useful governance concept for stateful agents because memory drift, stale assumptions, or corrupt state can produce internally coherent but unsafe outcomes.
  • Side Effect: Any change an agent makes to an external system, such as creating a ticket, updating a database row, sending a message, or provisioning access. Side effects turn evaluation into a control problem because a bad decision can alter the environment before the error is detected.

What's in the full article

Braintrust's full blog post covers the operational detail this post intentionally leaves for the source:

  • Trace instrumentation examples for LLM calls, tool invocations, and application-layer spans
  • Dataset pipeline patterns for turning production failures into versioned regression cases
  • Span-level and trace-level scorer examples for step validation and end-to-end outcome checks
  • CI integration details for blocking regressions before agent changes ship

👉 Braintrust's full post covers trace capture, dataset promotion, and scoring workflows in more operational detail.

Deepen your knowledge

The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, identity lifecycle, secrets management, and workload identity. It gives practitioners a practical way to connect privileged software behaviour to the controls their programme already owns.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 19, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org