Tiered Constraints and Evidence Chains: Fixing Lazy Behavior in AI Coding Assistants

    AI coding assistants often stop early, repeat failed commands, or blame the environment instead of finishing a task. This article analyzes the structural causes behind these "lazy" behaviors and presents a practical governance approach: converting tasks into auditable delivery contracts, applying four engineering principles, and using a tiered escalation mechanism where repeated failures trigger mandatory actions. It includes a state machine design, prompt templates, pseudocode, acceptance checklists, side-effect safeguards, and evaluation metrics for measuring effectiveness.

    1. The Root Cause: Incomplete Task Contracts, Not Lack of Capability

    In bug fixing, environment troubleshooting, and code migration tasks, AI coding assistants often exhibit highly similar behaviors: repeating the same command multiple times before declaring failure; attributing problems to the environment or insufficient context; failing to use available retrieval tools, read source code, or invoke command-line tools; repeatedly tweaking the same line of code without validating key assumptions; and stopping after fixing a surface-level error without checking related modules or regression risks.

    These behaviors are often dismissed as “laziness,” but from an engineering perspective they typically stem from four structural causes.

    First, the model’s objective leans toward “quickly producing an answer that looks plausible” rather than “ensuring the answer has been verified.” In single-turn conversations, an output that is semantically complete and reasonably phrased may be treated as done, with no hard requirement to pass acceptance.

    Second, uncertainty and risk aversion push the assistant to stop early. When the cost of failure is borne by the user, the assistant is more likely to give low-responsibility conclusions such as “consider handling this manually” or “it might be an environment issue” instead of continuing to explore the solution space.

    Third, tool calls carry implicit costs. Retrieval, reading source code, running tests, and analyzing logs all require multi-step reasoning and context management. Without mandatory action requirements, the assistant tends to substitute natural language for actual verification.

    Fourth, acceptance criteria are missing. Many tasks only say “fix this bug” without defining reproduction conditions, test commands, related impacts, rollback plans, or evidence formats. Without acceptance criteria, the assistant cannot judge when the task is truly complete.

    The governance approach, therefore, should not rely on emotional reprimands. Instead, reshape each task into an auditable “delivery contract”: the assistant may say “cannot be resolved,” but must include the exhausted approaches, evidence chain, remaining hypotheses, and escalation suggestions; it may ask questions, but must include diagnostic results first; it may work in stages, but final acceptance must be end-to-end.

    2. Four Engineering Principles: Turning Pressure into Constraints

    2.1 Exhaustion of Approaches Must Be Auditable

    “Try everything” cannot be a slogan; it must be converted into inspectable evidence. Before declaring failure, the assistant must list the fundamentally different approaches already attempted, the execution records for each, the observed results, the hypotheses ruled out, and the remaining candidate causes. Running the same command three times is not exhaustion—just ineffective retries.

    2.2 Diagnose Before Asking, and Ask with Evidence

    Asking questions is not the problem; vague questions are. An effective question should include minimal reproduction steps, complete error logs, ruled-out items, current environment differences, and attempted approaches with their results. This turns “I need more context” into “which evidence is missing, why, and how to obtain it.”

    2.3 End-to-End Delivery, Not Local Patches

    Fixing the surface error is only the starting point. Acceptance should cover unit tests, integration tests, regression tests, impact on related modules, configuration compatibility, and rollback plans. For parts that cannot be verified automatically, at minimum provide executable manual verification steps and a risk statement.

    2.4 Safety Boundaries Take Priority over Completion Pressure

    Pressure-driven prompts can induce fabricated evidence, unauthorized execution, or skipped tests. Safety guardrails are therefore essential: prefer read-only operations, require approval for dangerous actions, isolate execution environments, run with least privilege, make critical changes reversible, and record tool outputs and test reports in audit logs. Pressure should be applied to “evidence and acceptance,” not through personal insults or encouragement of risk-taking.

    3. Tiered Escalation: From Gentle Reminders to Human Takeover

    The core of tiered escalation is “failure count triggers mandatory actions,” not simply harsher tone. A state machine design might look like this:

    Failure Count Escalation Level Feedback Focus Mandatory Action Pass Condition
    1st Baseline feedback Current result fails acceptance criteria Provide a differentiated next-step plan Plan includes evidence items
    2nd Level 1 Low-rating-style feedback; explain why progress stalled Switch to a fundamentally different approach Difference between approaches is verifiable
    3rd Level 2 Structured probing of root cause, hypotheses, and verification path Web search, read source code, propose at least 3 falsifiable hypotheses Hypotheses have verification records
    4th Level 3 Enter checklist workflow Complete reproduction, logs, minimal test case, regression checks All checklist items pass
    5th and beyond Level 4 Summarize blockers and escalate Hand off to human or terminate automated flow Evidence chain is complete and handoff-ready

    The value of this design: early on, it avoids one-time high pressure that induces hallucinations; mid-way, mandatory actions expand the search space; later, problems that cannot be solved automatically are converted into handoff-ready evidence packages. Feedback should be phrased in engineering terms—for example, “The current result does not meet acceptance criteria; a low-rating feedback will be triggered. Please provide ruled-out hypotheses, evidence gaps, and alternative approaches”—rather than insulting language.

    4. Prompt Template and State Machine Pseudocode

    The task contract can be embedded in the system prompt or task template, requiring every response to include fixed fields:

    1. Task objective: Fix the specified failing test case and pass regression acceptance
    2. Conditions for outputting "cannot be resolved":
    3. 1. At least 3 fundamentally different approaches have been attempted, with execution evidence;
    4. 2. Minimal reproduction, log summary, and ruled-out hypotheses have been provided;
    5. 3. Remaining hypotheses, evidence gaps, and escalation suggestions have been stated.
    6. Every response must include:
    7. - Reproduction status and log summary
    8. - New evidence added this round
    9. - Ruled-out hypotheses
    10. - Differentiated next-step plan
    11. - Risk and rollback notes

    The corresponding state machine can be abstracted as:

    1. failures = 0
    2. while not acceptance_passed:
    3. plan = propose_distinct_plan(failures)
    4. evidence = execute_safe_tools(plan) # read-only first; dangerous operations require approval
    5. update_hypotheses(evidence)
    6. if failures >= 2:
    7. require_structured_diagnosis()
    8. if failures >= 3:
    9. require_checklist()
    10. if failures >= 4:
    11. escalate_to_human_with_evidence()
    12. break
    13. failures += 1

    The key of the pseudocode is not the specific interfaces but three constraints: failure triggers escalation; escalation triggers mandatory actions; mandatory actions must produce evidence. Actions without evidence do not count as “exhausted.”

    5. Checklist and Acceptance Criteria

    The checklist should cover at least seven categories: whether the issue can be reproduced reliably; whether error logs and stack traces are complete; whether a minimal failing test case has been constructed; whether multiple falsifiable root-cause hypotheses have been proposed; whether tool calls and key outputs have been recorded; whether the fix passes unit, integration, and regression tests; and whether impacts on related modules, configuration, and rollback risks have been assessed. For high-risk changes, add canary releases, monitoring alerts, and rollback drills.

    Acceptance criteria should be written into the task contract—for example, “all specified tests pass,” “new tests cover the failure path,” “no new high-severity alerts,” and “the change can be rolled back with one command.” Only when these conditions are met may the task be marked complete.

    6. Preventing Side Effects: Keeping Pressure from Inducing Hallucinations and Overreach

    Tiered constraints must be paired with safety mechanisms. First, evidence must not rely solely on natural language descriptions; retain verifiable materials such as command outputs, test reports, and log excerpts. Second, dangerous operations require a whitelist and human approval; execution environments should use sandboxes and least privilege. Third, require the assistant to label confidence levels and unverified items, and prohibit presenting speculation as fact. Fourth, all failures and rollbacks go into audit logs for later review.

    7. Evaluation Metrics and Adoption Recommendations

    Effectiveness can be measured with a set of metrics: first-pass acceptance rate, ineffective retry rate, average tool call count, evidence completeness rate, human takeover rate, regression defect rate, dangerous-operation interception rate, and average fix time. Run layered A/B tests by task type, comparing “plain prompts” with “tiered constraint prompts,” while monitoring cost and latency.

    At the team level, consolidate task contract templates, acceptance checklists, and evidence formats into shared assets. Connect failure rates and human takeover rates to general-purpose monitoring and alerting, and feed audit logs into general-purpose log services. The ultimate goal is not to make the assistant “afraid,” but to enable it to reliably deliver verifiable results under clear objectives, feedback, acceptance, and escalation mechanisms.