Quantitative Evaluation and Selection of Local Code Agents: Methods and Practices
This article explores how to design a reproducible, explainable, and practical quantitative evaluation framework for local code agents. Moving beyond simple task pass rates, it details the integration of process, quality, and cost metrics, and provides insights into task design, core metric interpretation, typical quantization strategies, scenario-based selection matrices, and deployment best practices.
In the practice of deploying local code agents, many teams initially focus on a single metric: whether the task passes. However, as model capabilities gradually cover basic defect fixing, “can it be done correctly” gives way to “how much does it cost,” “is the process controllable,” “is the code maintainable,” and “can it recover from failure.” The horizontal comparisons common in public evaluations essentially reflect the trade-offs between different quantization strategies, inference engine characteristics, and agent working modes. This article does not review or recommend specific products. Instead, it abstracts such evaluations into a general methodology, discussing how to design a reproducible, explainable, and practical quantitative evaluation and selection scheme for local code agents.
1. Why Task Pass Rate Alone is Insufficient
Task pass rate is the most intuitive metric, but it suffers from obvious saturation issues. When multiple solutions can all handle basic tool calling, defect fixing, and application building, the pass rate fails to distinguish between efficiency and engineering quality. At this point, at least four types of process metrics must be supplemented: completion time, output volume, interaction turns, and cache hit rate, as well as quality metrics such as code standard compliance rate, test case count, and failure recovery rate.
Completion time reflects end-to-end efficiency, but it is jointly influenced by hardware, inference engine, batching strategy, and task scheduling, meaning it cannot simply be equated with model capability. Output volume reflects whether the model tends to complete tasks with less content; less output means higher throughput, but it may sacrifice comments, edge-case handling, and maintainability. Interaction turns reflect the agent’s planning ability and self-correction frequency; fewer turns usually mean clear planning and stable context, but can also indicate insufficient exploration. Cache hit rate directly impacts the computational cost of local inference. Especially in scenarios with long contexts, repetitive system prompts, and multi-turn tool calls, a high cache hit rate can significantly reduce redundant computation.
Therefore, a reasonable evaluation should use “pass rate as the threshold, process metrics for differentiation, quality metrics as constraints, and cost metrics as the decision basis,” rather than replacing engineering judgment with a single benchmark score.
2. Evaluation Environment and Task Design
A trustworthy local evaluation first requires a fixed environment. In dual-machine local inference scenarios, hardware configurations, driver versions, inference engine versions, quantization configurations, context lengths, concurrency levels, and tool execution sandboxes should be standardized. If these variables change, the comparability of completion time and cache hit rate will rapidly degrade. Evaluation tasks should be run in isolated containers to avoid the impact of network fluctuations, dependency differences, and residual states on the results.
The task set is recommended to be designed in layers. The first layer is tool-calling capability, requiring the agent to choose among various native tools, pass parameters, read results, and act based on feedback. The second layer is defect fixing, containing multiple small-scale defects covering syntax, logic, edge conditions, exception handling, and regression verification. The third layer is application building, requiring the completion of a project with multiple types of checks from scratch, such as directory structure, configuration, interface behavior, data validation, error handling, and automated testing. Checks should be executed automatically by machines, including compilation or parsing checks, static standard checks, unit tests, behavioral acceptance, and artifact integrity checks, to avoid subjective bias introduced by model judges.
Below is a general pseudocode illustrating the evaluation loop, which does not represent any specific API:
procedure run_case(runner, task):ctx = init_context(task)trace = []for turn in 1..max_turns:plan = runner.plan(ctx)action = runner.act(ctx, plan)observation = execute_tool_in_sandbox(action)trace.append(turn, plan, action, observation)if task.done(observation):breakscore = auto_grade(trace, task.checks)return metrics(trace, score)
The key to this loop is that all tool executions are completed within a sandbox, all intermediate artifacts are traceable, and the final scoring relies solely on deterministic checkers. This prevents situations where a task “looks complete” but is actually non-functional.
3. Definition and Interpretation of Core Metrics
Completion time should be broken down into first-token response time, tool execution time, model inference time, and wait time. Logging only the total duration can easily misattribute a tool bottleneck as a model bottleneck. Output volume should measure the total amount of content generated by the model, combined with task complexity, to observe whether “conciseness” comes at the cost of maintainability. Interaction turns should distinguish between effective turns and repetitive turns; excessive repetitive turns indicate issues with context management or plan execution.
Prompt cache hit rate is an important metric for local inference costs. A high hit rate usually results from stable system prompts, minimal context disturbance, and a plan-first execution approach. It does not directly indicate code quality, but it affects the cost per task and the feasibility of autonomous background operation. The number of test cases and the standard compliance rate are used to measure engineering quality: more test cases do not necessarily mean correctness, but they reflect whether the model actively covers edge cases; a high standard compliance rate indicates the code is closer to team-mergeable standards.
Additionally, the failure recovery rate should be recorded: when a tool returns an error, a check fails, or the context limit is exceeded, can the agent identify the problem and adjust its strategy? This metric is closer to real-world development scenarios than a one-time pass rate.
4. Anonymized Observations Under Three Quantization Strategies
By abstracting a local dual-machine evaluation, three typical working modes can be observed. Solution A uses lower-bit weight quantization and outputs extremely concisely, tending to complete tasks with minimal content. In relative comparisons, it has the shortest application building time. The reason is not necessarily that the underlying inference engine is the fastest, but that the total output volume is small and ineffective exploration is minimal. The risk is that comments, documentation, edge-case coverage, and long-term maintainability may be insufficient, making it suitable for rapid prototyping and short-chain tasks.
Solution B uses higher-precision quantization, tending to formulate a plan first before executing step-by-step. It has the fewest interaction turns and a relatively high prompt cache hit rate. Its computational cost is relatively controllable, and the process is clear, making it suitable for autonomous background operation and long-task scheduling. However, a plan-first approach can also lead to rigidity: when tool feedback is inconsistent with the plan, if the self-correction capability is insufficient, it may continue executing along an incorrect path.
Solution C uses low-bit floating-point quantization and performs more internal reasoning during each interaction turn. It has the longest completion time, but the produced code typically has better standard compliance and more test cases, resulting in more stable engineering quality. The trade-off is high computational cost and slow response, making it suitable for pre-merge checks or complex refactoring scenarios where quality is prioritized and longer wait times are acceptable.
It must be emphasized that the above is an abstract summary of a class of evaluation phenomena and cannot replace multiple repeated experiments. Single runs, a single tech stack, and a limited task set are susceptible to randomness and environmental noise. Conclusions should be validated through multiple runs, confidence intervals, and layered task statistics.
5. Scenario-Based Selection Matrix
For daily iterative development, priority should be given to solutions with good planning, fewer interaction turns, and high cache hit rates to balance efficiency and cost; while retaining quality checkers as a safety net. For autonomous background operation, attention should be paid to failure recovery rate, log traceability, and cost per task, avoiding solutions with verbose outputs and excessive repetitive exploration. For rapid prototyping scenarios, lower test coverage is acceptable, and solutions with concise outputs and short completion times should be prioritized, but standard checks and regression tests must be supplemented before entering production. For quality-priority scenarios, solutions with sufficient internal reasoning, more test cases, and high standard compliance rates should be selected, accepting higher latency and compute consumption.
It is recommended to use a weighted scoring approach during selection rather than single-metric rankings. For example, set the task pass rate as a threshold, and normalize and weight completion time, output volume, interaction turns, cache hit rate, test case count, and standard compliance rate respectively. Weights should be determined by business scenarios and disclosed in the evaluation report to ensure reproducibility.
6. Implementation Practices and Considerations
First, fix versions and record metadata. Every evaluation should record hardware configurations, quantization configurations, inference engine versions, context lengths, task set versions, and scorer versions; otherwise, the results cannot be reproduced. Second, the task set should be layered and extensible, avoiding testing only a single language or a single defect type. Third, the automatic scorer should be as deterministic as possible; compilation, static checks, unit tests, and behavioral acceptance should take precedence over subjective judgments. Fourth, logging and tracing must be comprehensive, retaining plans, tool calls, observations, and failure reasons for each turn to facilitate locating whether the issue lies with the model, the tool, or the task design.
Regarding the deployment of the evaluation pipeline, if your team uses Baidu AI Cloud, you can run isolated evaluation tasks on general-purpose container platforms, use object storage for task sets, intermediate artifacts, and reports, and leverage logging and monitoring services to record turns, latency, and failure reasons. These are general categories; the focus is on building a reproducible, auditable evaluation closed-loop rather than binding to specific APIs.
Finally, a continuous mechanism of “evaluation—selection—regression” should be established. Models, quantization strategies, and inference engines will all be updated, and a one-time evaluation conclusion should not be permanently solidified. It is recommended to run a fixed regression set after each upgrade and set threshold alerts for key metrics. Only by transforming evaluation from a one-time comparison into a continuous engineering practice can the quantitative selection of local code agents truly serve the balance of efficiency, cost, and quality.
