How to Evaluate the Long-Horizon Coding Ability of AI Agents
Choosing a coding agent based on benchmark bar charts is unreliable, because leaderboards use inconsistent criteria, are increasingly optimized for, and cannot capture the variance of long-horizon tasks. This article presents an executable engineering process for self-evaluation: defining long-horizon coding ability across four multiplicative layers (planning, context stability, self-correction, tool use), designing high-discrimination tasks with acceptance criteria built into the prompt, recording reproducible metrics such as first usable time, convergence rounds, constraint retention and stability variance, and turning the evaluation into a repeatable team pipeline. It also explains why an "MVP first, then keep fixing" loop is more dependable and lists common failure modes with practical countermeasures.
1. When “the Best” Is Just Marketing, Self-Testing Is the Only Judge
Model launches over the past two years share a ritual: every new release claims to be “the best” on a few comparison charts. But anyone who has to make a real selection decision quickly runs into three problems.
First, leaderboards use inconsistent criteria. Some measure single-turn academic reasoning, some measure code completion pass rates, and others measure multi-step tool calling. Leading on a competition-problem leaderboard does not mean a model can read implicit conventions in a real repository or complete a cross-layer refactor across hundreds of files.
Second, leaderboards are being “optimized for.” Once an evaluation set is public, it becomes a training target at the same time. The correlation between rising scores and actual capability improvement keeps decaying.
Third, benchmarks do not reflect stability on long-horizon tasks. Benchmark problems usually have clear inputs, deterministic answers, and a limited number of steps. Real development tasks are characterized by long step sequences, weak feedback, many states, and cascading errors. A high average score hides a fatal variance: “three out of ten runs go off the rails.”
So when a new version ships, the right move is not to see whose bar chart is taller, but to run it on your own real tasks with your own acceptance criteria. The rest of this article breaks that into an executable engineering process.
2. Define “Capability” First: Four Things a Coding Agent Must Be Good At
Before testing anything, you have to decompose the vague phrase “strong capability” into observable sub-capabilities. Based on the current industry consensus on coding agents, long-horizon coding ability consists of at least four layers:
1. Task planning and decomposition
Can it turn a one-sentence requirement into ordered steps: scaffold first, then styling, then interaction, then self-testing? A poor implementation “writes whatever comes to mind” and produces a messy structure. A good one outputs a plan first and cuts the big task into verifiable milestones.
2. Context stability (long-horizon consistency)
Long tasks inevitably trigger context compaction or summarization. Whether the agent still remembers the original hard constraints (for example, “must support touch gestures” or “must not use a certain class of dependencies”) is the key measure of long-horizon ability. An agent that forgets constraints drifts into “a different project” the further it goes.
3. Self-correction loop
This is where the current generation differs most. It requires a complete act → observe → attribute → fix loop: reading build errors, proactively capturing the running UI, judging “is this a layout problem or a data problem,” and then making a targeted change instead of repeatedly tweaking the same irrelevant code.
4. Tool and environment usage
This includes reading and writing files, executing commands, launching a browser for end-to-end verification, and retrieving external references on demand. The gap in tool usage usually shows up not in “whether it can call a tool” but in timing of calls and failure recovery: whether search keywords are effective, whether it switches verification methods when a test fails, and whether it can change course quickly when a path is wrong.
One important conclusion: these four layers are multiplicative, not additive. No matter how good the plan is, if the agent loses its memory after compaction, the output is still unusable. No matter how strong the self-correction is, if every run needs a human fallback, it cannot go into an automated pipeline.
3. Designing the Evaluation: How to Make One Self-Test Convincing
3.1 Task Selection Principles
Pick tasks that are highly discriminating, strongly verifiable, and hard to fake. The recommended type is a “UI replication” front-end application, for three reasons: the requirement can be expressed in one sentence, but a complete implementation covers four layers (layout, varied data, animation, interaction); the result can be compared by screenshots, making acceptance nearly objective; and the model cannot get away with “inventing APIs,” because if it does not run, it does not run.
A reference prompt structure (note that acceptance criteria are placed up front, not dumped at the end):
Create an empty folder in the current working directory and complete thefollowing task autonomously, with no intervention from me:Goal: Use a mainstream progressive front-end framework to build a mobileweather app page.Data: Include several weather types (sunny / cloudy / rain / snow /thunderstorm / fog), switchable.Visual: The overall look must closely resemble the built-in weather app ofa mainstream mobile OS; each weather type needs a matching dynamiceffect (drifting clouds, rain/snow particles, lighting gradients).Interaction: Support swiping up/down to switch cities, tap to expand thehourly forecast.Acceptance: When done, start a local server yourself, run one end-to-endcheck with browser automation, and output screenshots plus aconclusion; if you find problems, locate and fix them yourselfuntil the check passes.Constraints: Do not introduce packages not declared in the dependencymanifest; the page must have no horizontal scrolling on narrowscreens.
The key is in the last two lines — they write “self-testing” into the task definition. Whether the agent has this closed-loop awareness directly determines the usability rate of its output.
3.2 Environment and Recording Standards
For a self-test to be reproducible, you must control variables. Fix the container image and runtime version, the dependency manifest and install method, the thinking-budget tier, the context window and compaction strategy, and the per-step tool allowlist. Also persist three kinds of data throughout: the full conversation and tool-call trace, artifact snapshots at each milestone, and screenshots at key points.
4. Metrics: Don’t Just Look at “Does It Run”
A single success/failure signal is binary and carries too little information. Record the following scale and score each round:
| Dimension | How to Observe | What to Judge |
|---|---|---|
| Time to first usable output | When the first artifact appears that starts and runs the main flow without errors | Reflects MVP-first ability |
| Convergence rounds | Number of self-repair rounds needed to meet acceptance criteria | Lower is better; zero human intervention is ideal |
| Fix hit rate | Whether each round’s change targets the real root cause | Distinguishes real debugging from random trial and error |
| Constraint retention | Whether hard constraints are still honored after compaction / long context | The core metric of long-horizon ability |
| Interaction completeness | Checklist items such as swipe, tap, page switch, ticked one by one | Visual similarity ≠ correct interaction |
| Visual fidelity | Structured comparison of screenshots against the reference | Layout / color / spacing, not pixel-level nitpicking |
| Stability variance | Repeat the same task 5 times; look at success rate and time distribution | The most overlooked and most important item |
The last row deserves separate emphasis. There is a common experience bias in the industry: some models “reason extremely fast, too fast to see the details.” A single run looks great, but running the same complex task repeatedly shows obvious high-low swings — elegant the first time, wrong path the second, off-track fix the third. Another kind of model behaves differently: “it quickly produces a runnable skeleton first, then keeps iterating around usability, and basically never loses the original instructions even when context is compacted repeatedly.”
This is not mysticism; it is quantifiable: run N times and record success rate, failure-type distribution, and average convergence rounds. Selecting on averages is planting a landmine for yourself.
5. Mechanism Breakdown: Why “MVP First + Continuous Fixing” Is More Reliable
The effective pattern abstracted from evaluation observations can be summarized as the agent’s main loop:
def run_task(goal: str, sandbox: Sandbox, max_steps: int = 60):"""Minimal viable main loop for a long-horizon coding agent."""ctx = Context(goal=goal, anchors=extract_hard_constraints(goal))# 1) Plan the scope of a minimal runnable version first,# instead of aiming for completeness in one shotctx.append(plan(skeleton_only=True))while not ctx.done and ctx.step < max_steps:action = decide(ctx) # 2) Actobs = sandbox.execute(action) # 3) Observe: build/test/screenshotverdict = verify(obs, ctx.acceptance) # 4) Objective gate, not model self-reportif verdict.passed:ctx.done = Truebreakctx.record(obs, verdict.reason) # 5) Keep failure evidencectx = compact(ctx) # 6) Compact the contextctx.reinject(anchors) # 7) Re-inject hard constraintsreturn ctx.artifacts()
A few design points:
verifymust be external and executable. Use “does the build succeed, is the end-to-end script all green, does the screenshot pass the structural comparison” as the gate, rather than letting the model say “I fixed it.” The model’s self-reported pass rate is always inflated.- Re-inject constraint anchors after compaction. Context summarization is lossy, and constraints like “must not use a certain dependency” or “must support touch gestures” are the easiest to get summarized away. Storing hard constraints separately and re-injecting them every round is the lowest-cost way to keep long-horizon tasks on track.
- Keep failure evidence from the most recent few rounds, but discard older verbose logs. Debugging needs “the original error plus the diagnosis,” not the full history.
- Limit the change surface per round. Encourage small commits and small verifications; changing eight files at once and causing four new regressions is a typical source of long-horizon failure.
6. Common Failure Modes and Engineering Countermeasures
| Failure Mode | Typical Symptom | Countermeasure |
|---|---|---|
| Path / dependency misjudgment | Reads and writes the wrong directory at the start, detours, then changes course | Pre-set the dependency manifest and directory conventions; run an environment self-check before starting |
| Visually similar but interaction missing | The page looks good but does not swipe or open | Score interaction items and visual items separately on the acceptance checklist |
| Forgetting after compaction | Drops constraints like “must support narrow screens” later on | Store constraint anchors separately + re-inject every round |
| Repeatedly tweaking the same spot | Three rounds in, still circling the same error | Force a strategy change after two rounds with no progress (switch verification method or implementation path) |
| Speed masking quality | Good on a single run, low success rate on repeated runs | Run a fixed N repetitions; look at variance and failure-type distribution |
| Unreadable thinking process | Long chain of thought makes the problem hard to locate | Check whether the chain of thought follows the language of the prompt, which makes it easier for a local team to trace |
One more practical note on thinking budget: tier it by task complexity. Use the default tier for simple changes, where the speed gain is obvious; raise the tier for complex refactors. And the language consistency of the chain of thought does not affect the quality of the final answer, but it significantly affects maintainability — when the prompt is in Chinese and the thinking process is also in Chinese, the cost for a team to trace the trajectory is an order of magnitude lower.
7. Turn It into a Team Asset
Self-testing should not be a one-off manual effort. Make it a repeatable, triggerable pipeline:
- Task library: accumulate 5–10 replication tasks, refactoring tasks, and bug-fix tasks each, with acceptance scripts and reference screenshots.
- Sandboxed execution: run each task in its own container so they do not pollute each other, and archive artifacts uniformly.
- Metrics dashboard: tag success rate, time to first usable output, average convergence rounds, and number of human interventions by version to form trend lines.
- Selection conclusion: not “who is the best,” but “which tier is most cost-effective for which class of tasks.”
General-purpose cloud capabilities are sufficient to support this pipeline: a container platform provides isolated, elastically concurrent execution sandboxes, object storage archives conversation traces, code artifacts and screenshots, logging and monitoring/alerting services track task success rate and time distribution, and a message queue decouples queuing and callbacks for long tasks. Taking Baidu AI Cloud as an example, these general categories can be combined into an internal “evaluation as a service” platform, so that every model or prompt change is backed by data.
8. Conclusion
For a new generation of coding agents, the answer to “how do you evaluate it” is not in the launch-event bar charts, but in your own task library and scorecard. The technical highlights truly worth attention are concentrated in four places: the planning ability to cut a big task into verifiable milestones, the long-horizon consistency to hold hard constraints after context compaction, the self-correction loop gated by screenshots and automated tests, and a configurable trade-off mechanism among speed, thinking depth, and stability.
The right question at selection time should also change from “who is the best” to three answerable questions: how many times does it succeed in five runs on my typical tasks? When it fails, can it climb out by itself, or does a human have to take over? How large is the cost of trading speed for stability, or the reverse? Only a team that can answer these three questions quantitatively has truly completed the evaluation.
