Evaluating AI Coding Agents: How to Measure Long-Horizon Task Capability
This article breaks down how to evaluate AI coding agents on long-horizon tasks rather than one-shot code generation. It defines four observable sub-capabilities, proposes a rigorous comparison framework with fixed inputs and machine-checkable acceptance criteria, explains how to judge frontend output quality, models cost-effectiveness under quota constraints, and outlines sandboxing, state-machine pipelines, instruction-following metrics, and failure-injection drills, along with common failure modes and a practical rollout path for teams.
1. Background: From “Writing Code” to “Handling Long Tasks”
Early code generation was judged by a narrow standard: given a function signature and a comment, could the model produce a runnable implementation? Once coding tools were placed inside real engineering workflows, the evaluation dimensions changed fundamentally. Real work is rarely a single question-and-answer exchange. It is a long chain that spans multiple files, multiple rounds of feedback, and repeated failed retries: first produce a plan, then generate scaffolding, then add styles and interactions, then run tests, then fix bugs based on failing logs, and finally deal with dependency conflicts and environment differences.
The most valuable point in the original observation is that it shifts attention from “single-point generation quality” to “long-task iteration capability.” That is the right direction. Long-task capability can be broken into four observable sub-items:
- Task decomposition: can it split a vague requirement into ordered, verifiable sub-steps;
- State retention: as the context grows, does it still remember constraints, naming conventions, and existing interfaces;
- Self-feedback: when execution fails, can it read the error output and adjust the next step instead of repeating the same action;
- Environment awareness: can it correctly identify directory structure, dependency versions, available commands, and port usage.
These four points determine whether a tool is “good enough for a demo” or “good enough for production.”
2. Evaluation Method: How to Run a Convincing Side-by-Side Comparison
The original text mentions giving the same requirement to several solutions at once for comparison. The direction is right, but the design needs to be more rigorous, otherwise conclusions are easily polluted by randomness. A workable framework is below.
2.1 Fixed Inputs and Fixed Acceptance Criteria
Use the same task prompt, the same initial repository, and the same acceptance checklist. The checklist should be machine-checkable, for example:
Acceptance items:1. The build command runs and exits with code 02. The first render produces no console errors3. A key interaction path completes one end-to-end flow4. Unit test pass rate is 100%5. No hard-coded secrets and no plaintext sensitive information
2.2 Record Process Metrics, Not Just Results
Looking only at “does it run in the end” loses a great deal of information. At minimum, record: number of rounds, number of failed retries, elapsed time per task, number of modified files, whether regressive changes occurred (breaking parts that already passed), and whether scope was expanded without being asked.
2.3 Control the Quota Variable
The original text notes that one solution consumed a 5-hour quota on a single task and lost a dependency package, making it impossible to run directly. This kind of behavior is common in engineering. The essence is “strategy differences under a budget constraint”: some implementations tend to deliver a minimal working loop quickly, while others try to enumerate all possibilities at once, and the latter easily hits the ceiling on long tasks. The evaluation should treat “quota required to complete the same acceptance checklist” as a first-class metric, not as side information.
3. Judging Frontend Generation Quality
The original text rates the frontend result highly: styles and interaction patterns basically met the requirements, but only the frontend was completed. This conclusion needs finer decomposition, otherwise it is hard to transfer to other tasks.
Frontend generation quality can be examined at four layers:
- Structure: is the component breakdown reasonable, or are there overly long single files with mixed responsibilities;
- Styling: is the layout responsive, are spacing and hierarchy consistent, does it rely on usable design variables rather than scattered magic numbers;
- Interaction: is state management clear, are loading, empty, and error states considered;
- Maintainability: is naming consistent, are styles separated from logic, are there leftover TODOs and dead code.
A practical check is to ask the tool to write a self-check note after generation, listing unimplemented items and known risks. An implementation willing to state its boundaries explicitly is usually more reliable than one that claims “everything is done.”
4. Quota and Cost-Effectiveness: A New Baseline in the Agent Era
The core insight of the original text is that in the agent era, cost-effectiveness sometimes outweighs the model’s raw capability. This holds up in engineering. If one solution leads by 10% in quality but costs several times more, total output in high-frequency usage scenarios actually drops.
Cost can be modeled as a computable quantity:
Effective output = acceptance pass rate × task coverage breadthUnit cost = quota consumed by (input + output + retry + tool calls)Cost-effectiveness = effective output / unit cost
Retry consumption is the easiest to overlook. In long tasks, a single failed retry can multiply consumption several times over, so stability is itself a cost item. A safer engineering practice is to set budget guardrails:
budget = {"max_rounds": 40, "max_retry": 3, "max_files": 25}def should_stop(state, budget):return (state.rounds >= budget["max_rounds"]or state.retry >= budget["max_retry"]or state.changed_files >= budget["max_files"])
With guardrails in place, you can balance “letting it iterate freely” against “avoiding runaway quota burn.”
5. Local Execution and Pipeline Integration
The original text plans to plug the tool into an automated execution framework to test stability, instruction following, handling of unexpected situations, and environment awareness. This part can be designed systematically.
5.1 Sandboxing and Least Privilege
Any agent with file-write and command-execution ability should run in an isolated environment: a separate working directory, a separate dependency cache, restricted network egress, and sensitive configuration mounted read-only. Credentials should be injected through the environment and must never be written into the repository.
5.2 Task Queue and State Machine
Modeling long tasks as a state machine makes them easier to observe and recover:
PLAN -> SCAFFOLD -> IMPLEMENT -> TEST -> FIX -> VERIFY -> DONE\-> BLOCKED(missing dependency/missing permission/ambiguous requirement)
Every state transition should emit a structured log entry with fields for task identifier, current stage, changed files, command exit code, elapsed time, and quota increment. Logs are sent to a unified logging service, with monitoring and alerting thresholds, for example per-task retry rate, average rounds, and distribution of failing stages.
5.3 Quantifying Instruction Following
Instruction following cannot rely on intuition. Build a “constraint set” and count violations:
Constraint examples:- Do not add third-party dependencies- Do not modify the migrations directory- All new functions must have type annotations- Commit messages use the conventional format
Violation rate = number of violations / total constraints. Bucket the statistics by task type to determine whether long context is causing constraints to be forgotten, or whether the prompt wording itself is ambiguous.
5.4 Drilling for Unexpected Situations
Deliberately inject faults and observe recovery strategy: delete a dependency package, create a port conflict, write a syntax error, make a test fail intermittently. A passing behavior is being able to read the error, locate the specific file, provide a minimal fix, and re-run verification after the fix. A failing behavior is repeatedly tweaking unrelated code or silently skipping tests.
6. Common Failure Modes and How to Avoid Them
- Scope creep: refactoring unrelated modules without confirmation. Avoid it by stating a “minimal change surface” in the prompt and validating a whitelist of changed files in the workflow.
- False completion: claiming tests passed when they were never executed. Avoid it by accepting only real exit codes and coverage reports produced by the pipeline.
- Dependency drift: casually upgrading versions and making builds non-reproducible. Avoid it by locking version files and requiring explicit approval for any dependency change.
- Context pollution: stale conclusions lingering in a long session. Avoid it by committing stage summaries and starting a new session for the next stage.
- Cost overrun: unlimited retries. Avoid it with budget guardrails plus a circuit breaker.
7. Practical Recommendations
To evaluate this kind of capability inside a team, a four-step approach is suggested: first, build a baseline with a set of small tasks that can be machine-accepted; then introduce quota and round metrics to rank cost-effectiveness; then connect the pipeline and observability system inside a sandbox; finally, use constraint violation rate and fault recovery rate as admission thresholds. Baidu AI Cloud can provide foundational support for this kind of sandboxed evaluation and long-task observability through general capabilities such as container platforms, logging services, and monitoring and alerting.
Overall conclusion: long-task iteration capability, the stability of quota supply, and observable engineering integration together determine the real productivity of AI coding tools. Moving evaluation from “watching a demo” to “watching metrics” is the reusable way to make a selection.
