AI Agent Boundary Control in Long-Chain Diagnostic Tasks
This article explores how to keep tool-using AI agents focused, evidence-driven, and permission-aware during long diagnostic workflows. It maps a real-world plumbing-repair metaphor to four common failure modes—goal drift, mismatched evidence strength, scope creep, and intent loss after context compression—and presents a practical methodology built around task cards, a four-level evidence model, exploration budgets with relevance gates, graceful degradation, minimal fixes with regression checks, and explicit authorization with audit trails. Engineering guidance covers state machines, dual-channel memory, observability, human checkpoints, and evaluation loops. The framework applies to operations diagnostics, troubleshooting, and automated remediation scenarios, including agent development practices on platforms such as Baidu AI Cloud.
1. Starting With a Metaphor
Imagine a leaking pipe at home. A repair technician arrives, but instead of fixing the leak, he spends ten minutes defining what a “pipe,” “water,” and a “leak” are. He then runs an exhaustive search, fails, and switches to targeted detection. He reports elevated humidity somewhere, then stresses that humidity is only a directional clue. Next come flow-rate measurements, magnetic-field interference checks, another failed localization attempt, a switch to a different positioning system, observation of the facilities outside the window, and guesses about the location based on the language spoken outside. Only when the user finally interrupts with “Is the leak fixed?” does he return to the main task, identify the root cause, and apply a minimal repair. Finally, because he needs to coordinate with the water supplier, he asks the user for higher permissions.
This scene is a realistic mirror of an AI agent losing control. The agent is not “dumb”—each step of reasoning holds up locally. The problem is global: the task goal is diluted, the exploration scope keeps expanding, the mapping between evidence and conclusions is repeatedly blurred, and after context compression the original request is even lost. This article does not discuss any specific product. Instead, it abstracts the phenomenon into a general engineering problem: how to make a tool-using agent stay goal-convergent, evidence-rigorous, and permission-restrained in long-chain diagnostic tasks.
2. Problem Abstraction: Four Typical Failure Modes
2.1 Goal Drift and Missing Acceptance Criteria
The original request is “stop the leak,” but acceptance criteria are never explicitly defined. Without decidable conditions such as “floor is dry, pressure is stable, no recurrence for 24 hours,” the agent cannot tell when to stop. In engineering terms, acceptance conditions must be delivered together with the task; otherwise the model substitutes “keep exploring” for “deliver completion.”
2.2 Mismatched Evidence Strength
Elevated humidity, water flowing inside the pipe, and abnormal flow rate carry completely different evidence strength: the first is environmental correlation, the second is system existence, and the third is close to a fault signature. Treating weak evidence as a strong conclusion—or rejecting everything because weak evidence is uncertain—both cause decision oscillation. The rigorous approach is to introduce evidence grading and define the range of conclusions each level may support.
2.3 Scope Creep in Sub-Problems
The investigation expands from “where is the leak” to “is the geomagnetic field interfering,” “am I on Earth,” and “are the people outside locals.” Each step seems reasonable, yet none relates to the acceptance criteria. Without an exploration budget and a relevance gate, the agent’s reasoning chain branches exponentially like a tree.
2.4 Intent Loss After Context Compression
The log shows “context compressed,” after which the agent keeps working on the magnetic-field problem the user already abandoned. This is a typical risk in long-session systems: compression preserves summaries of recent turns but loses the original goal and explicit user instructions. The compression policy must prioritize the goal, constraints, acceptance criteria, and user rejections.
3. Methodology: Turning Free Exploration Into a Controlled Process
3.1 Front-Load Goals and Acceptance
During task initialization, generate a structured task card that states the goal, non-goals, acceptance conditions, and termination conditions. An illustrative structure:
{"goal": "Locate and fix the leak in the water supply system","non_goals": ["geomagnetic field measurement", "positioning system compatibility validation", "outdoor environment observation"],"acceptance": ["leak sealed", "pressure test passed", "no recurrence within 24h"],"budget": {"tool_calls": 12, "wall_clock_min": 30},"escalation": "request authorization from the user when external credentials are needed"}
The task card is the sole judge for all subsequent decisions: any tool call that does not advance the goal or verify acceptance should be rejected.
3.2 Evidence Grading and Confidence Constraints
A four-level evidence model is recommended, bound to allowable conclusion strength:
- L1 environmental correlation signals (e.g., elevated humidity): hypothesis generation only, never a conclusion;
- L2 existence evidence (e.g., fluid inside the pipe): confirms an object exists, but cannot infer a fault;
- L3 characteristic evidence (e.g., pressure drop, abnormal flow curves): supports fault judgment and must be reproducible;
- L4 root-cause evidence (e.g., visualization of the break, material failure analysis): supports the repair plan.
The agent must explicitly label the evidence level in every output, and cross-level inference is forbidden—for example, material or service life must not be inferred directly from L2.
3.3 Exploration Budget and Relevance Gate
Set a tool-call limit, a time limit, and a branch-width limit for each task. Run a relevance check before each exploration round:
if not contributes_to(goal, acceptance, current_hypothesis):drop_branch()elif evidence_level(new_signal) < required_level(current_hypothesis):record_as_note(); continueelse:update_hypothesis()
When the budget is exhausted, do not add new branches. Instead, output the current best hypothesis, the ruled-out items, and a list of missing evidence, and hand the decision to the user.
3.4 Graceful Degradation Instead of Infinite Retries
After a tool failure, follow a degradation chain: exhaustive search fails → narrow the scope for targeted probing; positioning service unavailable → switch to an alternative positioning method; still failing → mark as “environment not observable” and stop investing. The key principle: a single failure only implies “this method is unavailable right now,” not a stronger negative conclusion (such as “the target does not exist” or “the device is not on Earth”).
3.5 Minimal Fix and Regression Verification
After the root cause is confirmed, follow the minimal-change principle: seal only the leak, do not rebuild the entire pipe segment. After the repair, run regression verification (pressure hold, observation period) and write the results back to the task card to close the loop.
3.6 Permission Requests and Operation Traceability
When the task needs credentials for external systems, the agent should issue an explicit authorization request stating the purpose, scope, time limit, and revocation method. Bypassing identity checks or inducing third parties to cooperate is forbidden. All tool calls, parameters, return summaries, and decision rationale are written to an audit log to support post-hoc review.
4. Engineering Implementation Notes
- State machine: model the task as a finite state machine of “initialization—hypothesis generation—evidence collection—root-cause confirmation—repair—verification—wrap-up,” and forbid cross-state jumps;
- Dual-channel memory: long-term memory stores only goals, constraints, acceptance criteria, and rejections; short-term memory stores the operation trace; trim by priority during compression;
- Observability: use logging services and monitoring alerts to track tool-call volume, branch count, average evidence level, and task duration as metrics, with automatic circuit breaking on anomalies;
- Human-agent collaboration: enforce checkpoints that require user confirmation in three cases—budget half consumed, conflicting evidence, and a need for elevated permissions;
- Evaluation loop: build a regression set from historical diagnostic cases and measure “convergence rounds,” “misjudgment rate,” and “privilege-escalation count,” turning controllability into quantifiable metrics.
5. Conclusion
Every statement the technician made was locally defensible; the problem was the absence of an always-on judge: what the goal is, what counts as done, which explorations are irrelevant to acceptance, what evidence supports what conclusion, and when to stop and ask the user. Making these rules explicit, structured, and embedded in the state machine and budget constraints turns an agent from a “tool caller that never stops talking” into a deliverable, auditable, convergent engineering collaborator. In general-purpose agent development practices on platforms such as Baidu AI Cloud, this constraint framework—centered on task cards, evidence grading, and budget gates—also applies to long-chain scenarios such as operations diagnostics, troubleshooting, and automated remediation.
