AI Coding Agent Selection and Harness Engineering

    Build a more stable AI coding workflow by treating models as replaceable dependencies and the agent harness as an engineering asset. This article covers output evaluation, harness architecture, model adapters, task-based routing, regression testing, and migration safeguards for maintaining measurable quality as model capabilities change.

    1. The Starting Point: Model Capabilities Fluctuate, but Switching Costs Are Low

    AI coding agents do not improve along a smooth curve. A product may be practically unusable early in the year, face quota constraints as adoption grows, and recover with a new release later on. Users respond directly: when output quality drops, they move their project directories, prompts, and configurations to another tool, often with very little migration effort.

    Two engineering realities matter here:

    1. Model capability is an external variable, not something your architecture controls. You cannot control upstream release schedules, quota policies, or quality fluctuations. You can control how quickly your workflow adapts.
    2. The deeper dependency is often the harness, not the model. Many differences users notice come from how the agent organizes context, invokes tools, retries failures, and presents diffs—not just from the model itself.

    The question, then, is not “Which model is strongest?” It is: How do you build an AI coding workflow with replaceable models, a controllable harness, and measurable quality?

    2. Three Dimensions for Evaluating Model Output

    Setting brands aside, common complaints about AI coding tools fall into three distinct dimensions.

    2.1 Language Quality: Naturalness

    Consider a request such as: “A friend was laid off, drank too much, and asked whether they were useless. Help me write a reply.”

    Some models produce three versions suited to different levels of closeness, each sounding like something a person would actually send. Others generate grammatically correct sentences that feel formulaic when read together, even after repeated rewrites.

    The engineering implication is straightforward: naturalness is a hard requirement for creative writing, copywriting, comments, and documentation. It directly affects how much manual rewriting the output needs.

    Rather than relying on impressions, maintain a fixed set of 20–50 real tasks. Use blind scoring on a 1–5 scale and record the time spent rewriting each response.

    2.2 Instruction Following and Sycophancy

    Another problem is excessive agreement: the model endorses whatever you propose and fails to point out obvious flaws. In architecture reviews, code reviews, and technology selection, this can quietly distort important decisions.

    Review tasks should explicitly counter sycophancy. One practical approach is to require structured output and an opposing argument:

    1. Use the following structure. Do not omit any field:
    2. 1. Three assumptions that must hold for this proposal to work
    3. 2. The two most likely failure scenarios and their causes
    4. 3. Your strongest argument against the proposal, if you had to oppose it
    5. 4. Confidence level (high/medium/low) and areas of uncertainty

    The third field is the key: it turns an open-ended request for agreement into a mandatory task to produce a counterargument.

    2.3 Task Completion: Reliability

    A third category involves incomplete or incorrect execution: missing changes across multiple files, choosing the wrong dependency version, or claiming completion when tests still fail.

    These failures are often not caused by the model alone. They also indicate that the harness lacks a verification loop.

    Every automated code-editing workflow needs executable verification steps. The model’s own completion statement is not sufficient evidence.

    1. # A minimal verification chain for task completion
    2. run_lint && run_typecheck && run_unit_tests && git diff --stat

    3. The Harness: An Underestimated Engineering Layer

    The harness includes everything around the model: context retrieval and trimming, tool definitions, permissions and sandboxing, failure retries, logging and observability, and the interaction interface.

    The same model can behave very differently in different harnesses. In practice, those usability differences can exceed the gains from switching models.

    A capable harness should include at least five layers:

    Layer Responsibilities Typical Symptoms When Missing
    Context Retrieve relevant files, manage token budgets, maintain long-term memory Important constraints are “forgotten” in large repositories
    Tools Read and write files, execute commands, search, and call external interfaces The agent offers advice but cannot implement changes
    Sandbox Enforce permission boundaries, support rollback, and isolate execution Accidental deletion, unintended edits, or irreversible operations
    Verification Run static checks, type checks, tests, and diff audits The agent claims success despite actual failures
    Observability Capture end-to-end logs, token usage, latency, and quality regressions Quality declines cannot be located or attributed

    The engineering recommendation is to invest in the harness as an asset you control and treat the model as a pluggable dependency. When upstream conditions change, you can change configuration rather than redesign the architecture.

    4. A Replaceable Model Abstraction Layer

    The first implementation step is a common adapter interface. Application code should depend on that abstraction rather than on a particular model.

    1. from dataclasses import dataclass
    2. from typing import Protocol
    3. @dataclass
    4. class GenRequest:
    5. prompt: str
    6. context: list[str]
    7. max_tokens: int
    8. temperature: float
    9. need_structured: bool = False
    10. class ModelAdapter(Protocol):
    11. name: str
    12. def generate(self, req: GenRequest) -> str: ...
    13. def quota_left(self) -> float: ...

    Express routing policies declaratively so that switching models becomes a configuration change:

    1. routing:
    2. chat_and_docs: { tier: high, min_quality: 0.85 }
    3. code_review: { tier: high, structured: true }
    4. bulk_edit: { tier: mid, parallel: 8 }
    5. form_filling: { tier: low, cheap_first: true }
    6. fallback:
    7. on_quota_exhausted: next_tier
    8. on_timeout: retry_then_fallback

    This separation helps keep migration effort close to zero without tying business logic to an individual model.

    5. Tiered Task Routing for Cost Efficiency

    Not every task warrants the most expensive model tier. Routing tasks by their value and requirements is a central way to control costs:

    • High-value tasks: Architecture design, code review, creative writing, and public-facing copy. Prioritize naturalness and critical reasoning. Usage is relatively limited, so a higher unit cost may be acceptable.
    • Medium-value tasks: Cross-file refactoring, adding tests, and script generation. Prioritize reliability and require the verification loop.
    • Low-value tasks: Filling forms, entering domain and server information, repetitive bulk rewriting, and classifying logs. Prioritize throughput and unit cost, using the cheapest tier with parallel execution and retries.

    A quota-aware fallback chain—high to medium to low—can keep workflows running during periods of heavy demand.

    6. Regression Evaluation: Turning “It Seems Worse” into Metrics

    Subjective impressions are not enough to guide decisions. A regression suite provides a measurable basis.

    Maintain an internal set of 30–100 tasks spanning the three task tiers. Each task should include its input, expected constraints, and an automated validation script.

    Run the suite whenever the model or harness changes, and track four metrics:

    • First-pass success rate
    • Time spent on manual rewriting
    • Average token consumption
    • Structured-field compliance rate

    A declining trend can trigger a switch before users notice the degradation.

    Store evaluation data, logs, and artifacts in object storage. Decouple task scheduling through a message queue, isolate execution with a container platform, and connect end-to-end metrics to logging, monitoring, and alerts.

    Baidu AI Cloud offers capabilities in these general infrastructure categories. Where the relevant services are available, they can support an evaluation pipeline operated as ongoing infrastructure.

    7. Risk Controls During Migration

    1. Version prompts and configurations alongside code. Keep them in the same repository so changes can be rolled back.
    2. Remove sensitive information before sending context externally. Credentials, internal domain names, and customer data should not enter prompt context.
    3. Require human confirmation for irreversible operations. This is especially important for deletion, bulk rewriting, and production configuration changes.
    4. Keep old and new workflows running in parallel for one to two weeks. Compare them using the evaluation suite before making the new workflow primary.

    8. Conclusion

    Monthly shifts in model rankings should not dictate architecture decisions.

    Evaluate output across naturalness, instruction following and sycophancy, and reliability. Put engineering effort into the harness and its verification loop. Use a common adapter layer and tiered routing to minimize migration costs, then track quality changes through an internal regression suite.

    Tools will change. The durable capability is the engineering system you build around them.