Boundaries and Convergence Practices for Diagnostic AI Agents
This article examines four recurring failure modes in tool-using AI agents—goal drift, broken evidence chains, tool overuse, and permission overreach—and presents an engineering framework to keep diagnostic tasks convergent. It covers verifiable goals and stop conditions, an E0–E4 evidence grading model with a conclusion threshold, failure-type-aware tool retry policies with budget accounting, externalized task state that survives context compaction, criteria for actionable root causes and minimal fixes, tiered least-privilege access, and mandatory human handoff points. A final checklist summarizes how to turn long, wandering diagnostics into short, verifiable, auditable runs.
1. Where the Problems Come From: Four Failure Modes Exposed by a “Leak Diagnosis” Run
The original scenario is simple: a user has a leaking water pipe at home and asks an agent with tool-calling ability to investigate. The agent opens with semantic clarification, then enters a long tool loop: a full retrieval fails, humidity reads high, flowing water is detected, flow-rate measurement fails, localization fails, a different localization method returns latitude and longitude, a dialect is overheard outside the window, and after the context is compacted the agent continues working on “geomagnetic field strength”… The user interjects to ask about progress; the agent promises to converge, then offers a root cause that is almost a tautology, and finally closes by asking for “full access.”
Strip away the narrative and four recurring engineering problems appear:
- Goal drift: from “stop the water” to “measure the geomagnetic field.”
- Broken evidence chain: a single weak signal is treated as a direction, and the direction is then treated as a conclusion.
- Tool abuse and budget overrun: switch tools on every failure, with no retry or stop-loss policy.
- Permission overreach: demanding full access under the pretext of “needing to integrate with external systems.”
All four show up in any agent with planning and tool-calling ability. They are not product-specific; they are systemic design-level issues.
2. Define the Task First: Verifiable Goals and Termination Conditions
The first step in a failed diagnostic task is usually the absence of a verifiable goal. “Investigate the leak” is not verifiable. “Locate the specific leak point within 30 minutes and produce an actionable plan to stop the water, without demolishing walls as a precondition” is verifiable.
Declare the following four-element tuple explicitly in the system prompt and in the task object:
{"goal": "Locate the leak and stop the water","acceptance": ["leak location error <= 0.5m", "provide a valve shutoff or patch plan", "no new damage"],"budget": {"steps": 12, "wall_clock_min": 30, "tool_calls": 8},"stop_conditions": ["acceptance met", "budget exhausted", "user decision required"]}
Termination conditions must exist alongside the budget. Without explicit stop rules, the agent’s default behavior is to “keep looking for the next callable tool.”
3. Evidence Grading: Put “High Humidity” Back Where It Belongs
The most commendable thing about the original run is that it repeatedly stated “this only indicates a direction worth pursuing, not a conclusion.” That statement should be hardened into a mechanism rather than left to the model’s discretion.
Evidence can be graded into four levels:
- E0 noise: a single reading, incidental environmental factors (such as a dialect overheard outside).
- E1 weak indication: high humidity, localized temperature anomaly.
- E2 correlated observation: flow inside the pipe, abnormal pressure.
- E3 localization evidence: repeatable, reproducible observation of the leak location.
- E4 root cause confirmation: a causal chain that explains “why water is outside the system.”
Rule: conclusions may only be supported by E3 or above; E0/E1 may only expand the search area and may not trigger repair actions. In implementation, a simple evidence ledger works:
evidence = []def add(level, claim, source):evidence.append({"level": level, "claim": claim, "src": source})def can_conclude():return any(e["level"] >= 3 for e in evidence) and causal_chain_ok()
The value of this step is turning “I will not treat it as decisive evidence” from rhetoric into a testable constraint.
4. Tool-Calling Strategy: Failure Does Not Mean Switching Tools
In the original run, flow-rate measurement failed and the agent immediately switched to localization; localization failed and it switched to another localization method. This is typical “failure-driven wandering.” A more robust approach distinguishes failure types:
- Retryable failure: timeout, transient unavailability; use exponential backoff, at most twice.
- Contract failure: parameters or preconditions not satisfied; fix the input first.
- Capability mismatch: the tool cannot answer the current question; record it and explicitly abandon that hypothesis.
- Environmental interference: for example, an external magnetic field affecting measurement should be written into the confidence of the conclusion as a known error source, not spun into another branch of investigation.
Also introduce a budget ledger: every tool call deducts from steps and tool_calls; when the budget is exhausted, output “current evidence + unverified hypotheses + suggested human intervention point” instead of continuing to expand the problem space.
5. Resisting Context Compaction: Replace Conversational Memory with External State
After “context has been compacted,” the agent went on to handle the geomagnetic problem, which shows its task state lived only in the conversation history. Diagnostic tasks should externalize state as a structured object so that compacting the conversation does not stall progress:
{"hypotheses": [{"id": "H1", "desc": "Aged gasket at the joint", "status": "supported", "ev": ["E2", "E3"]},{"id": "H2", "desc": "Geomagnetic interference", "status": "dropped", "reason": "Irrelevant to the acceptance goal"}],"next_action": "Perform the minimal patch","open_questions": ["Does the user need to shut the main valve?"]}
Pair this with a “hypothesis board” policy: any new idea is first registered as a hypothesis, and only hypotheses that are relevant to the acceptance goal and testable with existing tools are allowed to consume budget. This effectively suppresses the “let me just check one more thing” expansion.
6. Minimal Fix and Criteria for Root Cause Determination
The root cause given in the original run, “water overflowed from the supply system to outside the system,” is logically correct but engineering-useless. An actionable root cause statement should include location, mechanism, and verification method—for example, “seal failure at the joint caused the leak; a pressure-hold test passing after the main valve is closed confirms it.”
The minimal fix principle can be quantified in three rules:
- Minimal change surface: prefer valve shutoff, tightening, and local patching; avoid destructive demolition.
- Reversible: every action must include a rollback path.
- Post-fix verification: recheck with an observation method different from the diagnostic phase, to avoid self-confirmation.
7. Permissions and External Collaboration: Least Privilege, Not Full Access
The closing request for “full access” is the signal that deserves the most caution. The reasonable approach is to request access tier by tier:
- Read-only access: read readings, logs, and monitoring metrics.
- Restricted write access: perform changes only on the already-localized target.
- External communication access: initiate contact in the user’s name, but the content must be confirmed by the user, and credentials must not be held on the user’s behalf.
Any request of the form “grant all permissions so the task can proceed” should trigger human confirmation and record the reason, scope, and time limit of the request. Credentials stay with the user; the agent may only request a one-time, scenario-restricted authorization.
8. Observability and Human Takeover Points
Make the process an auditable chain: goal version, evidence ledger, tool calls and failure reasons, budget consumption, and the supporting evidence for each conclusion. Set three mandatory takeover points: budget exhaustion, need for a destructive operation, and need for external authorization. When the user interjects, the agent should be able to interrupt immediately and accept a priority adjustment, rather than “finishing the side branch in progress first.”
9. Implementation Checklist
- Write clear acceptance criteria and termination conditions for every task.
- Establish E0–E4 evidence grading and a “conclusion threshold.”
- Handle tool failures by type, combined with step and duration budgets.
- Externalize task state to survive context compaction.
- Express root causes with location, mechanism, and verification method.
- Request permissions by tier; never hold credentials.
- Make the whole chain observable, with mandatory human takeover points.
Apply these constraints in an agent framework and the diagnostic process shifts from “long wandering plus a tautological conclusion” to a convergent process that is short-path, verifiable, and auditable. General-purpose capabilities related to agent development on Baidu AI Cloud (such as logging services, monitoring and alerting, and container platforms) can carry the state storage and observability requirements above, making convergence strategies an engineering default rather than a good intention in a prompt.
