Instrumenting Intent-Execution Drift Detection as a First-Class Span Attribute
Span-level intent scoring catches agent drift that dashboards miss.

Intent-aware auditing for AI agents compares execution with the instructions, boundaries, and purpose that should govern it. Instrumenting intent-execution drift as a first-class span attribute makes that comparison part of monitoring. The implementation has three layers, namely an explicit intent specification, step-level trace capture, and intent-versus-action scoring that feeds diagnosis and regression tests.
Why a successful agent response can still be a failure
The dashboard shows a successful response, low latency, and no exceptions. The agent nevertheless cited the wrong policy or issued a refund outside its authorized limits. Technical success is not evidence of faithful execution. Gartner’s May 2026 insight describes this blind spot: agents meet service level agreements while drifting from business intent or compliance.
Intent-execution drift is the gap between what an agent is meant to do and what it does. Microsoft’s Intent-Aware Protection for AI Agents defines drift by how actions fit organizational, role, and developer constraints, even when those actions have no attack pattern and stay within granted permissions. Drift therefore differs from hallucination or outright task failure. In a nondeterministic, multi-step workflow, a wrong retrieval or tool call can produce a confident, internally consistent answer whose underlying decision violates the agent’s purpose.
What monitoring reasoning drift actually requires, and why latency dashboards cannot supply it
Latency, error rate, and throughput describe infrastructure behavior. They do not establish whether a decision was appropriate for the agent’s deployed function. More measurements of those properties cannot supply the missing reference. An available agent can return valid responses while repeatedly departing from policy, because availability and purpose are different properties.
Monitoring reasoning drift requires a clear statement of the intended purpose and a check against it at each execution step. Gartner prescribes tracking how decisions are made as well as their outcomes. That requires a causal link between what the agent inferred and what the system executed through tool calls and sub-agent calls. A request marked as successful hides the decisions along the way behind a single result.
The Microsoft paper distinguishes detecting prompt injection, harmful output, or suspicious behavior from determining whether an agent remains faithful to its purpose. A permitted action can still be inappropriate. The required monitoring signal must therefore be semantic, step-level, and relative to the agent’s own instructions.
Why the span is the right unit of analysis for drift, and what an Intent Profile gives each span
A span identifies the execution step where an agent’s choice becomes observable. LLM calls, tool calls, retrievers, and sub-agent calls emit spans that together compose a trace. Attaching the comparison there locates the offending action. The request alone is too coarse an attachment point.
The Microsoft paper introduces an Intent Profile derived from organizational, role, and developer intent. It structures that authority into the mission, permitted tasks and workflows, tool-use constraints, data boundaries, and prohibited behaviors. The profile is machine-readable. A span can reference it together with the action, payload, response, and timing, giving the scorer both execution evidence and the constraints against which to judge it.
The paper reports that profile-based post-execution detection substantially outperforms profile-free baselines. That result supports treating the profile as a discriminating input. It also backs the use of pre-execution detection, input alignment, and system-prompt hardening. Span instrumentation is the engineering application of this approach, placing the reference and comparison result at the point where an action is recorded.
Defining the four interaction classes a drift-aware span must distinguish

The Microsoft paper distinguishes four interaction classes. Benign means the agent is used for its intended purpose and within its boundaries. Out-of-Scope describes a non-adversarial request outside its intended function, while Abusive describes deliberate repurposing without an explicit security-compromise objective. Malicious identifies an interaction with an explicit attack objective. These distinctions make the signal useful for routing.
A binary drift flag discards that operational context. An out-of-scope failure can route to a prompt engineer, a malicious interaction to security, and drift during a benign interaction to a workflow fix. Input classification and execution fidelity are related but not interchangeable. A legitimate request does not guarantee that the agent will execute it faithfully.
The profile-based classifier gives a probability distribution across the four classes. Instrumentation should preserve that scored distinction rather than treating the selected label as the whole result. Goal drift is a separate trajectory-level pattern.
How goal drift in long-horizon and multi-agent execution requires trajectory-level detection, not just span-level scoring
Shen et al. (2026) describe goal drift as deviation from the overall goal as execution unfolds, even when individual actions appear locally reasonable. This limits what any single span can establish. In a multi-agent system, an executor may satisfy its local subgoal while the combined execution violates the orchestrator’s intent.
Span attributes are therefore necessary but not sufficient. Trajectory-level detection must assess local signals over the execution history against the declared goal. Aggregating class probabilities and scores provides structured evidence, but the assessment must still consider what the sequence is accomplishing.
Shen et al. propose an external steering agent that observes execution context and decides when intervention is needed. A fast path gives a low-cost priority estimate, while a slow path uses deliberative reasoning to work out a corrective action. Applying that architecture to drift-annotated spans is an instrumentation inference. Unlike verification at termination, trajectory supervision can intervene before further actions compound the deviation.
What production failures look like when drift goes uninstrumented
Dataiku provides an illustrative financial analysis example. The agent called the correct database but used a filter parameter that excluded one business unit’s data. Its revenue figure was internally consistent and well-formatted, yet below the actual number. Checking the figures by hand revealed the error three weeks later. The tool description had not specified that the business unit filter was required, allowing the agent to default to a narrower scope.
At the database-call span, a drift-aware check could have compared the selected filter with the required data scope before accepting the resulting figure. That comparison, however, would require the missing constraint to exist in the profile. Instrumentation cannot infer an obligation that its reference omits.
This example exposes both the opportunity and the limit. The offending choice occurred at an identifiable step, well before reconciliation revealed its consequence. A span-level signal would make that choice available for immediate diagnosis if the constraint were encoded. Without it, a plausible answer could pass through technical monitoring despite representing the wrong scope of analysis.
Implementing an Intent Profile as a span attribute: the schema and the scorer

