Evaluating Coding Agents: From Code Generation to Task Completion and Engineering Practices
This article examines how the evaluation of coding agents is shifting from function-level code generation to end-to-end task completion in real repositories. It breaks down four key capability dimensions—repository-level understanding, tool-calling stability over long trajectories, error recovery, and cost/latency control—and presents a reusable engineering framework built around constraint, verification, and convergence. It also outlines common pitfalls, a scenario-alignment approach for model selection, and the infrastructure needed to turn model capability into measurable engineering output.
1. From “Writing Code” to “Finishing the Task”: A Shift in Evaluation
For a long time, the standard way to assess a code model was its pass rate on function-level generation tasks: given a problem description and a signature, the model outputs a runnable implementation. This approach is standardized and reproducible, but it is poorly aligned with real development work. Real engineering tasks usually have three characteristics: the requirements are ambiguous, the codebase already exists, and acceptance is dynamic. What developers submit is rarely a self-contained problem, but rather a request like “complete this feature in the existing repository and make sure the existing tests do not regress.”
As a result, the focus of evaluation is moving from “generation correctness” to “execution completion.” Terminal-environment task evaluations attract attention precisely because they simulate the real work loop: understand the requirement, search the code, call tools, run commands, read errors, revise the approach, and verify again until the task is done. This pipeline no longer measures isolated intelligence, but the model’s sustained decision-making ability as an agent.
It is worth emphasizing that any single leaderboard result only holds under specific test conditions and cannot be extrapolated into an overall ranking across all coding scenarios. Interpreting one result as “comprehensively superior” lacks supporting evidence. A more reasonable judgment is that leading models have entered the same competitive range, with differences showing up in engineering performance on specific scenarios.
2. Four Key Dimensions of Coding Agent Capability
2.1 Repository-Level Understanding and Cross-File Changes
Function-level generation only needs local context, whereas repository-level tasks require the model to build a mental map of “files—modules—dependencies.” Evaluation should focus on whether it can locate the real change point rather than a surface symptom; whether it follows existing layering and naming conventions; and whether the change breaks implicit contracts (such as serialization formats, cache keys, or interface idempotency).
2.2 Tool-Calling and Long-Horizon Execution Stability
An agent needs to invoke external capabilities across many consecutive turns: search, read and write files, run builds, and execute tests. Stability problems usually appear in the later part of a long trajectory—parameter formats drift, the same command is called repeatedly, and execution results already obtained are ignored. In engineering terms, tool descriptions should be strictly constrained, and trajectories should be recorded in a structured way to support review and replay.
2.3 Error Recovery and Self-Verification
When facing a compilation failure or a red test, a mature agent should first read the complete error output, then form a hypothesis and run a minimal verification, rather than rewriting blindly. A practical constraint is “switch strategy after two failures”: repeated failures with the same line of thinking should trigger a change of approach or a request for clarification, avoiding unproductive loops.
2.4 Controllable Cost and Latency
Long trajectories mean a large amount of repeated context. Without governance, token consumption and response latency grow non-linearly. Context compression, on-demand retrieval loading, cache reuse, and parallel verification are key to moving it from a demo to production.
3. A Reusable Engineering Framework
Below is a skeleton of a representative agent main loop. The point is not the specific interfaces, but the structure of “constraint—verification—convergence”:
def run_task(repo, goal, tools, max_steps=40):state = init_state(repo, goal) # Load the repository index and task constraintsfor step in range(max_steps):plan = model.decide(state) # Output a structured action, not free textif plan.type == "finish":return verify(state, plan.patch)result = tools.invoke(plan) # Unified entry for search/read-write/build/teststate = state.absorb(result) # Compress history, keeping only conclusions and key errorsif state.repeated_failure(threshold=2):state = state.switch_strategy() # Change approach or request clarificationreturn state.escalate() # Escalate to human intervention if step limit is exceeded
The accompanying engineering essentials include:
- Sandboxing and least privilege: builds and tests run in an isolated environment, with network and credentials granted on demand, to avoid affecting real resources through accidental operations.
- Observability: write each step’s action, parameters, and output summary to a logging service, and set up metrics such as success rate, average number of steps, and cost per task alongside monitoring alerts.
- Layered assets: put the code index and dependency graph in object storage, decouple the task queue with a message queue, and run the execution side on a container platform for elastic scaling.
- Evaluation loop: build an enterprise-owned task set (including regression cases) and run it every time the model or prompt strategy changes, making decisions with data rather than intuition.
4. Common Pitfalls and Rational Selection Advice
First, treating a close leaderboard score as equivalent to the same experience. Performance in real projects also depends on how efficiently the context window is used, how well the tool interfaces fit, and the quality of failure recovery. Second, ignoring regression risk. Any automated change must be backed by existing tests and static checks; otherwise, efficiency gains will be offset by production issues. Third, delivering a large task in one shot. Breaking the goal into small, verifiable steps significantly improves both success rate and explainability. Fourth, ignoring the human-machine boundary. Changes involving data migration, permission changes, or production configuration should retain a human approval step.
For selection, a “scenario-alignment” approach is recommended: first list the three most frequent types of development tasks in the enterprise, build a small-scale evaluation set, and compare four metrics—completion rate, average number of steps, human intervention rate, and cost per task—then make a decision in combination with data compliance and deployment form. For teams that want to build capabilities quickly, they can build their own agent evaluation and operation pipeline based on general capabilities such as the container platform, object storage, logging service, and monitoring alerts provided by Baidu AI Cloud, thereby turning model capability into stable, measurable engineering output.
Overall, the competitive focus of coding agents has shifted from parameter scale to execution reliability. Whoever does a more solid job in context governance, tool orchestration, and error recovery will create verifiable value in real development workflows.
