Evaluating LLMs for Agentic Coding: A Practical Framework

    This article presents a practical framework for evaluating large language models in agentic coding scenarios. It explains why benchmark scores and subjective chat impressions are insufficient, how to define evaluation scope and cost accounting, which dimensions to measure, and how to design a reproducible evaluation process. It also covers scoring consistency, common pitfalls, tiered model selection, and cloud-based evaluation environments. The goal is to help teams compare models by task completion, deliverable quality, self-testing, instruction following, UI fidelity, cost, latency, knowledge breadth, and stability, and use the results for concrete technical decisions.

    1. Why Evaluation Needs to Be Redefined

    In the past, large language models were often evaluated by benchmark scores or subjective impressions from a few rounds of conversation. These methods are generally sufficient for question-answering scenarios, but they have limited reference value in agent scenarios. An agent needs to autonomously decompose tasks, call tools, run tests, fix issues, and ultimately deliver usable artifacts. A single correct answer does not mean the model can complete a development task that involves multiple files and multiple steps.

    R&D teams usually care about specific questions: Can the model complete the task independently? How many human fixes are needed? How many tokens are consumed? How long does it take? Can the artifacts be merged or delivered directly? These questions cannot be answered from a single score. Therefore, evaluation should be designed around real tasks and compare delivery results, process quality, and resource consumption in the same table.

    2. Define Scope Before Evaluation

    Before formal testing, three things need to be determined.

    First, the scenario boundary. Coding, document generation, interface prototyping, data analysis, and knowledge Q&A place very different demands on model capabilities. A model that performs well in code generation may not be suitable for design communication that requires broad knowledge. The evaluation report should clearly state which type of scenario was tested.

    Second, versions and parameters. Model versions, tool versions, system prompts, temperature, and other sampling parameters all affect results. These variables should be fixed during testing and recorded item by item in the report. Otherwise, results from different batches cannot be compared.

    Third, the cost accounting method. It should be agreed in advance whether input and output tokens are priced separately or converted into a unified rate. If tools internally call the model multiple times, all calls should be accumulated rather than counting only the final request.

    3. Core Evaluation Dimensions

    3.1 Task Completion Rate and Delivery Efficiency

    Task completion rate refers to the proportion of tasks whose artifacts pass acceptance test cases without human intervention. It is the most direct metric. Delivery efficiency needs to combine time consumption with the number of human interventions. A model may take a very short time per run, but if each task requires three human edits, actual efficiency is not high. It is recommended to record both end-to-end time and the number of human fixes.

    3.2 Code and Artifact Quality

    Code quality can be evaluated from four aspects: correctness, edge-case handling, maintainability, and style consistency. Correctness is verified by test cases. Edge-case handling focuses on whether there are reasonable responses to empty input, invalid input, and concurrency scenarios. Maintainability looks at whether naming, module division, and comments are clear. Style consistency checks whether artifacts follow existing project conventions.

    Code produced directly and code after self-testing and fixes should be recorded separately. The gap between the two reflects the model’s baseline capability and its error-correction capability.

    3.3 Self-Testing and Validation Capability

    Self-testing capability refers to the model’s ability to proactively run tests, inspect outputs, and correct issues before delivery. Evaluation should not look only at the number of self-tests. A high number of tests with very narrow coverage may still miss key issues. More useful metrics include whether self-testing covers the main functional paths, whether it discovers real defects, and whether the model can accurately interpret the meaning of test results.

    3.4 Instruction-Following Precision

    Real prompts often contain small constraints, such as output format, variable naming, language version, word limits, or a field that must be preserved. Instruction-following precision measures how well the model handles these details. A set of explicit constraints can be listed for each task and checked one by one. The proportion of constraints satisfied is the score for this dimension.

    This dimension is easy to overlook. A model may complete the main functionality but ignore two of three requirements, leaving the artifact in need of manual rework.

    3.5 Interface and Visual Details

    For tasks involving interfaces, the alignment between artifacts and design specifications needs to be checked, including spacing, font size, color, responsive layout, and copy spelling. These issues are usually not found by functional tests and can only be checked manually or with screenshot comparison tools. Scoring can use three grades: ready to use, minor fixes needed, and rework needed, with the number in each grade recorded.

    3.6 Cost and Latency

    Cost metrics should be converted into cost per delivered task, that is, the cost of completing one task that passes acceptance. A low cost per call does not mean low overall cost. If the model needs more rounds to complete a task, or if artifacts require more human fixes, total cost may still be higher.

    Latency affects the interaction experience. In batch processing scenarios, throughput is more important than single-call latency. In scenarios that require real-time collaboration, both first-token response time and overall completion time are worth attention.

    3.7 Knowledge Breadth and Context Understanding

    In design communication, requirements discussions, and document writing, the model’s grasp of professional terminology, industry background, and niche knowledge directly affects collaboration efficiency. This dimension can be evaluated through a set of business-related Q&A questions. The questions should cover both common and long-tail domains, and domain experts should score them.

    3.8 Stability

    Running the same task multiple times may produce very different results. Stability metrics measure this fluctuation. It is recommended to run each task at least three times, use the median as the representative value, and record both the lowest and highest scores. The median reduces the impact of occasional anomalies on conclusions.

    4. Evaluation Process Design

    A reproducible evaluation process usually includes the following steps.

    1. Build a task set. Tasks are divided into simple, medium, and complex levels, with each level covering typical needs in real business. Each task comes with acceptance test cases, reference answers, and a constraint list.
    2. Fix the environment. Record model versions, tool versions, system prompts, and sampling parameters, and generate a unique ID for each run.
    3. Execute tasks. The model runs under the same initial conditions without human hints during the process. All call records, tool logs, and intermediate artifacts must be saved.
    4. Score. Automated tests handle functional acceptance, while humans handle quality and visual scoring. Raters should remain blind to model identity to reduce subjective bias.
    5. Aggregate and analyze. Calculate metrics such as pass rate, median score, and cost per delivery, and retain raw data for review.

    The following example summarizes the results of a single evaluation run and shows how to convert process data into comparable metrics.

    1. from dataclasses import dataclass
    2. from statistics import median
    3. @dataclass
    4. class TrialResult:
    5. task_id: str
    6. passed: bool # Whether all acceptance tests passed
    7. score: float # Overall score, 0 to 100
    8. tokens: int # Total tokens consumed in this run
    9. human_fixes: int # Number of human fixes
    10. seconds: float # End-to-end time in seconds
    11. def summarize(results: list[TrialResult], price_per_1k: float) -> dict:
    12. if not results:
    13. raise ValueError("results must not be empty")
    14. passed_count = sum(1 for r in results if r.passed)
    15. total_tokens = sum(r.tokens for r in results)
    16. total_cost = total_tokens / 1000 * price_per_1k
    17. cost_per_pass = total_cost / passed_count if passed_count else float("inf")
    18. return {
    19. "pass_rate": round(passed_count / len(results), 3),
    20. "median_score": median([r.score for r in results]),
    21. "avg_human_fixes": round(sum(r.human_fixes for r in results) / len(results), 2),
    22. "median_seconds": median([r.seconds for r in results]),
    23. "cost_per_pass": round(cost_per_pass, 4),
    24. }

    The output of this function can be copied directly into an evaluation report. When comparing multiple models, use the same task set and the same aggregation method for their results.

    5. Scoring Standards and Consistency

    Scoring standards need to be written as specific check items rather than vague judgments such as “good” or “bad.” For example, code quality can be split into items such as “functions have a single responsibility,” “exception branches are complete,” and “no duplicate logic.” Each satisfied item earns one point.

    When multiple people participate in scoring, inter-rater consistency should be calculated. Common metrics include Cohen’s kappa. When consistency is low, it indicates that the standard description is unclear, and the scoring rubric should be revised before re-scoring.

    For visual and copy scoring, it is recommended that two people score independently first, and samples with large disagreements are reviewed by a third person. The review ratio should be noted in the report.

    6. Common Pitfalls

    First, looking only at a single leaderboard score. Benchmark scores measure performance on specific question types, and their match with concrete business scenarios may not be high.

    Second, looking only at first output. The model’s error-correction and self-testing capabilities also affect final delivery. Ignoring this part underestimates the actual value of some models.

    Third, treating the number of tests as quality. A high number of self-tests only means the model ran more checks; it does not mean the checks covered critical paths.

    Fourth, ignoring cost. A low unit-price model may require more rounds and human fixes, making the final cost higher.

    Fifth, using too few samples. Results from ten tasks are easily affected by chance. A formal evaluation should include at least dozens of tasks and cover all difficulty levels.

    Sixth, unfair prompts. Optimizing prompts specifically for one model and then comparing it with an unoptimized model produces conclusions with no reference value. All models should use the same prompt set, or each should be optimized separately before comparison.

    7. Model Selection and Tiered Usage

    Evaluation results ultimately serve model selection. Different models have different strengths in speed, cost, quality, and knowledge breadth. A single model can hardly lead in all dimensions.

    A common approach is tiered usage. For batch generation, first-draft writing, and large numbers of repetitive tasks, choose a model with low unit cost and high throughput. For critical module design, complex logical reasoning, and code review, choose a model with more stable quality. The outputs of the two types of models can be connected through manual or automated workflows to balance cost and quality.

    In addition, the boundaries of model usage need to be clear. For tasks that require strict correctness, automated testing and human review should be retained. A model should not be put into production simply because its self-tests pass.

    When building an evaluation environment on cloud platforms such as Baidu AI Cloud, teams can use object storage to keep task sets and artifacts, logging to record call chains, and monitoring and alerting to track cost and failure rates. These general capabilities make the evaluation process traceable and the conclusions easier to review.

    8. Conclusion

    The goal of evaluating large language models is to find the right tool for specific tasks, not to produce an absolute ranking of models. As long as the task set is close to real needs, metric definitions are consistent, and process data is fully preserved, evaluation conclusions can support a team’s technical decisions and enable rapid re-testing after model version updates.