Why AI Agents Drift Off-Track: A Framework for Verifiable Agent Diagnostics
This article uses a household water-leak repair scenario to expose four systemic failure modes in AI agent systems: goal drift, evidence misuse paired with over-caution, unbounded tool-chain expansion, and state loss after context compaction. It then shows how to convert an unverifiable request into an acceptance-ready engineering task with explicit scope, budgets, and stop rules; how to grade evidence so weak signals cannot drive conclusions; how to run a hypothesis ledger with disproof-first discipline; how to externalize state so compaction never drops the goal; and how to handle external dependencies as an explicit blocked state. A cloud implementation mapping and a final acceptance checklist are included.
1. One Scenario, Four Systemic Failures
Consider an everyday fault: a leaking water pipe at home. The agent the user hires opens as a “repair service” and looks professional at first, declaring that it must clarify the conceptual boundaries of “pipe,” “water,” and “leak.” Then it starts working for a long stretch, attaching “tool called, inspection executed” to every round. Ten rounds later, the scope has spread from abnormal humidity to flow-rate measurement, then to magnetic-field interference, positioning failures, satellite system differences, and accents outside the window. After the context is compacted, the topic settles on “continue processing geomagnetic field strength.” The user has to interrupt and ask whether the original problem is solved, and the answer is “confirm the root cause first, then apply a minimal fix” — where the so-called root cause is stated as “part of the water plant’s supply overflowing outside the distribution system.” That is a correct but engineering-worthless tautology. At the end, the service side is refused by the supply side for “insufficient credentials” and turns around to ask the user for credentials.
The technical content of this flow is not low: there are tool calls, command execution, multi-source sensing, and failure degradation. Yet it produces no user value. Abstracted as an execution log of an agent system, it yields four categories of problems.
The first is goal drift. The acceptance criteria were never explicitly defined, so every subtask that “looks like progress” can legitimize itself. The second is a mixture of evidence misuse and over-caution: on one hand, weakly correlated signals (high humidity, accents outside the window) are admitted as candidates; on the other, a large number of negative statements declare “this does not prove anything,” so the reasoning neither advances nor converges. The third is tool-chain divergence, with detection dimensions constantly multiplying and no budget or priority. The fourth is state loss after context compaction: compaction keeps only the most recent intent and discards the original goal and the already-excluded items, so the system returns to a long-irrelevant branch and keeps burning resources.
2. Translating “Fix the Pipe” into an Acceptance-Ready Engineering Problem
The first step of governance is rewriting the goal. The original task “fix the leak” is not verifiable and must be converted into a form with metrics, boundaries, and termination conditions:
task:goal: Eliminate visible leakage in the specified area and restore supply pressure to the normal rangein_scope: [visible indoor piping, joint seals, valve state]out_of_scope: [municipal supply scheduling, building structure, regional geology and magnetic environment]acceptance:- No new leak points for 30 consecutive minutes of visual and humidity re-measurement- Water consumption per unit time returns to baseline within ±5%budget:max_steps: 12max_tool_calls: 20wall_clock_minutes: 40stop_rules:- All acceptance criteria satisfied- Budget exhausted, output current conclusions and unverified items- An external dependency requiring user authorization appears
Three points matter: acceptance criteria are observable, scope is explicitly excluded, and budget plus stop rules are defined up front. With out_of_scope in place, issues like the geomagnetic field and satellite positioning are removed at the architecture level, rather than relying on the model to “restrain itself” round after round by declaring that it will not participate.
3. Evidence Grading: Give Weak Signals a Place, Not Authority
What drains patience most in this scenario is the volume of “I will not mistake A for B” declarations. Such self-constraint is a virtue in a single round and noise across many rounds. A better approach is to harden the constraints into a data structure, so evidence carries its own weight and the conclusions it is allowed to support:
E1 Direct observation: continuous dripping at the joint -> supports "a leak point exists"E2 Instrument reading: locally elevated humidity -> supports "worth investigating" only, weight 0.3E3 Environmental correlation: regional magnetic field, positioning deviation -> no causal link to the hypothesis, weight 0E4 Rumor-type: language characteristics outside the window -> excluded from the evidence set
The accompanying rules: evidence with weight 0 does not enter the reasoning chain and is not written into external reports; evidence below the threshold may only trigger “widen sampling” and cannot trigger “draw a conclusion.” This preserves exploration while avoiding dressing up weak correlation as insight. Reporting language also simplifies, from “I cannot determine” to “current evidence supports A with medium confidence; next step is to verify B.”
4. Hypothesis Ledger and Disproof First
The root of divergence is the absence of an explicit hypothesis set. Introducing a ledger that centrally manages all candidate causes, supporting evidence, disproof results, and current status turns troubleshooting into a convergent process rather than a random walk:
| Hypothesis | Supporting evidence | Disproof / exclusion basis | Status |
|---|---|---|---|
| Joint seal aging | Dripping at the joint | — | Pending |
| Valve not fully closed | High water consumption | Valve position feedback normal | Excluded |
| Upstream supply pressure fluctuation | Simultaneous leakage at multiple points | Pressure curve stable | Excluded |
| Regional environmental interference | None | No causal path to leakage | Out of scope |
Two disciplines are worth emphasizing. First, look for disproof before support, and prioritize low-cost tests for hypotheses that can be excluded in one shot. Second, the root cause must be written as an intervenable causal chain, not a restatement of the symptom. “Water overflows from the supply system” merely repeats “leak”; a real root cause should point to a specific component and failure mechanism, for example “aging of the joint seal causing pressure-bearing failure.”
5. Context Compaction Should Not Drop the Goal
In long tasks, context compaction is an inevitability. Engineering-wise, state should be externalized, and compaction should compress only the process narrative, not the goal and constraints. A minimal implementation is to maintain a persisted state file updated every round:
{"goal": "Eliminate visible indoor leakage","excluded": ["geomagnetic field", "satellite positioning", "municipal scheduling"],"hypotheses": [{"id":"H1","status":"pending"}],"evidence": [{"id":"E1","level":1}],"budget": {"steps_used": 7, "steps_max": 12},"next_action": "Re-measure joint humidity and run a pressure-hold test"}
If the compaction prompt keeps only a summary of this file plus the last three actions, the “return to an irrelevant branch after compaction” failure is avoided. The test is simple: after any compaction, the system’s next action must be traceable to goal and next_action.
6. Minimal Fix and Closed-Loop Verification
The repair stage follows the minimal-change principle: replace only the failed seal, do not rebuild the entire piping run; take one baseline sample before and after the change for comparison. Closed-loop verification must include a time dimension — a single visual pass is not a pass, and coverage of one complete usage cycle is required. If verification fails, return to the ledger instead of adding detection dimensions.
7. External Dependencies and Credential Boundaries
The “insufficient credentials” ending is actually the most commendable behavior: when the task needs external authorization, the correct move is to stop and tell the user what is needed and why, rather than trying to bypass the process. Engineering-wise, such cases should be modeled as an explicit state blocked with a structured request:
status: blockedreason: Authorization required for the supply-side operationrequired_from_user: Proof of account ownership, confirmation of the on-site time windowimpact_if_delayed: Leakage continues, water consumption stays high
8. Running This Framework on the Cloud
The mechanisms above map onto a general combination of cloud capabilities: task state and the hypothesis ledger persisted in object storage or a managed database; every tool call and evidence item written to a logging service to form an auditable trail; a message queue decoupling long-running detection tasks so the main flow is not blocked; monitoring and alerting with thresholds on step count, elapsed time, and tool-call count, triggering a convergence strategy once the budget is exceeded; and a container platform hosting a reproducible detection environment so the same check yields consistent results across rounds. Baidu AI Cloud typically handles this kind of scenario with the same general combination of “storage + logging + queue + monitoring + containers,” and the specific selection should still be based on your own load testing and compliance requirements.
9. Acceptance Checklist
- Is the goal written as observable metrics, with an explicit statement of what is not in scope?
- Is evidence graded, and are zero-weight items removed from the reasoning chain?
- Does a hypothesis ledger exist, and are low-cost disproofs executed first?
- Does the root cause point to an intervenable component rather than restating the symptom?
- Can the next action after compaction be traced back to the goal?
- Is the fix a minimal change, and does verification cover a complete cycle?
- Are external dependencies reported explicitly as a blocked state?
An agent’s real professionalism is not measured by how many “I will not misjudge” statements it makes, but by delivering a verifiable conclusion in fewer steps. Writing constraints into structure, state into storage, and budgets into configuration is what turns tool-calling capability into deterministic delivery.
