Local LLM Model Selection for Coding Agents: A Practical Guide
This article presents a practical methodology for selecting local LLMs used in coding agents, focusing on three evaluation dimensions: quantization formats, model behavior style, and prompt cache hit rate. It explains how per-token cost and total token consumption together determine real latency and cost, outlines a reusable machine-scored evaluation process, and offers a selection checklist for different development scenarios. Readers will learn how to compare quantization trade-offs, interpret process metrics, and build a repeatable selection baseline.
1. Background: Why “It Runs” Does Not Mean “It Fits”
When deploying large models locally for coding agents, teams often fall into a common trap: assuming selection is successful as long as the model can complete the task. In real deployments, three factors actually determine the experience: the time cost per task, compute and memory overhead, and the maintainability of the generated code. The same base model can show multiples of difference across these three metrics under different quantization schemes.
A typical reference scenario is a local inference environment with dual accelerator cards, comparing three Flash-class open-source models that use different quantization schemes. The tasks were designed to resemble real development work: the model had to act as an agent calling 21 native tools, fix 17 defects, and complete a full web application build with 19 checkpoints. Scoring was fully automated by machine, with no LLM judge, to avoid evaluation drift caused by subjective preferences.
It is worth emphasizing that this article does not repeat any specific product conclusions. Instead, it abstracts this kind of hands-on test into a methodology: the quantization scheme determines the “cost per token,” while the model’s behavior style determines the “total token consumption.” Only the product of the two reflects real latency and billing.
2. Three Evaluation Tracks
2.1 Quantization: The Triangle of Precision, VRAM, and Throughput
Common quantization routes in the industry fall into three categories: extremely low-bit integer quantization (such as 4-bit level), low-precision floating-point quantization (such as FP8 level), and block-level floating-point formats designed for newer accelerator hardware (such as NVFP4 level). They share the same principle of trading numerical precision for VRAM and bandwidth, and differ in error distribution and hardware compatibility.
- Extremely low-bit quantization: lowest VRAM usage, but output stability is more sensitive to prompts and decoding parameters;
- FP8 level: mature ecosystem on mainstream accelerator cards, with balanced performance for long context and cache reuse;
- Block-level floating-point formats: require newer hardware and inference stack support, and usually deliver clear gains in high-throughput scenarios.
When selecting, do not look only at “how many bits.” Check whether your inference engine natively supports the operators for that format; otherwise you may end up with “format supported but speed drops instead of improving.”
2.2 Behavior Style: Output Volume, Interaction Rounds, and Planning
All three models passed the tests, but their working modes were completely different, which is exactly the most informative part:
- Minimal-output type: extremely low total generation (reference scale of about 20,000 tokens). Even if the underlying engine is slow per token, “talking less” still yields the shortest wall-clock time.
- Plan-driven type: fewest interaction rounds (reference scale of 77 rounds). It plans first and then executes step by step, offering strong process readability, and combines with a high cache hit rate to push compute cost to the lowest.
- Deep-reasoning type: performs extensive internal thinking every round, taking the longest time (reference scale of 27.6 minutes), but producing the most standardized code and the most test cases (reference scale of 18).
An actionable rule is to decompose total time as total time ≈ interaction rounds × output tokens per round ÷ effective throughput. The minimal-output type wins on the second term, the plan-driven type wins on the first term, and the deep-reasoning type trades the first and second terms for quality.
2.3 Cache Hit Rate: The Underrated Cost Lever
Agent prompts are highly repetitive (system instructions, tool definitions, historical context), so the prompt cache hit rate often affects the bill more than the model itself. In the reference scenario, the high-hit scheme reached about a 98% hit rate, meaning most of the prefix did not need to be recomputed. In engineering practice, you should put the stable prefix first, variable content later, and keep tool definition order fixed to avoid meaningless cache invalidation.
[Fixed prefix: system instructions + tool schema + coding standards] <- target hit rate > 90%[Semi-fixed: repository structure summary][Variable: current task description + recent conversation turns]
3. A Reusable Evaluation Method
- Fix the task set: allocate a certain proportion each to defect fixing, tool calling, and end-to-end build tasks to avoid single-dimension bias;
- Prioritize machine scoring: use compilation, tests, static checks, and checkpoint pass rate as hard metrics to reduce subjective review;
- Record process metrics: interaction rounds, input/output tokens, cache hit rate, and peak VRAM, forming a comparable table;
- Repeat three times and take the median: to offset fluctuations caused by decoding randomness;
- Focus on failure modes: whether it is missed changes, over-modification, or missing tests, which is more instructive than the total score.
4. Selection Checklist and Deployment Advice
- Want the fastest usable prototype: choose an extremely low-bit quantization, minimal-output scheme, suitable for exploration and demos;
- Daily development balancing efficiency and cost: choose an FP8-level, plan-driven, cache-friendly scheme, suitable for long autonomous background runs;
- Pursuing standards and test coverage: choose a deep-reasoning scheme, suitable for core modules and scenarios with high pressure for code review.
If you use relevant capabilities from Baidu AI Cloud to carry the above workflow, you can adopt a general category combination: a container platform to host inference services and evaluation orchestration, object storage to save task sets and artifacts, a message queue to decouple task distribution, and logging, monitoring, and alerting services to track latency, VRAM, and hit-rate metrics, thereby turning a one-off hands-on test into a sustainable regression baseline for model selection.