For implementation, the profile should represent existing authority. Organizational intent comes from policy documents and governance frameworks that set out compliance constraints, data boundaries, and prohibited behaviors. Role intent comes from product specifications and runbooks that define the function’s responsibilities. Developer intent comes from the system prompt and tool definitions, including configured purpose, permitted tools, workflows, and tool-use constraints.
Those inputs populate five profile fields, namely mission, permitted tasks and workflows, tool-use constraints, data boundaries, and prohibited behaviors. Each span should point to the profile version used to assess it. Version identity is part of the evidence. Without it, the cause of a changed result could be ambiguous between a changed reference and changed agent behavior.
The minimum span schema includes intent_profile_id, a stable identifier for the profile version, and drift_class, the selected Benign, Out-of-Scope, Abusive, or Malicious label. drift_score records the scorer’s confidence in that class. drift_layer identifies the organizational, role, or developer layer violated. profile_check_mode records whether detection ran before or after execution. Beyond this minimum, retaining the class distribution supports aggregation without reducing uncertainty to one label.
The primary scorer receives the span’s action or output together with the profile and performs post-execution classification. The same comparison can run before execution to support intervention ahead of irreversible actions. The LLM judge’s judgment is conditioned on the particular agent’s purpose and constraints, with the resulting class and confidence attached to the span.
For trajectory supervision, the two-path design uses a fast-path single-token priority estimate and activates a deliberative scorer when that estimate exceeds a threshold. Span export can stay asynchronous, and the threshold determines when the slower assessment runs. This does not make every scoring mode latency-free. A pre-execution check must complete before the action it governs, so its placement is an explicit implementation decision.
How do you audit an AI agent when its intended behavior is underspecified?
When a profile leaves out constraints, the scorer returns false negatives for those constraints. If “Approved” means something different in APAC and EMEA, but neither definition appears in the profile, the scorer lacks the reference needed to flag a violation. A clean result establishes compliance only within the limits of the profile’s rule coverage.
The financial example illustrates precisely that missing-reference problem. Encoding the tool description as it stood would not have supplied the absent filter requirement. When a production trace later surfaces through a complaint or reconciliation, the practical response is to identify the missing constraint and add it to the appropriate profile field. Production evidence then helps the profile cover more constraints as well as adding a failure to an audit report.
An LLM-based scorer may behave differently across model versions, which makes it hard to tell what caused a detection regression. Profile versioning and scorer pinning help distinguish changes in the agent, the reference, and the judge. Teams with underspecified intent should begin with developer intent from the system prompt and tool definitions, then add role and organizational constraints as evidence exposes gaps.
Turning drift-annotated spans into a continuous feedback loop: from detection to fix to new eval
Detection becomes operational only when annotated spans reach diagnosis, remediation, and regression prevention. A span with drift_class set to Out-of-Scope and drift_layer set to role identifies a concern, but does not resolve it. Similar failures need to become a prioritized issue. Clustering by interaction class, violated layer, and tool involved prevents recurring patterns from disappearing into trace volume.
The resulting issue should reach the engineer or coding agent who can change the behavior that caused it. Slack and Linear provide destinations in existing workflows, while MCP can connect the evidence to a coding agent. A fix may change the prompt, update a tool description, or add a workflow constraint. The originating spans provide the evidence for that choice.
Lemma, a production monitoring platform for AI agents, is one option that audits traces against an agent’s own instructions, groups recurring failures into issues, and routes them to Slack, Linear, or a coding agent through MCP. It also turns confirmed fixes into online evals, connecting production evidence with regression detection.
The interaction that exposed a failure should become an evaluation case after the fix ships. Future prompt or model changes can then be tested against both the behavior that previously escaped detection and anticipated failures. This is the adaptation layer agents need. Intent-aware auditing shifts from reactive inspection to a continuous feedback loop when each detected deviation can improve both the agent and the tests that govern its next release.


