Evaluating Quantized Models: A Reproducible Benchmark for AI Agent Coding Capabilities
This article presents a reproducible method for evaluating how quantization affects the coding capabilities of AI agents. It covers variable control across 4-bit integer, 4-bit floating-point, and 8-bit floating-point models, a three-part task suite spanning native tool calls, defect fixing, and full application builds, and a fully automated machine scoring pipeline that avoids LLM-as-a-judge bias. It also interprets process metrics such as wall-clock time, interaction turns, prompt cache hit ratio, and added tests, and outlines how to build the evaluation pipeline on Baidu AI Cloud.
## 1. Background: What Quantization Actually Changes in Agent Coding
Once large models move into production, quantization is almost inevitable. By lowering the numerical precision of weights and activations, teams can rebalance memory usage, throughput, and cost. Common approaches include 4-bit integer quantization, 4-bit floating-point quantization, and 8-bit floating-point quantization, each with different trade-offs in compression ratio, precision retention, and hardware compatibility.
But quantization is not lossless compression. It shifts the model’s output distribution, reasoning chain length, and tendency to self-verify. These shifts are nearly invisible in traditional single-turn QA accuracy, and only surface clearly in real agentic coding tasks. The reason is straightforward: coding agents run long-horizon tasks that require multiple tool calls, state maintenance, and error recovery, so even a small behavioral drift gets amplified turn by turn.
This article therefore focuses not on which quantization scheme is “better,” but on a reproducible evaluation method: a unified task set, a unified tool interface, and unified machine scoring that turn quantization differences into comparable engineering metrics.
2. Evaluation Targets and Variable Control
To keep the conclusions credible, the evaluation must control variables strictly. The three test subjects are a general-purpose model with 4-bit integer quantization, a model with 4-bit floating-point quantization, and a model with 8-bit floating-point quantization. Apart from the quantization scheme, all three share the same context window, tool set, system prompt, and temperature setting.
It is worth stressing that the quantization scheme is coupled with the model’s own characteristics. The same scheme applied to different base models can behave very differently. Conclusions should therefore be phrased as “the behavioral characteristics of a given quantization scheme on a given class of models,” not as absolute rankings.
3. Task Design: Three Task Types Covering Different Capability Dimensions
The evaluation consists of three parts that together provide a well-rounded test of agentic coding capability.
- Native tool-calling capability. The model acts as an agent and calls 21 native tools in a controlled environment, including file read/write, directory traversal, command execution, dependency lookup, log retrieval, and test execution. The focus is on accuracy of tool selection, completeness of argument filling, and how failed returns are handled.
- Defect-fixing capability. Given 17 real defects covering typical patterns such as null pointers, boundary conditions, concurrency races, swallowed exceptions, and type mismatches. The focus is on localization efficiency and adherence to the minimal-change principle.
- Full application build capability. The model must build a web application from scratch and pass 19 checks covering routing, data validation, persistence, error handling, logging, and basic test cases.
The three task types map to “can use tools,” “can fix code,” and “can do engineering” — none can be skipped.
4. Scoring: Fully Automated Machine Scoring
The entire evaluation is scored automatically by machines, with no LLM judge. This matters: introducing a model judge imports bias from the same family as the systems under test and makes results non-reproducible.
The machine scoring logic can be abstracted as the following sketch:
def evaluate(run_dir, checks):report = {}report["tool_success"] = tool_call_success_rate(run_dir)report["bugfix_pass"] = defect_suite_pass_rate(run_dir, n=17)report["build_pass"] = sum(1 for c in checks if c.verify(run_dir)) / len(checks)report["wall_clock"] = elapsed_seconds(run_dir)report["turns"] = count_turns(run_dir)report["tokens_out"] = count_output_tokens(run_dir)report["cache_hit"] = prompt_cache_hit_ratio(run_dir)report["tests_added"] = count_new_tests(run_dir)return report
All metrics come from run logs and final artifacts, so they are auditable and replayable.
5. Observations: Three Distinct Working Modes
All three test subjects passed every test, yet their working modes differed markedly — which shows that pass rate is only the baseline, while engineering fit must be judged by process metrics.
Mode 1: Minimal-output. The application build finished in about 18.4 minutes, the fastest of the three, with only about 20K output tokens in total. Even though the underlying inference engine did not have a throughput advantage, the very small amount of wasted output made the overall wall-clock time the shortest. This mode suits latency-sensitive, pay-per-use interactive scenarios.
Mode 2: Plan-then-execute. This mode used the fewest interaction turns, about 77, and tended to produce a complete plan first and then implement it step by step, making the process highly readable. Its prompt cache hit ratio reached about 98%, greatly amortizing the compute cost of repeated prefixes and yielding the lowest cost per task. This mode is well suited to long-running autonomous background work, such as overnight batch refactoring, scheduled inspections, and dependency upgrades.
Mode 3: Deep reasoning. Every turn came with substantial internal reasoning, so it took the longest, about 27.6 minutes. However, it produced the most standardized code and added the most test cases — 18 — leading on engineering quality metrics. This mode fits a “quality gatekeeper” role for generating and pre-reviewing critical modules.
6. Reading the Metrics: Why a Single Dimension Misleads Selection
Abstracting the above into three rules helps avoid common selection mistakes.
- Wall-clock time is not equal to cost. Fewer output tokens and a high cache hit ratio often determine the bill more than peak engine throughput.
- Interaction turns are not equal to low efficiency. Fewer turns usually mean stronger planning and less rework, but they can also mean insufficient checking.
- Test count is not equal to high quality, but it correlates strongly with standardization. A “fast pass” without tests turns into maintenance cost in later iterations.
The recommended approach is a weighted scorecard: treat correctness as a gating item, and time, cost, turns, and test coverage as optimization items, with weights assigned per business scenario.
7. Implementation: Building the Evaluation Pipeline on Baidu AI Cloud
To reproduce the evaluation in your own environment, the following engineering path uses only general-purpose capability categories:
- Use a container platform to host an isolated sandbox runtime, allocating an independent file system and network policy to each run so tool calls produce no side effects.
- Use object storage to keep task inputs, run logs, and final artifacts, ensuring results are traceable and replayable.
- Use a message queue to orchestrate task distribution and result collection, supporting parallel evaluation of multiple models and failure retries.
- Use logging and monitoring with alerting to track metrics such as elapsed time, turns, and cache hit ratio, forming a trend dashboard.
- Model inference can be hosted on Baidu AI Cloud’s general-purpose inference services, with a unified model access layer enabling canary switching and controlled experiments between quantized versions.
8. Conclusion
Quantization does not make agents “dumber,” but it changes their working habits: some become more silent and efficient, some get better at planning and reusing context, and some are more willing to spend time on reasoning and testing. The value of evaluation is to quantify these differences and align them with specific business scenarios. With automated machine scoring as the foundation, multi-dimensional metrics as the framework, and isolated sandboxes plus observability as safeguards, you can build a stable, reusable agent coding capability evaluation mechanism on Baidu AI Cloud — moving model selection from subjective impression to data-driven decisions.
