Evaluating Coding Agents: Real Terminals, Long-Horizon Tasks, and Executable Benchmarks
This article explains how coding agent evaluation is shifting from text-based matching to executable verification. It covers why real terminal environments are essential for evaluating coding agents, the four design pillars for trustworthy benchmarks, how long-horizon tasks expose error accumulation, practical task specifications and execution patterns, enterprise deployment considerations, and common pitfalls. It also shows how resource limits, cost metrics, observability, and failure attribution make benchmark results more reliable and actionable.
1. The capability shift: from code completion to task completion
The evolution of coding agents can be roughly divided into three stages.
The first stage is snippet completion. Given the context of the current line, the model predicts the next few tokens, and the evaluation standard is primarily text similarity.
The second stage is function-level generation. Given a natural language description or a function signature, the model produces a standalone function, and evaluation begins to incorporate unit test pass rates.
The third stage is task completion inside a real terminal. Given an issue-level goal, the agent must autonomously read code, modify files, run commands, observe errors, and iterate until the acceptance criteria are met.
This shift changes evaluation methodology more thoroughly than many people expect. In the first two stages, static metrics based on textual similarity can still have some reference value. Once the third stage is reached, these metrics lose much of their explanatory power. Two patches can have very different formatting but be behaviorally equivalent, which is common. Conversely, two patches can be textually similar but introduce regressions.
The only stable criterion for distinguishing quality in this setting is executable verification.
This is also why the real terminal environment has become the core vehicle for evaluating coding agents: it changes evaluation from asking “what did the model say?” to asking “what did the agent accomplish?”
2. Why the agent must be placed in a real terminal
A complete repository-level task naturally contains a large amount of non-code information, and this information only exists in a realistic environment:
- The environment is the context: directory structure, build configuration, dependency lockfiles, script conventions, and error stack traces. Without these, the agent can only guess the engineering conventions of the project.
- The action space is multi-step: read files → execute commands → observe output → update hypotheses → execute again. The value is not in getting a single step correct, but in whether the agent can correct itself based on feedback.
- Real-world noise cannot be avoided: dependency version conflicts, restricted network access, insufficient permissions, disk quotas, and timeouts. An idealized input distribution will cause evaluation to overestimate real-world performance.
- Resource limits have discriminative meaning: when given CPU, memory, time limits, and a limited number of retries, the benchmark can distinguish “efficiently locating the problem” from “brute-force enumeration.” The latter may inflate scores under unlimited budgets, but it has little value under realistic cost constraints.
In short, the terminal environment is not merely a harder test; it is a more realistic test.
3. Four design pillars for trustworthy evaluation
To turn a terminal-based benchmark into a long-term usable tool rather than a one-time leaderboard, at least four requirements must be satisfied.
1. Environment reproducibility
Images should be fixed, dependencies locked, random seeds controlled, and network policies explicit: open, allowlisted, or fully isolated. Any evaluation whose results change from one rerun to the next lacks comparability.
2. Objective criteria decoupled from prompts
Each task should have dedicated tests, and it is important to separate public tests from hidden tests. Public tests can be provided to the agent as a feedback signal, while hidden tests are used for final scoring. If all tests are visible to the agent, the benchmark can easily degrade into writing implementations that target the tests.
3. Observable process
Recording only the final score makes post-hoc improvement difficult. The evaluation system should retain complete artifacts: action traces, stdout and stderr for each command, time spent at each step, token consumption, and file diffs. Trace data is the primary source for failure attribution and for constructing training data.
4. Attributable failure
A “failed” result can be broken down into at least four categories, and their optimization directions are completely different:
| Failure type | Typical symptoms | Attribution |
|---|---|---|
| Environment failure | Image build failure, dependency installation failure, tests error on their own | Evaluation infrastructure |
| Instruction failure | The agent cannot parse or does not execute evaluation instructions | Evaluation design |
| Capability failure | The agent executes and exits normally, but tests do not pass | Agent capability |
| Resource failure | Timeout, OOM, step limit exceeded, cost limit exceeded | Agent efficiency |
Without distinguishing these four categories, the score has little diagnostic value.
4. Long-horizon tasks: the main challenge is error accumulation
Long-horizon tasks are tasks that require dozens or hundreds of actions, span multiple files, and include multiple “execute and verify” cycles. For example: “add asynchronous support to a module and adapt all callers.”
The key difference between long-horizon tasks and short tasks is not necessarily single-step difficulty, but the fact that errors accumulate along the trajectory. In engineering practice, three failure patterns are commonly observed:
- Goal drift: after dozens of steps, the agent is optimizing a derived subgoal rather than the original requirement.
- Context contamination: an incorrect early assumption remains in the context, continuously biasing later reasoning, and becomes increasingly difficult to correct as the task progresses.
- Local optimum traps: the agent fixes the current test but introduces regressions elsewhere, or repeatedly tweaks the same failing point instead of changing strategy.
Corresponding engineering techniques generally fall into four categories:
- Plan-execute-verify loop: each phase ends with a decidable checkpoint, preventing open-ended drifting.
- External memory instead of unlimited context: repository structure, conventions, and confirmed assumptions are written into external files and retrieved on demand, rather than stuffed into the conversation.
- Checkpoints and rollback: after each subgoal is completed, the state is solidified. On failure, the agent returns to the latest known-good state instead of continuing to build on a damaged state.
- Fast feedback loops: prioritize the smallest reliable verification step, such as unit tests, type checking, or lint, and delay long feedback until later. This exposes incorrect assumptions earlier.
The skeleton of a long-horizon execution loop may look like this:
def run_long_horizon(task, sandbox, budget):# 1. Planning phase: produce a structured list of verifiable subgoalsplan = agent.plan(task, repo_index=sandbox.build_index())assert_structured(plan, requires=["goal", "steps", "verify"])checkpoints = []spent = 0for step in plan.steps:if spent >= budget.max_steps or budget.elapsed() > budget.timeout:return Result(status="resource_exceeded", checkpoints=checkpoints)spent += 1patch = agent.act(step, memory=load_memory(sandbox))sandbox.apply(patch)# 2. Verification phase: fail early with the smallest reliable feedback loopverify = sandbox.run(step.verify_cmd, timeout=step.verify_timeout)if verify.exit_code == 0:checkpoints.append(sandbox.snapshot()) # Save a known-good stateupdate_memory(step, evidence=verify.summary)else:sandbox.restore(checkpoints[-1]) if checkpoints else sandbox.reset()# 3. Strategy escalation: switch approach after retries instead of polishing the same failureplan = agent.replan(step, feedback=verify.stderr) if retry_left(step) else planif step.exhausted():return Result(status="capability_failed", at=step.id)# 4. Final verification: hidden tests are executed only herereturn Result(status="passed" if sandbox.run_hidden_tests() else "capability_failed",checkpoints=checkpoints)
Two easily overlooked details here are important. First, verify must be cheap and deterministic, otherwise the loop itself becomes a bottleneck. Second, final verification must use tests that the agent cannot see throughout the task, otherwise the score is not trustworthy.
5. Evaluation execution skeleton: what a task specification looks like
It is best to fully decouple the task definition from the evaluation logic. Tasks should be described declaratively, while the executor remains general-purpose:
id: async-migration-017repo: { image: registry.internal/bench/async-migration:base-2026Q3, ref: pinned }limits: { cpu: 2, memory: 4Gi, timeout: 900s, max_steps: 120, cost_usd: 0.6 }network: allowlist: ["pkg-mirror.internal"]public_tests: ["tests/unit/test_public_*"] # Feedback signal available to the agenthidden_tests: ["tests/hidden/test_acceptance_*"] # Executed only during final scoringscoring: { metric: hidden_pass_rate, weights: { correctness: 0.8, cost: 0.1, steps: 0.1 } }cleanup: { always: true, retain_artifacts: ["trajectory.jsonl", "diff.patch"] }
The execution layer should have clear boundaries: create an isolated execution environment → inject the repository snapshot → drive the agent loop → collect traces and artifacts → run hidden tests → clean up the environment whether the run succeeds or fails. Cleanup must be placed in finally semantics, otherwise a single exception can pollute all subsequent results.
Two engineering practices are essential. First, use layered concurrency: container creation, agent inference, and test execution should be rate-limited separately to avoid resource contention and false timeout judgments. Second, include cost in scoring: evaluations that report only pass rates without reporting token usage and elapsed time systematically favor strategies that trade large amounts of trial and error for success.
6. Key non-capability considerations for enterprise adoption
Technical metrics only answer whether an agent can perform a task. Enterprise adoption also depends on several additional factors:
- Isolation and least privilege: agents are designed to execute arbitrary commands and must run in disposable sandboxes. Access to production credentials, sensitive internal ports, and unnecessary read-only mounts should be prohibited.
- Code must stay within the domain: closed-source repository evaluations and trial runs should be restricted to owned environments. External model calls require clear data boundaries and retention policies.
- Observability and cost governance: long-running tasks must integrate with centralized logging and monitoring. Alert thresholds should be set for step count, token usage, and per-task duration, and anomalous traces should be automatically retained for review.
- Human-agent division of labor: agents should handle mechanical, verifiable changes such as dependency upgrades, large-scale refactoring, test generation, and lint fixes. Humans should handle interface design, trade-off decisions, and final judgment. This is not merely a capability issue; it is an accountability issue.
At the implementation level, these requirements can generally be supported by cloud infrastructure: container platforms for disposable isolated execution environments and elastic quotas, object storage for archiving trajectories, diffs, and test artifacts, and logging/monitoring services for long-running task observability.
7. Four common pitfalls
- Score-only evaluation: a single aggregate score hides the distribution of failure types. Two systems with the same 60% score may fail for completely different reasons: one concentrated in resource timeouts, the other in capability gaps. Their improvement paths are different.
- Data contamination: when the repository commits corresponding to benchmark tasks have entered public corpora, scores can be inflated. Mitigations include building private task sets, rotating tasks regularly, and adding recently created issues.
- Ignoring cost: focusing only on success while ignoring cost constraints can select solutions that lose money immediately after deployment.
- Underestimating environmental fragility: image drift, unreachable dependency sources, and flaky tests can all distort evaluation conclusions. The stability priority of the evaluation infrastructure should be higher than adding new tasks.
8. Conclusion
Evaluation of coding agents is shifting from “text comparison” to “executable verification.” Terminal-based benchmarks and long-horizon task sets are two key handles for this shift. The former ensures objective criteria, realistic environments, and attributable failure. The latter tests robustness and cost efficiency under error accumulation.
The truly valuable output is not a leaderboard rank, but a reproducible, attributable, and observable evaluation engineering system. It transforms “the model appears to know how to write code” into “we can prove what the agent completed under which constraints,” which is the prerequisite for large-scale deployment.
