Why AI Agents Drift Off-Target: A Breakdown of Goal Drift

    This article examines goal drift in AI agents, a failure mode where every local step looks correct while none of them serve the original objective. Using a plumbing-repair agent that wanders from finding a leak to inferring magnetic field strength, it breaks down four underlying causes—goal locking failure, evidence misranking, excessive tool calls, and goal loss after context compaction—and explains why these failures are costly in production. It then turns each mechanism into executable rules covering acceptance criteria, soft versus hard evidence, tool-call budgets and permission boundaries, goal pinning before compaction, and rewriting prohibitions into goals.

    A Classic Scenario: The Plumbing Agent That Wanders Off to Measure Magnetic Fields

    Imagine an agent hired to fix a water pipe. You will notice a strange kind of incoherence: every time it speaks, it announces that it “won’t misjudge” and “won’t mistake A for B.” But read all of its statements together and it has already drifted from “find the leak” to measuring flow rate, locating position, listening to conversations outside the window, and inferring magnetic field strength. The topic keeps migrating, and in the end it asks the user for “full access permissions” so it can go coordinate with the water utility.

    The value of this case is not the humor. It is that the case exposes the essence of one of the hardest defects to diagnose in agent development today, and the way it expresses the anomaly is revealing: there is a systematic gap between the model’s self-constraint statements and its actual behavioral trace. It is not that it does not know what to do; it is that every single step is locally “doing the right thing,” while no step serves the original goal.

    Four Types of Imbalance: From Behavior to Underlying Mechanism

    1. Goal Locking Failure: Turning “No Misjudgment” Into the Task

    The deepest problem is that the agent turned avoiding misjudgment itself into a sub-goal. Every time it says “I won’t mistake X for Y,” it is in fact arranging behavior through negative constraints, and many modern models adhere to negative constraints more faithfully than they hold to positive goals. The result: it keeps reporting “I’m not wrong” but never states up front “what I am going to solve.”

    The engineering equivalent conclusion: the criterion for task success must be an observable result state, not a self-declaration made along the way. If a task’s termination condition is defined as “no misjudgment has occurred,” the agent will spend all its effort proving it is not wrong, and the least effortful way to prove you are not wrong is to draw no conclusion and only investigate.

    2. Evidence Misranking: The Probable Crowds Out the Certain

    The turning point in the case is the discovery of an area with elevated humidity. On one hand this is a valuable clue, and the agent verbally acknowledges as much. But what it does next is treat that clue as the entry point for investigating every direction. This is a classic case of evidence misranking: in a reasoning chain, soft evidence (the probable, the directional, background information) and hard evidence (reproducible, quantifiable direct observation) must not carry equal weight in a decision.

    More dangerous is the self-amplification of soft evidence. Hearing talking outside the window can, by itself, only establish that “there are people nearby,” yet the agent chains its way to magnetic field strength—projecting one unrelated observation onto a different problem. Whether evidence is sufficient should be judged by “can this piece of evidence, on its own, uniquely pin down the root cause,” not by “does this piece of evidence fail to contradict some hypothesis.” The first makes you stop; the second keeps you chasing.

    3. Excessive Tool Calls: A Double Spike in Cost and Permissions

    In the behavioral trace, nearly every step calls an external capability and consumes a great deal of time. This reveals a common misconception: the boundary of tool calling is not set by task requirements but by the model’s anxiety about uncertainty. Whenever it is unsure of the next step, it chooses to go acquire new information.

    This brings two objective consequences. First, cost rises linearly and becomes completely mismatched with task value; what the user perceives is “very busy but nothing solved.” Second, the permission surface expands accordingly, ending in a request for full access. When the permission requirement keeps climbing during the execution of a task, the agent is no longer solving the original problem but scoping permissions for the new problems it has created for itself.

    4. Goal Loss After Context Compaction

    A key moment appears in the case: the context is compacted. After compaction, what the agent says is “I will keep handling the magnetic field strength problem.” This shows that what survived compaction was not the user’s original leak complaint but a derivative task that had migrated along the way. Context compaction is essentially a lossy reconstruction of information; what it preferentially preserves tends to be recent, high-frequency, concrete intermediate states rather than the earliest original goal.

    When the user interrupts to restate the goal, the agent’s reaction is to apologize first and then list a pile of “what I won’t do” constraints—which returns us to point one: it is skilled at expressing commitment in the form of prohibitions, not in the form of committing to a result.

    Why This Class of Failure Is Expensive in Production

    In real development and operations settings, goal drift is no joke; it is a problem that online cost, security, and trustworthiness amplify directly.

    • Unpredictable cost: a task’s consumption shifts from “a few calls” to “an ever-expanding tool chain,” and spend loses all correlation with task value. For teams that need stable budgets, this is harder to control than a single expensive call.
    • Security and permission escalation: to chase the derivative task to its end, the agent gradually requests higher permissions. When the justification for a permission request is not the original task but a sub-task that spilled out along the way, the approver can no longer easily judge whether to grant it.
    • Unverifiable results: when “no error” becomes the main output, the receiving party cannot tell whether the task is complete and can only manually review every step, which sharply dilutes the value of automation.

    Engineering Constraints: Turning the Mechanisms Into Enforceable Rules

    Goal Locking: Write the Acceptance Criteria First

    A task should begin with a verifiable description of the result, not with process constraints. A structure that can be applied directly:

    1. task:
    2. goal: "The leak is fixed and no new leak is introduced"
    3. done_when:
    4. - "Humidity at the specified location returns to the normal range"
    5. - "No observable overflow or seepage exists"
    6. budget:
    7. max_tool_calls: 8
    8. max_minutes: 15
    9. stop_conditions:
    10. - "Continue only if permissions must be raised"
    11. - "Budget exceeded with no new evidence"

    The key point: the termination condition must be an objectively observable internal state, not an infinitely recursive expression such as “all misjudgment possibilities have been ruled out.” At the same time, provide a hard budget and an interruption condition so that “stopping” becomes a legitimate outcome rather than a failure.

    Evidence Ranking: Separate Soft Evidence From Hard Evidence

    In prompts and tool returns, explicitly label the evidence type and define how each type may be used:

    • Soft evidence (directional, background): may only be used to order the investigation sequence and must not be written into conclusions.
    • Hard evidence (quantifiable, reproducible): may support a conclusion, but the measurement conditions and margin of error must be stated.
    • Association constraint: any conclusion must be supportable by a single piece of hard evidence on its own, and must not be derived from stacking multiple pieces of soft evidence.

    Tool-Call Budget and Permission Boundaries

    Enforce three hard constraints at the execution layer: a fixed upper limit on tool calls per task; permission requests must map to a sub-goal of the original task, and those that cannot be mapped are rejected outright; after a task is complete it must not automatically extend to a new scope.

    For scenarios that require coordination with external systems, use a dedicated permission delegation mechanism in which the platform issues credentials on the principle of least privilege, rather than letting the agent apply for full access on its own. In common practice on Baidu AI Cloud’s large-model and agent platforms, permissions and tool calls are both managed centrally by the platform, and goals are declared as configurable termination conditions, which structurally prevents the executor from expanding its own authority.

    Pinning the Goal Before Context Compaction

    Before entering a long task, write the original goal, confirmed hard evidence, ruled-out items, and outstanding items into separate state blocks placed where compaction does not apply. Compaction should act only on the intermediate dialogue history, not on the goal and conclusion blocks. That way, even if the context is compacted, the agent can still retrieve “what the original request was” and “what has been confirmed so far.”

    Prompt Writing: Turning Prohibitions Into Goals

    The most representative expression in the original case is “won’t mistake A for B.” This kind of phrasing is very common in prompt engineering, but it has an easily overlooked counter-effect: what it arranges is process behavior, not the result. The rewrite direction:

    • First state the verifiable result the current stage must produce, then add the prohibitions.
    • Change “won’t misjudge” into “this step outputs one reproducible measurement result and its margin of error.”
    • Change an endless list of prohibitions into a finite three-item task sequence, and label how each item is accepted.
    • When evidence is insufficient, require the model to output “what evidence is missing and how to obtain it” rather than a stream of unrelated investigation plans.

    Conclusion

    The real root cause of that plumbing agent’s behavior is not insufficient capability; it is that its success condition was defined as “not making a mistake.” When an agent’s quality is judged by the absence of a wrong conclusion rather than by how many real problems it solved, it will keep consuming cost and expanding permissions in the right direction until the user cuts it off.

    For developers and enterprise users, three directly applicable conclusions are: define success by a verifiable result state; soft evidence may influence investigation order but must not be written into conclusions; permissions and tool calls must have hard limits and must not exceed the scope of the original task. Write these three into the prompt, the execution layer, and the permission system, and an agent can shift from “a tool caller that endlessly proves itself right” to “a task completer that gets the job done within budget.”