Building an Intent-First Audit Loop That Starts With the System Prompt Not the Span
Audit AI agent actions against the prompt that governed them.

Intent-aware auditing for AI agents checks each action against the instructions that applied to it, rather than taking a successful run as proof that the action was correct. Building an intent-first audit loop means anchoring every trace to the system prompt and tool manifest versions active during the run. That link lets reviewers distinguish an authorized decision from a silent deviation, then use the same evidence to detect regressions and guide repairs.
Why starting an audit loop at the span produces an incomplete record
A reviewer opens a span and sees a tool name, latency, token counts, a return value, and an HTTP 200. The record looks complete because the call succeeded. It answers an execution question. None of those fields establishes whether the agent was permitted to call that tool, whether its arguments respected the intended scope, or whether the call served the user's request.
WitnessAI identifies the limits of access logs that show a service account touching a system without preserving what the agent was asked, what the model returned, or which employee initiated the workflow. Traditional application logs also fail to connect the original user's intent to sub-tasks across tool calls. They can record an API call without the context for the decision, leaving it unclear whether agent logic or a user override led to the action.
Agent execution is non-deterministic, so the same prompt can produce a different sequence of actions on another run. So a later run that succeeds cannot prove that the earlier decision was correct. The historical record needs the instructions that governed the original action alongside evidence that the action completed.
What the system prompt actually is in an agentic system
The system prompt defines the agent's behavioral contract. It establishes the agent's persona, permissible tools, behavioral guardrails, and the scope of decisions it is authorized to make. Those boundaries govern which tool the agent should call, with which arguments, and in what order. Reviewing an action without them removes the standard against which the action must be judged.
A prompt change can therefore change what counts as correct behavior. Consider a refund tool allowed under prompt v2 but removed from the agent's authorized scope in v3. A call made under v3 might still succeed if the tool is still technically available. That success would not make the call authorized. Reviewing only the available tool or a current configuration would miss the contract that applied during the run.
The tool manifest supplies the contract's operational detail. It declares the tools the agent may invoke, their schemas, and their scope, so its historical version is necessary to evaluate a historical call. WitnessAI says the audit must record the system prompt version, tool manifest version, and model version in use during the run. These are release artifacts because changing them changes the context in which an action must be interpreted.
How silent failures exploit the gap between intent and execution
The difficult failure is often a completed workflow with the wrong outcome. A tool returns an unexpected schema, a partial payload, or an empty result from a timeout, and the model improvises around it. Execution continues without an exception or an anomalous span. The workflow can look healthy even when the agent has strayed from its instructions.
An agent that keeps calling the same tool or rereading the same document may use up resources without producing an error log. A final-output check can miss the repetition or a mismatch between the stated reasoning and the action taken. Similarly, retrieval may return plausible but stale or mis-scoped material. The individual call looks acceptable while the decision it supports is not.
Lost context can look much the same. Some frameworks silently truncate older messages, so the agent continues with only part of the picture. This is not universal API behavior. Modern APIs increasingly return explicit errors or require opt-in silent truncation, so the audit must tell apart what the framework does and what the model interface does.
These failures become interpretable when execution is compared with governing intent. WitnessAI connects unexpected, ambiguous, or manipulated model outputs to the OWASP “Excessive Agency” risk, where downstream actions can exceed intended boundaries before the final answer appears. The audit needs to preserve the contract and the intervening decisions, because the consequential deviation may already have occurred.
What a defensible audit record must contain to support intent-first review

