Long-Horizon Coding Agents: Evaluation Design and Engineering Practices
Evaluating coding agents requires more than checking whether they can generate correct code in a short interaction. This article explains how to assess long-horizon performance with reproducible tasks, constrained environments, and executable acceptance checks. It also covers common failure modes, context management, sandboxing, audit trails, and a practical framework for building an internal evaluation suite.
Coding agents are moving beyond completing individual functions toward finishing work in real software projects. Short tasks can reward local pattern matching. Long-horizon tasks require an agent to maintain its objective across repeated tool calls, manage intermediate state, respect environmental constraints, and deliver results that tests can verify.
For development teams, the key question is not whether a single demonstration looks smooth. It is whether the agent can consistently pass task-specific acceptance checks when terminal permissions, dependencies, time, and compute resources are limited.
Why Long-Horizon Capability Matters
Changing a few lines in a conversation is fundamentally different from locating a defect in a repository, modifying the implementation, passing regression tests, and handling side effects. Long-horizon tasks typically have four characteristics:
- The objective spans multiple steps. Requirements often involve interface behavior, edge cases, and existing callers. A change that merely looks correct is not enough.
- The environment is real and constrained. Filesystem access, dependency installation, networking, processes, and time limits can all cause failures. The agent must adapt to errors rather than assume unlimited resources.
- Acceptance is executable. Each task should have independent tests or checking scripts that determine success through exit codes and assertions, not subjective human impressions.
- The execution trace is long. Logs, patches, and failed attempts fill the context, making early constraints easier to forget.
Improvements in coding capability should therefore be measured through both correctness on individual steps and completion rates over extended tasks. Better performance on short questions alone does not establish engineering usefulness.
What an Evaluation Should Measure
A reliable evaluation defines and fixes the tasks, environment, and scoring separately so that results can be reproduced.
Tasks: Real Development Work
Tasks should come from realistic development scenarios rather than recall-based questions. A representative set can include:
- Implementing a feature from a specification.
- Fixing a defect with reproducible steps.
- Refactoring without changing public behavior.
- Adding missing tests.
- Resolving dependency conflicts.
- Investigating a problem under read-only restrictions.
Each task should target one primary capability while allowing necessary supporting steps. Otherwise, skills such as interpreting errors and modifying an algorithm become entangled in a score that is difficult to explain.
Environment: Consistent Resource Limits
Use a consistent base image, locked dependencies, account permissions, CPU limits, and time limits. Prevent files from carrying over between tasks.
Disable network access where possible. When outbound access is necessary, restrict it with an allowlist. This helps measure planning and troubleshooting rather than an agent’s ability to download an arbitrary package by chance.
Scoring: Task-Specific Checks
Use tests for functionality, static checks for style and security, and contract checks for documentation and interface changes.
Record more than whether the task passed:
- Number of attempts.
- Number of tool calls.
- Wall-clock time.
- Whether prohibited paths were touched.
- Whether failures can be reproduced.
Two execution traces with the same pass rate can have very different engineering implications. An agent that makes the correct change on its first attempt is not equivalent to one that repeatedly overwrites user files before succeeding.
Comparisons: Control the Conditions
Scores are not directly comparable if environment images, time limits, retry policies, or scoring scripts differ.
When differences are small, examine variance, task coverage, and scoring noise before ranking capabilities. Internal baselines are often more useful: consistent gains on difficult tasks within the same long-horizon coding suite provide stronger evidence than a single public score.
Do not use fabricated or irreproducible leaderboard results as a basis for procurement decisions.
Common Failure Modes
Failures in long-horizon work are often caused by loss of process control rather than an inability to write valid syntax.
- Goal drift: Logs distract the agent, leading it to modify files unrelated to acceptance criteria.
- Local optimization: The agent weakens assertions, skips cases, or hardcodes outputs to make the current test pass.
- State loss: After several rounds, the agent forgets the original interface constraints or produces patches that overwrite earlier work.
- Tool misuse: Repeated full-repository searches or unnecessary dependency reinstalls exhaust the time budget.
- Environment misdiagnosis: The agent treats insufficient permissions as a logic error or repeatedly retries writes to a read-only directory.
- Missing verification: The agent marks a task complete after reading code without running tests.
- Hidden side effects: Changes to global configuration or locked dependencies break other tasks or later steps.
Include these failure modes as evaluation labels. Knowing which category a failure belongs to makes it easier to improve prompts, tool permissions, or task descriptions.
Build an Executable Plan–Execute–Verify–Rollback Loop
A practical workflow uses small, verifiable steps instead of generating a repository-wide patch in one pass.
Plan
Produce a short plan with testable steps:
- Which modules need to change.
- What behavior is expected.
- How acceptance will be checked.
- Which paths must remain untouched.
Keep the plan concise, and do not present unverified design assumptions as facts.
Execute
Limit the scope of each step. Modify only files relevant to the current hypothesis, and retain a description of the patch.
Truncate and summarize tool output. Keep important errors, failed assertions, and file paths in context while discarding repetitive logs.
Verify
Use tests as a gate. Run the smallest relevant test set first, followed by the agreed regression suite.
If verification fails, feed the assertion differences into the next step rather than adding the entire terminal transcript to the context.
Roll Back
Make every change reversible. Never “fix” a failure by deleting tests. At the end of the task, the workspace should contain only changes relevant to the objective.
The following generic pseudocode illustrates evaluator logic, not a specific product API:
for step in range(max_steps):action = agent.decide(goal, observations, constraints)if action.touches(forbidden_paths):record("policy_violation")breakresult = sandbox.run(action, timeout=step_limit)observations.append(summarize(result))if harness.tests_pass(task.checks):record("pass", steps=step + 1)breakelse:record("fail", reason="budget_exhausted")
Budgets should cover steps, elapsed time, and tool failures. An evaluation without budgets rewards unlimited retries and does not reflect real operating costs.
Context, Memory, and Repository Understanding
The bottleneck in long-horizon coding is often information organization, not the length of a single generated response.
Separate repository facts from interaction history. Facts include directory structure, public interfaces, test commands, and confirmed failing assertions. Interaction history includes trial-and-error logs.
Compress facts into a stable summary and retain only recent, relevant portions of the history. When referencing code, include file paths and line ranges so the agent does not modify the wrong file from memory.
For large repositories, narrow the search space first. Map the task description to likely modules, then inspect relevant tests and callers. Aimless traversal increases noise and the likelihood of unrelated changes.
Memory must support invalidation. When dependency versions or interface signatures change, discard or revalidate old summaries. Treating outdated conclusions as current facts is a common reason agents break working code late in a task.
Permissions, Sandboxing, and Auditability
Coding agents should run in isolated environments by default, with:
- An independent working copy.
- Minimal filesystem permissions.
- Restricted networking.
- Processes that can be terminated and cleaned up.
- Write access limited to the task workspace.
Do not include secrets or production configuration in evaluation images.
Audit records should contain at least the task identifier, model and prompt versions, tool-call sequence, patches, test commands and results, and resource consumption. These records help explain why a task passed or why the agent violated a constraint. Logs must not contain credentials.
Human and agent responsibilities should remain explicit. The agent drafts changes and runs acceptance checks; reviewers approve merges. Passing automated tests does not eliminate the need for code review, particularly for changes involving permissions, data migrations, or externally visible behavior.
For evaluations running on container platforms, use immutable images and task-level isolation. Object storage is appropriate for logs and patch artifacts, but writable production data should not be mounted into the evaluation environment. These are general engineering practices, not capabilities tied to a particular vendor.
Building an Internal Long-Horizon Coding Evaluation
Start with a small, rigorous suite rather than trying to create a large leaderboard.
Select Reproducible Tasks
Choose 20 to 50 reproducible tasks from your team’s actual defects and requirements. Cover implementation, bug fixing, refactoring, and missing tests.
For each task, specify the initial state, permitted operations, acceptance commands, and timeout. Exclude tasks that depend on external accounts or data that cannot be reproduced.
Separate Short and Long Tasks
Use short tasks to assess basic editing and code location. Use long tasks to assess cross-file changes and recovery after repeated failures.
Report the groups separately so that strong short-task performance does not hide weaknesses in long-horizon work.
Stabilize the Evaluation
Lock dependencies and the base environment. Fix random seeds where possible, and record sources of variation that cannot be eliminated.
Run the same version multiple times and report a pass-rate interval rather than the best single result.
Prevent Leakage
Do not include solution patches in task descriptions. Keep public examples separate from hidden acceptance checks.
Replace some tasks periodically to prevent prompts from effectively memorizing old answers.
Check for Regressions
After a capability update, evaluate both new and existing tasks. Improvement on new tasks accompanied by decline on old ones may indicate overfitting to a class of prompts rather than a general gain in long-horizon capability.
Interpret Quality, Violations, and Cost Together
Track pass rates, constraint-violation rates, and costs together. A higher pass rate accompanied by more violations or more exhausted time budgets should not be treated as evidence of deployment readiness.
Label failed runs and prioritize common failure modes, such as skipping tests or forgetting constraints.
Boundaries for Practical Deployment
Agents are best suited to changes with clear specifications, automated tests, and reversible failures. They are poorly suited to work without acceptance criteria, operations requiring production write access, or actions where one mistake carries a high cost.
Explicit goals, non-goals, and acceptance commands are more useful than elaborate role descriptions. For example:
Keep externally visible response fields unchanged. Modify only the internal cache invalidation logic, and ensure the specified test command completes with zero failures.
A vague request such as “optimize this” can encourage broad, unrelated changes.
Human reviewers should still inspect diffs for weakened tests, expanded permissions, unnecessary dependencies, and conflicts with existing error-handling conventions. Agent-generated explanations are clues, not evidence. The patch and test output remain the basis for verification.
Conclusion
Long-horizon coding capability should be measured through constrained terminal environments and task-specific acceptance checks. Evaluation design matters more than rankings: fix the environment, use independent tests, record execution traces and costs, and compare versions on the same internal task suite.
In practice, small changes, mandatory verification, reversible steps, and minimal permissions turn “can write code” into “can deliver a verifiable change.” The result is a reproducible quality signal rather than a demonstration score that may not transfer to real engineering work.
