Reconstructing Agent Intent From System Prompt Snapshots When a Trace Tells You Nothing Useful
Read the prompt snapshot against the trace to find why agents misbehave.

Intent-aware auditing for AI agents compares behavior with the instructions that governed it alongside checking whether execution succeeded. When a trace records actions but no decision standard, the system prompt snapshot supplies the intended reasoning contract. Reconstructing agent intent requires reading that contract against the trace, locating the divergence, and turning the diagnosis into a targeted fix and a failure-derived eval.
Why a clean trace is not enough to understand what an agent intended
In May 2026, a support-triage agent ran for nine days while getting one ticket in fourteen wrong. Every infrastructure dashboard remained green. The failure surfaced only when a human in the refunds queue noticed mis-routed billing questions. The distinction was consequential because the agent kept completing work that did not satisfy its purpose.
A trace can record inputs, outputs, latency, and tool-call status without recording the standard that makes a choice right or wrong. An agent can route to the wrong queue or cite a hallucinated policy while producing HTTP 200, well-formed output, and acceptable latency. Nothing has failed at the infrastructure layer. A successful tool call may also use a stale schema, while a planning step may run correctly against the wrong subproblem. The execution sequence is visible, but its governing contract is absent.
That absence becomes harder to resolve when an error propagates. Incorrect information written to memory or a vector store can influence later reasoning even after its original source is corrected. A silent failure at step 3 can therefore cause a wrong result at step 10 without the result pointing back to its origin. The diagnostic cost is substantial. Observability failures took much longer to fix than tool-call failures with schema validation in place, because investigators had no clear standard for checking the path that seemed to have worked.
How do you audit AI agents against what they were supposed to do?
The system prompt is the agent’s reasoning contract. It specifies which goals take priority, which tools are in scope, which outputs are acceptable, and which paths are excluded.
The relationship resembles a contract in a dispute. Watching what a party did cannot establish whether it fulfilled its obligations without reading what it agreed to do. For an agent, intended decision logic defines when to route, escalate, refuse, or retry. Tool scope and permission boundaries define which calls are sanctioned and in what sequence. Output and policy constraints set rules for what answers can say, including rules that format validation alone cannot enforce.
A snapshot makes the model’s selected branch auditable against an explicit rule. This distinction keeps intent reconstruction precise. The investigator is recovering the standard under which the action should have occurred, rather than claiming access to the model’s thought process.
The snapshot must also belong to the execution under investigation. The prompt in the codebase today may differ from the prompt active when the failure occurred, so the latest revision cannot substitute for the historical artifact. A live session also falls short when the instructions have changed. The relevant contract is the one attached to the specific trace.
How prompt drift makes the snapshot you have different from the one that caused the failure
The March 2026 logistics routing case shows how a small dependency change can invalidate an otherwise familiar prompt. A downstream API renamed incident_count to num_incidents, and the agent silently made wrong decisions until a human noticed. The dependency had changed beneath the instructions. Checking for drift takes more than comparing prompt text, because the prompt also depends on tool definitions and data contracts.
Prompt drift is the gap between what a team believes is running and what actually governed an execution. Incremental edits in staging or a provider’s playground can remain outside version control, leaving instructions in environment variables or configuration files without a changelog. A/B variants can also remain active after a test ends. Traffic then keeps reaching versions that neither team is monitoring, so a diagnosis based on what seems to be the production prompt can be wrong.
Capturing the full context window preserves what the agent received, which is essential when retrieval supplied something different from what the team intended. Logging tool arguments before execution preserves the agent’s constructed request before the response complicates the comparison. Final outputs alone cannot recover either artifact.
Prompts need to be treated as deployable infrastructure, with versioning, traceability, and rollback capability. That discipline connects the instructions, their dependencies, and the execution being investigated. Without it, a careful reading can diagnose the wrong version with considerable precision. Snapshot identity must be established before textual interpretation begins.
Reading a system prompt snapshot systematically when a trace gives you no direction
A diagnostic reading begins with the observed failure and the clause that should govern it. For a mis-routed billing question, the relevant passage is the routing rule or escalation condition. This establishes the first comparison between obligation and action. If no clause covers the decision, the absence is already a finding. The agent operated in an unspecified region of the contract, which identifies a prompt gap.
Once the governing clause is located, the reading follows its consequences into tool scope. The investigator compares the tools sanctioned by the prompt with those called in the trace, including any required sequence. Successful execution does not establish permission to act. A call outside the allowed set breaks a boundary, while arguments the prompt does not account for may be a sign of schema drift. Sherlocks’ 2026 analysis found that tool-call and schema drift accounted for 31% of production agent failures, making this comparison a substantive diagnostic step.
The next comparison concerns the output produced by those actions. The prompt’s format requirements establish whether the answer has the expected shape, while its policy constraints establish whether the content is permissible. An output can pass format validation yet go over a refund cap, ignore a routing rule, or include a claim the rules forbid. A hallucinated policy must be checked against the stated rules for content, even when the response makes sense.
Only after those explicit obligations have been examined does the reading turn to omissions. This order prevents an investigator from calling something a prompt gap before checking whether an existing instruction was violated. Where the contract is silent, the agent may fill the gap with training-data priors.
The resulting diagnosis states what the prompt specified, what the trace showed, and whether the divergence concerns decision logic, tool scope, output constraints, or an uncovered scenario. That precision separates diagnosis from prompt rewriting. A repair can then target the identified gap instead of changing unrelated instructions in the hope that the failure disappears.
Where the reading breaks down in multi-step workflows with more than one prompt
In planner-worker and multi-agent architectures, the governing contract is distributed across prompts. A worker may do its assigned task while working against the planner’s broader goal, so following its own instructions does not prove that the workflow is correct. The worker’s trace can still look as though everything worked. Reading only that worker’s system prompt risks judging the last visible action while missing the upstream decision that made it wrong.
Partial results, intermediate context, and tool outputs can pass between agents as state and change what the next agent receives. The handoff payload becomes part of the investigation. A connected sequence of snapshots must therefore include both the sub-agent’s prompt and the context passed into it, rather than treating each agent as an independent execution.
Wrong context can lead an agent to construct incorrect arguments for the correct tool, after which the schema validates and execution succeeds. Sherlocks’ analysis found that retrieval failure was the upstream cause in 61% of multi-layer agent incidents. The visible tool call’s apparent correctness concealed the context error that shaped it.
The practical requirement is to reconstruct the full context window at each handoff and capture the payload connecting the agents. CrewAI v0.5 does not include built-in task handoff tracing, so emitting a span for each agent-to-agent handoff requires custom instrumentation, such as the opentelemetry-instrumentation-crewai package. Framework support cannot simply be assumed. When the defect originates upstream, the final agent’s system prompt may not be wrong at all. The investigation has selected the wrong snapshot as its starting point.
Grouping failures by pattern so a single snapshot illuminates a class of incidents, not just one
A missing clause or stale tool definition can affect many executions that follow the same contract. Once that defect is diagnosed, rereading the same prompt for every affected trace adds work without adding understanding. Grouping allows one snapshot diagnosis to explain a class of incidents and directs attention toward shared causes, including those that originate upstream.
The support-triage case’s consistent error rate pointed toward a recurring gap. Similar wrong outputs across traces can expose an ambiguous routing rule, an uncovered scenario, or a tool definition that has drifted. The pattern directs the next comparison of evidence. It does not, by itself, prove which clause is responsible.
Memory drift makes that comparison more difficult because contamination can outlive the interaction that introduced it. A single successful injection can affect later sessions without its original source being triggered again. Grouping must therefore account for propagated failures as well as repeated inputs. Otherwise, incidents with a shared origin can appear unrelated because they occur in different sessions.
Operational alerts are useful when they surface these patterns. Three consecutive failures in the same category provide a more actionable signal than isolated score drops, while sampling production traces and using an evaluator from a different model family reduces model-specific scoring blind spots. P0 triggers can include tasks that run longer than a duration threshold based on a percentile, more than five restarts in an hour, or an authentication error on a tool credential. These triggers start an investigation, which still has to be carried out. The useful handoff is the grouped issue with its specific prompt gap identified.
Closing the loop from snapshot diagnosis to fix to verified non-recurrence
The structured brief specifies what failed, the responsible prompt clause, the divergent tool call or output, and the intended fix. This limits the scope of the proposed change. Instead of rewriting a prompt from a vague complaint about unexpected behavior, the coding agent can propose a repair tied to evidence.
Repeated unsuccessful corrections require a different approach. Anthropic’s documented guidance is to clear the session after two failed corrections and write a better prompt incorporating what was learned. In this workflow, the snapshot diagnosis supplies that learning. A live session alone cannot show which instruction in use at the time, or which missing constraint, caused the production failure.
Verification then has to preserve the incident’s defining conditions. A trace-derived eval captures what actually happened and what the correct output would have been, rather than substituting a general assertion about desirable behavior. That makes the test specific to the exposed gap. The repair can be evaluated against the failure that motivated it, while checking that the change has not introduced a regression.
An online eval extends that check into subsequent operation. When the same failure mode returns after a prompt edit or model update, the failure-derived case provides a way to detect it. The snapshot begins as evidence of the original contract and becomes the basis for a test that guards the repaired boundary in later deployments.