A defensible audit record links actions to identity, intent, policy, approval, and execution outcome. These layers depend on one another. A tool result without an identity does not establish who authorized the workflow, while an approval without its argument scope does not establish what was approved. The record must also preserve the prompt delivered to the model, including the base prompt template, retrieved context, and injected content.
The identity layer identifies the agent, owner, user or subject, tenant, and delegation chain. Identity must not come from a model-generated claim. It must remain connected to the workflow across sub-agent handoffs so that delegated actions retain their authorization context. The intent layer then identifies the tool, version, action, normalized arguments, resource scope, and a redacted digest of sensitive values. Together, these layers establish the actor and the proposed action without treating the model's account as evidence of authority.
The policy decision layer records the policy identifier and version, risk tier, verdict, reason, and decision timestamp. Approval has its own evidence layer for high-impact actions. It records the approver, approval scope, argument digest, expiry, and any rejection or cancellation state. Keeping those details apart lets a reviewer check both the policy verdict and the human authorization that applies to the proposed arguments.
The execution outcome layer records attempt links, idempotency keys, start and end times, status, result metadata, error class, and verified downstream effects. It establishes what actually happened after the decision. Correlation IDs tie that evidence to the tool call and the prompt version that governed it, while explicit prompt and manifest identifiers keep a timestamp from standing in for the contract. A transcript cannot substitute for this runtime evidence because the model may request an action that policy blocks, omit a retry, misunderstand a result, or explain a failed call plausibly.
How to anchor each trace to the system prompt version that governed it
Implementation starts by treating the system prompt and tool manifest as versioned artifacts. Their identifiers belong in the trace at execution time. At the start of each run, the parent span records the system prompt version hash and tool manifest version identifier, together with the model version, session ID, and delegating user identity. This makes the governing contract explicit rather than asking a reviewer to infer it later from deployment times.
Child spans then preserve the phases of the agent loop. Prompt assembly records what was prepared for the model, while retrieval spans record queries and retrieved evidence, including document IDs and scores. Tool spans retain inputs, outputs, and correlation IDs. Model-call spans record the provider, tokens, latency, and cache hits, and further spans cover post-processing and safety checks. The hierarchy ties each phase back to the run's contract without flattening distinct decisions into one final result.
OpenTelemetry's GenAI semantic conventions provide a foundation for this structure by modeling an agent run as a parent span with child spans for model calls and tool invocations. Structure alone is not enough for intent review. Prompt-version and manifest-version fields must extend that foundation so that a reviewer can connect an action to its authorized scope. Capturing the input prompt and raw model output before post-processing also preserves what the model returned separately from what later stages presented.
AWS's enterprise agent architecture calls for agents to be “observable by default,” with traces emitted at each step and the trust and control framework present throughout the loop. Irreversible actions must pass through a human checkpoint before execution, while reversible steps with a low blast radius can auto-approve and log. In both cases, the audit records the approval decision and its basis.
Using prompt-version correlation to detect behavioral drift before users do
Without a version anchor, a change in tool-call patterns is difficult to attribute. The reviewer can see different behavior but cannot reliably connect it to a change in governing instructions. Once traces name the prompt versions, reviewers can use the same rubrics to compare runs under an updated prompt with runs under the one before it. The comparison examines behavior through tool choices, retrieval choices, and output characteristics.
Fewer calls to a removed tool may be expected, while continued calls under the new version may indicate a regression. The version anchor supplies that interpretation. Manifest and model versions preserve further context for the comparison, so the record does not silently treat every change in behavior as a prompt-only effect.
In practice, this means scoring samples of real traffic and tying rollouts to gates. Judge-model scoring can use the review rubrics, while traces keep the evidence for reviewers to check. If a change harms a critical slice, such as an enterprise tenant segment or workflow type, the rollout pauses for review. This is more specific than tracking aggregate execution health because a technically successful run can still fail the behavioral rubric.
A single drop in a score can raise a false-positive alarm. Grouping failures that happen in a row in the same category under a given prompt version gives triage a stronger basis than scattered low scores from unrelated runs. That grouping helps distinguish a one-off edge case from a systematic regression and directs reviewers to the affected contract and decision path.
Routing diagnosed failures from trace to fix using the audit record as context
A diagnosed failure already has much of the context needed for repair. The record identifies the governing prompt and manifest versions, the deviating call, and the behavior required by the contract. That applies whether the agent invoked an out-of-scope tool, used a deprecated argument schema, or produced output that violated a prompt policy. The repair workflow can therefore begin with a bounded discrepancy rather than an engineer reconstructing intent from partial logs.
That context package can be handed to a coding agent over MCP. MCP can expose prompt templates and tool schemas through its prompts and tools primitives, giving the coding agent the material needed to propose a prompt revision or schema correction. The proposal is not itself a verified repair. The same contract-based rubrics and trace comparisons used to diagnose the failure provide the basis for judging whether the changed behavior resolves it.
AWS describes an iterative architecture in which tool results inform subsequent decisions and audit entries preserve proposed actions, reasoning, and confidence scores. Those entries help with repair when they stay linked to trusted evidence of policy decisions and execution outcomes. A model's explanation provides useful context for the runtime evidence. Keeping that distinction intact prevents the repair workflow from accepting the agent's account in place of what the runtime recorded.
Escalation triggers should be expressed as thresholds. When a threshold is reached, the system halts before damage compounds, and the record preserves what was stopped and why. The repair workflow then starts from that evidence ahead of user complaints. Its completion criterion remains behavioral, whether the revised agent follows the applicable contract at the decision point where the earlier run deviated.


