Evaluating Coding Agents: Quantization, Inference Cost, and Engineering Quality

    Dedicated evaluation of coding agents requires more than checking whether a model can write a correct code snippet. This article covers why coding agents need separate evaluation, how quantization changes working patterns, how to design tool sets and bug-fixing/application-building tasks, why executable checks are preferable to LLM judges, which metrics to observe, three common working patterns, selection guidance, and a simplified reproducible evaluation script. The focus is on controlling variables, measuring stability, efficiency, and cost across multi-turn interactions, and using practical acceptance criteria for engineering quality.

    1. Why Coding Agents Need Dedicated Evaluation

    Coding agents are different from single-turn Q&A. They need to read a codebase, decide which tool to call, execute commands, modify files based on returned results, and repeat the loop until tests pass. Therefore, judging whether a model is suitable for this kind of work cannot rely only on whether it can write a correct piece of code. It also requires looking at stability, efficiency, and cost across multi-turn interactions.

    This problem is even more prominent in local deployment. VRAM capacity, inference throughput, quantization precision, and the implementation of the inference service jointly determine the actual experience. When the same model is switched to a different quantization method, both latency and output style can change noticeably.

    2. How Quantization Affects Working Patterns

    Quantization is the process of compressing model weights from high-precision representations to lower-bit representations. Common forms include 8-bit floating point, 4-bit integer, and 4-bit floating point. Compression can reduce VRAM usage, but it introduces numerical error. In addition, different quantization formats require corresponding support from inference kernels, so the speed impact depends on the software-hardware combination.

    Two points need attention during evaluation. First, bit width cannot directly determine speed; actual speed is determined by the inference engine and hardware. Second, quantization mainly changes numerical precision, while the model’s reasoning style, output length, and planning habits come more from training. The two should be analyzed separately.

    Therefore, quantization should be controlled as an independent variable. Only by running the same batch of tasks under different quantization settings can you determine where the differences actually come from.

    3. Designing Evaluation Tasks

    3.1 Tool Set

    The evaluation needs to provide the agent with a fixed set of native tools, such as reading files, writing files, executing shell commands, searching code, and running tests. The number of tools and the way they are described affect the model’s accuracy in selecting tools, so the tool definitions should remain unchanged and be fully listed in the report.

    3.2 Bug-Fixing Tasks

    Bug-fixing tasks are used to test the model’s ability to locate and modify code. Each task should contain three parts: a problem description, a test that reliably reproduces the failure, and the scope of source files involved. Tasks should be independent of one another, which makes it easier to calculate pass rates and prevents changes from one task from affecting the next.

    3.3 Application-Building Tasks

    A complete application-building task covers requirement understanding, module decomposition, interface implementation, and self-checking. Acceptance criteria should consist of a set of explicit checks, each corresponding to an executable assertion, such as an endpoint returning the correct status code, a page containing a specified element, or data being correctly written to storage. The more specific the checks are, the more comparable the results are.

    4. Use Machine Scoring Instead of LLM Judges

    If another large model is used to score the results, the scoring itself introduces bias. A judge model may prefer longer answers or be more tolerant of a certain code style. A safer approach is to write all acceptance conditions as executable checks and let a program produce a pass or fail conclusion.

    An automated scoring workflow should meet three requirements. First, reset the environment before each run to avoid leftover files affecting the results. Second, fix the checks before the model runs; they must not be adjusted temporarily based on the output. Third, save the raw output for all decisions to facilitate manual review.

    5. Metrics to Observe

    5.1 End-to-End Elapsed Time

    Elapsed time refers to the wall-clock time from task start to acceptance pass. It is the combined result of inference speed and the number of interaction turns. Looking at it alone cannot reveal which part is slow, so it needs to be interpreted together with other metrics.

    5.2 Total Output Tokens

    Total output refers to all content generated by the model. Fewer output tokens usually mean lower single-turn latency. However, excessive brevity may also lead to missing necessary tests, error handling, or comments, so it should be viewed together with quality metrics.

    5.3 Number of Interaction Turns

    The number of interaction turns refers to the number of round trips completed between the agent and the tools. Fewer turns suggest clear planning or a larger amount of information per step. More turns are not necessarily a disadvantage; they may also mean the model is carefully verifying step by step.

    5.4 Prompt Cache Hit Rate

    In multi-turn conversations, the previous context prefix is resent in each turn. If the server can cache this prefix, there is no need to recompute it. The higher the hit rate, the lower the computational cost for the same task. This metric depends heavily on the caching strategy of the inference service and cannot be treated directly as an attribute of the model itself.

    5.5 Engineering Quality

    Engineering quality includes the number of test cases, test pass rate, static check results, and code style consistency. Test count is only a rough proxy for coverage; the real judgment requires reviewing whether the tests cover boundary conditions and exception paths.

    6. Three Typical Working Patterns

    Putting the above metrics together, common working patterns can be roughly grouped into three categories.

    • Lean: low output, moderate turns, and short elapsed time, suitable for quickly building prototypes. The risk is that tests and documentation may not be complete enough.
    • Planning: lists a plan first and then executes it step by step, with fewer turns, suitable for unattended background tasks. When the cache hit rate is high, the marginal cost of long tasks drops noticeably.
    • Deliberative: more internal reasoning per turn and longer elapsed time, but code standards and test coverage are often better, suitable for scenarios with high delivery-quality requirements.

    These three patterns summarize characteristics of metric combinations; they do not refer to a fixed model. The same model can behave very differently across tasks and deployment conditions.

    7. Selection Guidance

    Selection should start from the scenario, not from a leaderboard. The process can proceed as follows:

    1. Clarify the task type and determine whether it is rapid prototyping, daily development, or long-running automation.
    2. Determine constraints, including the latency cap per task, cost budget, and VRAM and hardware conditions.
    3. Run a small-scale evaluation using your own codebase and acceptance cases, with samples as close as possible to real work.
    4. Aggregate metrics by weight rather than looking only at the best value of a single metric.

    8. Reproducible Evaluation Framework Example

    Below is a simplified evaluation script that shows how to consistently record elapsed time, run tests, and save results.

    1. import json
    2. import subprocess
    3. import time
    4. from pathlib import Path
    5. def run_check(workdir: Path, test_cmd: list[str], timeout: int = 300) -> dict:
    6. """Run a test command in the specified directory and return pass status, elapsed time, and output tails."""
    7. start = time.monotonic()
    8. proc = subprocess.run(
    9. test_cmd,
    10. cwd=workdir,
    11. capture_output=True,
    12. text=True,
    13. timeout=timeout,
    14. )
    15. return {
    16. "passed": proc.returncode == 0,
    17. "elapsed_s": round(time.monotonic() - start, 2),
    18. "stdout_tail": proc.stdout[-2000:],
    19. "stderr_tail": proc.stderr[-2000:],
    20. }
    21. def evaluate(task_dir: Path, test_cmd: list[str], record_path: Path) -> None:
    22. result = run_check(task_dir, test_cmd)
    23. record_path.parent.mkdir(parents=True, exist_ok=True)
    24. record_path.write_text(
    25. json.dumps(result, ensure_ascii=False, indent=2),
    26. encoding="utf-8",
    27. )
    28. if __name__ == "__main__":
    29. evaluate(
    30. task_dir=Path("./workspace/task_01"),
    31. test_cmd=["python", "tests/run_all.py"],
    32. record_path=Path("./results/task_01.json"),
    33. )

    The script passes commands as an argument list rather than concatenating strings, so special characters in paths or task names are not misinterpreted by the shell. Each run saves the output tails for later review.