How to Evaluate LLM Coding Capabilities in Agentic Programming Scenarios
Evaluating large language models for coding has traditionally meant checking whether a single function passes unit tests or an algorithm problem produces the right answer. In agentic workflows, however, models must read codebases, plan steps, call tools, edit files, run tests, and iterate on errors over tasks that can last from minutes to hours. This article explains why conventional single-shot evaluation is no longer sufficient, introduces five key evaluation dimensions—task completion rate, code quality, tool call reliability, long-horizon consistency, and efficiency and cost—and shares practical guidance on metrics, cost accounting, and building a reproducible benchmarking process.
1. Why Coding Capability Needs to Be Redefined
The traditional way to evaluate an LLM’s coding ability is to check whether a function passes unit tests or whether an algorithm problem is solved correctly. In agent mode, however, the model must read a codebase, plan steps, call tools, modify files, run tests, and iterate repeatedly based on error messages. Task durations stretch from tens of seconds to tens of minutes, or even hours. At that point, the correctness of a single output no longer fully describes capability—the stability, efficiency, and cost of the entire execution process matter just as much.
An evaluation therefore needs to answer three questions:
- Can the model complete the task?
- Is the process controllable, and are there wasteful loops?
- Is the cost of completion acceptable?
The rest of this article is organized around these three questions.
2. Five Dimensions for Evaluating Coding Capability
2.1 Task Completion Rate
Task completion rate is the proportion of tasks the model ultimately accomplishes under given conditions. The acceptance criteria should be explicit—for example, “all relevant tests pass, and no existing tests are broken.” Relying on the model’s own claim of completion tends to produce optimistic results. Completion rates should be reported per task type, because fixing a small, well-defined bug and refactoring an entire module differ enormously in difficulty; an average across mixed task types is of limited value.
2.2 Code Correctness and Maintainability
Passing tests is only the baseline. You also need to check whether the scope of changes is reasonable, whether new dependencies were introduced, whether naming is consistent with existing conventions, and whether edge cases are handled. Code that runs but is hard to read creates extra cost in later iterations. Manual sampling is essential for this dimension: for instance, randomly select a number of changes based on lines modified and have engineers familiar with the project score them.
2.3 Tool Call Reliability
Nearly every step an agent takes depends on tool calls—reading files, searching for symbols, writing content, executing commands. Common causes of failed calls include misspelled parameter names, non-existent paths, invalid JSON structures, and string escaping errors. Reliability should be tracked with two metrics: the first-attempt success rate of individual calls, and the total number of tool call failures within a single task.
2.4 Long-Horizon Consistency
In long tasks, the model must remember decisions made earlier and keep subsequent actions consistent with them. Common failure modes include forgetting files that were already modified, repeating the same step, or dropping earlier constraints as the context grows. For evaluation, design tasks that span multiple files and multiple rounds of modification, and observe whether the model still honors the original requirements.
2.5 Efficiency and Cost
Efficiency covers both elapsed time and token consumption; Section 4 discusses this in detail. The key here is to look at “how long it took” and “how much was accomplished” together—examining either one in isolation easily leads to one-sided conclusions.
3. Common Patterns of Tool Call Failure
3.1 Parameter Spelling and String Escaping
In long contexts, models sometimes repeatedly output incorrect identifiers—for example, mistyping similar variable names or paths, or failing to escape quotes and newlines in long strings. There are three common engineering approaches:
- Constrained decoding or structured output: Use a schema to restrict field types and allowed values, reducing invalid structures at the source.
- Validation with explicit feedback: When validation fails, return the list of allowed field names and the specific error location to the model rather than silently substituting values.
- The limits of fuzzy matching: Fuzzy matching improves fault tolerance but can silently route a request to the wrong target. For write operations, log fuzzy-matching results and refuse to execute when ambiguity is high.
In addition, set an upper limit on retries for a single call. Once exceeded, hand off to a human or a higher-level policy instead of retrying indefinitely.
3.2 Semantic Repetition with Slight Parameter Tweaks
This is an easily overlooked class of problem. Clients typically detect and block repeated calls with “the same tool and the same parameters.” But the model may tweak just one parameter each time—reading one more line, shifting an offset by one—thereby bypassing exact-match detection. The call still succeeds and nothing appears to violate the rules, yet the model is doing no useful work.
This shows that repetition detection cannot rely solely on literal parameter comparison; it should judge whether there is semantic progress. Below is a simplified example that determines whether progress has stalled based on the target object and a digest of the returned result:
import hashlibfrom collections import defaultdictclass ProgressGuard:"""Detects whether tool calls have stagnated semantically."""def __init__(self, max_stall: int = 5):self.max_stall = max_stallself.last_digest = {} # (tool, target) -> digest of the last resultself.stall_count = defaultdict(int)def record(self, tool: str, target: str, result: str) ->ind: str) -> str美丽的:str) -> str:key = (tool, target)digest = hashlib.sha256(result.encode("utf-8")).hexdigest()if self.last_digest.get(key) == digest:self.stall_count[key] += 1else:self.stall_count[key] = 0self.last_digest[key] = digestif self.stall_count[key] >= self.max_stall:return "stop" # Stop this direction and prompt the model to try another strategyreturn "continue"rodents return "continue"
This code is illustrative only. In a real system, you might normalize target objects by file path, and compute result digests after stripping line numbers and other irrelevant fields, so the check better reflects “whether new information was obtained.”
3.3 Prolonged Spinning
Some tasks fall into prolonged, inefficient reasoning that burns a large number of tokens without producing meaningful changes. The mitigation is to set budgets—for example, caps on total call count, total tokens, and total elapsed time. When the budget is exhausted, the system should output a summary of the current state and let a human decide whether to continue or terminate.
4. Measuring Time and Token Consumption Correctly
4.1 Wall-Clock Time Is Not Model Speed
Task duration is affected by inference service queuing, concurrency limits, network conditions, tool execution speed, and other factors. Two models taking different amounts of time on the same task does not necessarily reflect a difference in inference itself. When comparing models, run them under identical network, concurrency, and tool environments as much as possible, and record the time distribution of each step.
4.2 Long Runtime Does Not Mean High Quality
An agent working for a long time may be tackling a genuinely complex task—or it may be stuck in a loop or repeatedly trial-and-erroring. The consumption profiles of these two cases are completely different. Evaluation should therefore focus on the resources required per completed task, rather than treating long runtime as a positive signal.
4.3 A Recommended Metric Set
The following metrics can be used to measure efficiency:
tokens_per_success = total tokens consumed / number of accepted tasksfirst_pass_rate = tasks passed on the first run / total taskseffective_change_ratio = accepted lines that pass tests / total generated lineswasted_call_ratio = tool calls that yielded no new information / total tool calls
Together, these metrics answer the question: “How many resources were spent, and how many usable results were obtained?”
Here is an illustrative aggregation script:
from dataclasses import dataclass@dataclassclass RunRecord:passed: booltokens: inttool_calls: intstalled_calls: intdef summarize(records: list[RunRecord]) -> dict:passed = [r for r in records if r.passed]total_tokens = sum(r.tokens for r in records)total_calls = sum(r.tool_calls for r in records)total_stalled = sum(r.stalled_calls for r in records)return {"pass_rate": len(passed) / len(records),"tokens_per_success": total_tokens / max(len(passed), 1),"stall_ratio": total_stalled / max(total_calls, 1),}
5. How to Account for Cost
5.1 Compare Cost per Unit Task, Not List Prices
Providers bill differently: some charge by token, some offer monthly plans or bundled quotas, and some deduct quota at different rates for different models. Comparing list prices directly can be misleading. A more reliable approach is to measure the quota or cost consumed per accepted task on the same task set, then derive a unit cost.
5.2 Subscription Plans vs. Pay-As-You-Go
The value of a subscription plan depends on how quickly the quota is actually consumed. If a model burns quota faster on the same tasks, then even a cheaper plan may result in a higher actual cost per task. When evaluating plans, observe them over time under real task workloads and record the quota consumption curve.
5.3 Prices Change
Service prices and billing rules may change at any time, so evaluation conclusions should note when the data was collected and defer to the rules published by the provider at that time. This article does not cite specific prices; readers should re-measure usingplätze based on their own task sets.
6. Building a Reproducible Evaluation Process
The goal of an evaluation process is to make results reproducible by others. The following steps are recommended:
- Build a task set: Cover bug fixes, feature additions, refactoring, test writing, and other task types, with clear difficulty grading per category.
- Fix the environment: Unify repository versions, dependencies, tool sets, and timeout settings.
- Standardize prompts and budgets: Give every model the same task descriptions and resource limits.
- Run multiple times: Run each task at least several times and look at the distribution of results, not a single run.
- Record process data: Save every tool call, error, token consumption figure, and elapsed time.
- Sample manually: Conduct code review on cobre review of test-passing results to confirm quality.
A simplified execution framework:
def run_benchmark(models, tasks, runs=3, budget_tokens=200_000):records = {}for model in models:records[model] = []for task in tasks:for _ in range(runs):outcome = execute_agent(model=model,task=task,token_budget=budget_tokens,)records[model].append(outcome)return records
Here, execute_agent must be implemented according to your actual agent framework. The key is to keep the input, environment, and budget identical for every run—otherwise comparisons are not trustworthy.
7. Practical Advice for Model Selection
- Clarify your scenario first. Quick code completion, long-horizon autonomous modification, code review, and test generation impose very different requirements on a model. Selection should start from your business scenario.
- Compare cost per unit task. Measure pass rates and consumption on your own task set before comparing costs.
- Prioritize stability. Tool call failure rates and wasted-loop rates directly affect delivery speed and increase the burden of human supervision.
- Consider other capability needs. If the same service must also handle image, audio, or video capabilities, include them in the overall assessment rather than comparing coding alone.
- Trust pilot results. Benchmark leaderboard scores are a useful reference, but your team’s codebase, toolchain, and task characteristics determine the final outcome. Run a one-to-two-week pilot with real tasks before deciding.
8. Summary
Agentic programming shifts LLM evaluation from “answering a question once” to “collaborating over a long period.” Judging whether a model fits a team requires looking at task completion rate, code quality, tool call reliability, long-horizon consistency, and cost per unit task together. Problems such as repetitive calls, parameter tweaks that bypass limits, and prolonged spinning need to be addressed through engineering measures within the agent framework. Only by standardizing the evaluation process and quantifying the metrics can model selection decisions rest on reproducible evidence.
