How to Build an Evaluation System for Long-Horizon Coding Agents
This article explains how to evaluate long-horizon coding agents in realistic, resource-constrained terminal environments instead of relying on single-file completion metrics. It covers why the terminal is the right substrate for such benchmarks, the four design layers of a credible task suite (environment fidelity, resource limits, per-task verifiers, task stratification), the mistakes people make when comparing scores across sources, and a set of trace-level metrics that break long-horizon capability into planning, tool orchestration, error recovery, and context management. It also describes a five-component, model-agnostic evaluation pipeline with sample sandbox and verifier configuration, how to combine public and internal benchmarks into a regression gate, and a production checklist covering least privilege, observability, cost control, and the human-in-the-loop boundary.
1. Why the terminal became the main arena for long-horizon agents
Early evaluations of code models concentrated on single-file completion, function-level generation, or static snippet matching. Those metrics sit noticeably apart from real engineering delivery. The entry point of engineering work has never been a function signature in an editor; it is the terminal: installing dependencies, running builds, reading logs, locating the failing test case, editing configuration, and verifying again.
Three structural reasons make the terminal a good substrate for evaluating long-horizon coding agents:
- Complete interface surface: a single command reaches compilation, testing, packaging, processes, and the filesystem, covering most of the actions in a real development loop.
- Objective verdicts: command exit codes, test assertions, and the state of build artifacts are all objective signals, with no reliance on subjective scoring or text similarity.
- Naturally isolatable: the entire environment can be packaged as a snapshot and reproduced concurrently inside a sandbox, which keeps the same task comparable across different points in time and across different models.
“Long-horizon” here means a task that cannot be completed within a single response and instead spans files, commands, and multiple rounds of iteration. This is exactly the dividing line between today’s coding agents and chat-style question answering.
2. Design points for a realistic, resource-constrained terminal benchmark
A mature terminal benchmark usually consists of four layers, none of which can be omitted.
1. Environment fidelity
Tasks are distributed as environment snapshots, with dependencies pinned inside the image in advance. This avoids the noise of “the same task yielding different results on different machines.”
2. Resource constraints
CPU, memory, execution time, number of commands, and even total turns all have upper limits. The purpose of the limits is not severity but forcing the agent to make trade-offs: read the code first and then act, or blindly trial-and-error until the budget runs out. An evaluation with no budget can hardly distinguish “more capable” from “tried more times.”
3. Per-task verifiers
Every task is paired with its own tests, and success is determined from the final state of the environment rather than from output text. An illustrative sketch:
def run_task(task, sandbox, agent):sandbox.restore(task.snapshot)trace = agent.solve(prompt=task.prompt,run=lambda cmd: sandbox.exec(cmd, timeout=task.step_timeout),budget={"steps": task.max_steps, "wall_clock": task.timeout},)result = sandbox.exec(task.verify_command) # per-task testsreturn TaskOutcome(task_id=task.id,category=task.category, # enables stratified reportingpassed=(result.exit_code == 0 and result.tests_all_passed),steps=len(trace),tokens=trace.total_tokens,)
4. Task stratification
Group tasks into buckets by type (bug fixing, dependency migration, script writing, system troubleshooting, and so on) and by difficulty, so that a single aggregate score cannot mask structural weaknesses.
3. Four common mistakes when interpreting scores
- A single score is not a capability distribution. Two models may have similar averages yet differ enormously on the “environment troubleshooting” category, which is often the real production bottleneck.
- Results from different sources are not directly comparable. Prompt templates, the available toolset, step and time budgets, and whether network access is allowed — any one of these can change the outcome significantly. Numbers published by different teams lack strict comparability.
- Sampling methodology differs. A single run, the average over multiple runs, and the best pass rate across samples (pass@k style) are three different measures, and mixing them leads to wrong conclusions.
- Pass rate is not code quality. An agent may “pass” by hard-coding special cases, skipping test cases, or loosening assertions. Verifiers must therefore be isolated from the production code path and paired with diff review.
4. Breaking long-horizon capability into four observable dimensions
An overall score can only rank; metrics are what guide improvement. Fine-grained observation is best organized along these dimensions:
| Dimension | Metrics to observe |
|---|---|
| Task planning | First-solution rate, average number of iterations, whether the agent reads before it writes |
| Tool orchestration | Degree of parallelism, share of invalid commands, number of repeated commands |
| Error recovery | Fix success rate after the first failure, whether the agent loops on the same mistake |
| Context management | Forgetting rate in long sessions, cross-file reference consistency, context occupancy over time |
For example, a high share of invalid commands suggests the agent lacks prior understanding of the repository structure, while a low fix success rate after the first failure points to insufficient log parsing and causal reasoning ability. Such metrics cannot be derived from the aggregate score; they have to be instrumented and collected inside the execution trace.
5. Building a reusable evaluation pipeline
It helps to split the evaluation system into five replaceable components so that it is not tightly coupled to a specific model or tool:
- Task set: maintained declaratively (identifier, snapshot, prompt, verify command, budget, category) and put under version control.
- Sandbox executor: responsible for snapshot restoration, command execution, timeouts, and resource limits.
- Agent adapter layer: a unified interface that hides differences between model and tool implementations, making it easy to swap them in and out.
- Verifier: run and maintained independently, and off-limits to modification by the agent.
- Aggregation and dashboards: output overall pass rate, stratified pass rates, cost distribution, and regression trends.
Key implementation points for budgets and isolation:
# Evaluation configuration example (illustrative)sandbox:snapshot: task-<id>.tarcpu_limit: 2memory_limit: 4Ginetwork: disabledagent:max_steps: 60wall_clock: 900sverifier:command: ["bash", "run_tests.sh"]isolated_from_agent: true
6. Combining internal and public benchmarks
The two serve different roles and both are worth keeping:
- Public or standard benchmarks provide external comparability and guard against overfitting, answering “where does the overall level stand?”
- Internal benchmarks are drawn from real business repositories and real incident tickets, answering “can it deliver my work?” Their task distribution closely matches the actual workload, giving a higher signal-to-noise ratio.
In practice, it is worth turning the internal benchmark into a regression gate: when the model, prompts, or toolchain change, automatically run a sampled subset and set thresholds for pass rate and cost, blocking the release as soon as a regression appears. Compared with one-off evaluation, continuous regression is far better at preventing capabilities from quietly degrading.
7. Production readiness checklist
- Least privilege: temporary credentials, read-only mounts for sensitive directories, authorization granted on demand, so the agent cannot reach production resources beyond its scope.
- End-to-end observability: command-level audit logs, structured logging, anomaly alerting, and trace tracking, so that any automated change can be traced back.
- Cost control: image layer caching, combined constraints on concurrency and timeouts, and return-on-investment statistics broken down by task category.
- Human-in-the-loop boundaries: operations involving data migration, permission changes, and destructive deletions keep a human confirmation step; automatically produced changes enter the normal code review process as diffs.
- Platform hosting: container platforms handle sandbox orchestration and elastic scaling, an image registry manages environment snapshot versions, and the monitoring and alerting stack keeps both evaluation runs and production tasks observable. Mainstream cloud platforms such as Baidu AI Cloud offer general-purpose categories for these capabilities; isolation strength and elasticity are the primary criteria when selecting among them.
Conclusion
The value of terminal benchmarks does not lie in producing a nice-looking aggregate score. It lies in turning the vague question “can this coding agent write code?” into an engineering problem that can be measured, stratified, and regression-tested. When evaluation moves from single-point scores to trace-level metrics, teams can finally pinpoint the actual weakness — insufficient planning, weak recovery, or context management out of control — and iterate on the model and the toolchain accordingly.
