How to Evaluate AI Coding Agents: From Writing Code to Engineering Work
AI coding agents are moving from single-function code generation to completing real engineering tasks inside existing codebases. This article explains why evaluation criteria must shift accordingly, breaks down five core engineering capabilities, and provides a practical guide to building your own internal evaluation set, managing long context, tracking cost and reliability metrics, and rolling out agents safely within a team.
Why Evaluation Criteria Need to Change
Early evaluations of code models typically followed a simple pattern: give the model a function specification, let it generate an implementation, and check the result with unit tests. This approach measures only local code generation ability. In day-to-day development, however, local generation accounts for only a small fraction of the work. Real tasks usually happen inside an existing codebase, requirements are often incomplete, changes span multiple files, and existing functionality must not break.
The focus of evaluation should therefore shift from “can it write code” to “can it complete engineering tasks.” An engineering task generally goes through four stages: understanding the requirements and current state of the code, locating the files that need to change, executing the changes and verifying the results, and diagnosing failures and continuing after setbacks. Every stage can go wrong, so evaluation needs to cover the entire chain rather than only the final output.
Breaking Down Engineering Execution Capability
The capabilities that determine the final outcome can be broken into five areas:
- Codebase understanding: Can the agent locate relevant code based on directory structure, module dependencies, and naming conventions? Judge this by the number of steps needed to find the correct files and how many task-irrelevant files it reads.
- Cross-file modification: A single requirement often touches interface definitions, callers, and test code simultaneously. Judge this by whether changes are complete and whether required companion edits were missed.
- Tool-calling reliability: Running commands in a terminal, parsing output, and handling path or permission errors. Judge this by call success rates and whether the model repeatedly executes the same ineffective command.
- Error recovery: After a test failure, can the agent read the error message, form a hypothesis, verify it, and fix the problem? Judge this by the number of rounds between the first failure and a passing test.
- Regression control: Does a change break existing functionality? Judge this by results across the full test suite, not just the newly added test cases.
These five capabilities can be measured independently. Compressing them into a single overall score hides a model’s weaknesses in specific areas. For example, a model may have a high overall pass rate but frequently miss companion changes in cross-file modifications — a problem that will surface quickly in real team usage.
Building Your Own Evaluation Set
Scores on public benchmarks are useful reference points, but they are produced under specific environments and conditions. Your team’s codebase size, tech stack, and development workflow may differ significantly. A more reliable approach is to build an evaluation set from real internal tasks.
Build the evaluation set following these steps:
- Select tasks: Sample from real tickets from the past three months, covering bug fixes, test supplementation, small-module refactoring, API migration, and other task types. Keep samples of varying difficulty for each category.
- Prepare snapshots and verification scripts: For each task, save a starting code snapshot, the requirement description, and an automated verification script. The verification script should produce objective verdicts, such as running a designated test suite and checking the exit code.
- Fix the runtime environment: Standardize the container image, dependency versions, timeout, and tool permissions so different models are compared under identical conditions.
- Record metrics: Include task pass rate, average tool-call count, total time, per-task cost, and number of manual rework rounds.
Here is a simplified illustration of the evaluation workflow:
task = {"id": "fix-timezone-parse-001","repo_snapshot": "snapshots/billing-service@a1f3c","instruction": "Fix the date error caused by timezone offset in billing export","verify": "run tests/export_test.sh","timeout_sec": 900,"max_tool_calls": 60}for task in tasks:env = prepare_sandbox(task["repo_snapshot"])result = agent.run(task["instruction"], env, limits=task)passed = env.run(task["verify"]).exit_code == 0report.add(task["id"], passed, result.tool_calls,result.cost, result.duration)
Two points matter here. First, verification commands are executed by the evaluation framework — the model does not judge for itself whether it passed. Second, each run takes place in an isolated sandbox to prevent historical state from affecting results.
Pass rate alone can also be misleading. A model may make tests pass while modifying files unrelated to the task. Evaluation reports should therefore include a diff review: check whether the scope of changes exceeds what the task requires, and count the number of irrelevant modifications.
Long Context: Capability and Boundaries
Million-token context windows let models ingest large amounts of material at once. When working with large code repositories, lengthy technical documents, or research tasks that require comparing multiple sources, this capability reduces the manual effort of splitting material into chunks.
However, context length and information utilization are two different metrics. The longer the input, the more likely key information is overlooked, especially details in the middle of the context. Across multi-turn reasoning, the model’s conclusions may also become inconsistent. Meanwhile, input size directly affects inference cost and response latency. How much content a window can hold does not equal how reliably the model can use that content.
A more robust approach is to control the input scope and make context management part of workflow design:
- Retrieve first, read later: Use symbol search, keyword matching, and dependency graphs to narrow the scope, and put only relevant files into the context.
- Execute in stages: Break large tasks into three steps — design, code modification, and verification — with each step carrying only the information it needs.
- Maintain task notes: Write confirmed facts, to-do items, and unverified hypotheses into a separate file. Subsequent steps rely on the notes rather than a long conversation history, saving tokens and reducing information drift.
Here is a simplified example of the retrieval stage:
candidates = search_symbols(keyword="export_date")candidates += dependency_graph.neighbors(candidates, depth=1)context_files = rank_by_relevance(candidates)[:8]prompt = build_prompt(task, context_files, notes_file)
The key to this logic is limiting input size. The number of candidate files, dependency expansion depth, and the final number of retained files should all be tunable parameters, with appropriate values determined through your evaluation set.
Cost, Latency, and Reliability
When assessing an agent’s economics, the price of a single API call means little. A more meaningful metric is “cost per successful task.” A model with a low unit price may require many retries to finish a task, ultimately costing more.
Monitor the following metrics together:
- Cost per successful task: Total spend divided by the number of passing tasks.
- Tail latency: For example, the 95th-percentile completion time, which reflects the worst-case waiting experience.
- Failure type distribution: Distinguish timeouts, tool errors, infinite loops, out-of-scope changes, and verification failures to enable targeted improvements.
- Retry count: Reflects the model’s stability in error recovery.
To keep tasks from running out of control, set budget caps for every run, including maximum tool calls, maximum token spend, and timeouts. When a cap is reached, the system should stop execution, preserve complete logs, and notify a human to take over.
Recommendations for Team Adoption
The efficiency gains from agents come with the prerequisite of controllable risk. The following practices apply to most teams:
- Least-privilege access: Agents can only access the repositories needed for the current task and never hold production credentials directly.
- Branch isolation: All changes are made on separate branches and merged only after human review.
- Human checkpoints: Changes to high-risk modules such as database migrations, permission configurations, and payment logic must be reviewed by a human.
- Archive run logs: Save the input, tool-call records, and final diff of every run to analyze model weaknesses and refine prompts and task templates.
- Gradual rollout: Start with tasks like supplementing tests, improving documentation, and fixing low-risk bugs, then expand to feature development as evaluation data accumulates.
When evaluating a coding agent, the key question is whether it can reliably complete tasks under real engineering constraints. Teams should base their judgment on internal evaluation sets and control risk through permissions, branching, and review mechanisms.
