Evaluating LLM Cost-Efficiency for Coding Agents
This article explains how to measure cost-efficiency for large language models in daily coding-agent work. It covers mixed unit price from input, output, and cache tokens, cache-price sensitivity, task routing, budget-back calculation, and operational constraints so you can size usable volume instead of judging list prices.
Once large language models are part of everyday coding, the decision is no longer “pick the strongest model.” It is “within an acceptable monthly spend, reliably complete exploration, edits, verification, and regression.” Nominal plans, cache discounts, and subtask routing all change usable scale. List prices alone are easy to misread. The following is a checkable method for cost-efficiency in coding scenarios.
Define cost-efficiency as a computable quantity
Cost-efficiency is not a feeling. It is the effective work a unit of budget can sustain. Effective work includes at least four call types: reading the repo and locating issues, generating or changing implementation, interpreting run results and fixing errors, and retaining context for those steps. Their token structures differ, so you cannot divide by a single “price per million tokens.”
Fix three observation windows: one medium request (for example, change a module and add tests), one workday, and one calendar month. In each window record input tokens, output tokens, cache-hit tokens, and failed retries. Monthly cost-efficiency can be read as:
usable scale ≈ monthly budget ÷ mixed unit price
mixed unit price ≈ input share × input price + output share × output price + cache-hit share × cache price + miss-or-write share × corresponding price
Do not plug in a vendor’s “maximum discount” if you lack real shares. Coding agents are usually input-heavy, and multi-turn chats repeat a lot. Cache share often drives the bill more than output length.
What actually makes up the bill
Common billing at least splits the items below. Names differ by vendor; meanings should match the contract.
- Asymmetric input and output. Inference output is usually more expensive. Long explanations and pasting whole files raise the output share and the mixed price.
- Cache hits vs misses. Long system prompts, project rules, and already-read files can settle at a lower price when reused. Changing rules, prefixes, or model versions drops hit rate.
- Context window and truncation. A larger window is not automatically cheaper. Irrelevant files in context raise both input and cache writes.
- Retries and parallelism. Failed retries and many subtasks reading the same repo can multiply one request into several times the calls.
- Plan boundaries. Some plans allow “unlimited” use only on a few models; others are metered or capped. Evaluate the model mix you will actually use. Do not extrapolate the cheapest line item to all work.
“A plan says you can use a lot in a month” is an upper-bound claim. Ask: under my input/output ratio and cache hit rate, what is the mixed unit price?
Cache price is a lever on quota
If cache hits dominate the bill, a change in cache price transfers almost linearly into usable tokens. Suppose about 80% of tokens are cache hits and the rest ordinary input/output. If cache-hit price becomes five times, that portion of cost becomes five times. If it already dominated mixed cost, mixed unit price can rise by a similar factor, and usable scale under the same budget can fall to about one-fifth. For example, a rough 7 billion tokens of support might drop to about 1.4 billion. This is not a precise invoice. It is a reminder: cache-heavy workloads are extremely sensitive to cache unit price. Run sensitivity analysis; do not look only at base input price.
In practice, reduce billed repetition and cache invalidation:
- Separate a stable prefix from variable content. Put norms, directory notes, and tool protocols in the prefix; put this diff, errors, and user instructions in the suffix.
- Limit how often the prefix changes. Frequent system-prompt edits destroy hits.
- Do not dump the whole repo into context to “save one call.” Read on demand and summarize before the main session; that is usually cheaper.
- Record hit rate. If it falls continuously, check prefix jitter first, then routing, rather than blindly adding budget.
Layer tasks instead of one model for the whole path
Coding-agent calls are not equal. Exploration reads many files and tries many paths: low decision value per call, high token use. Implementation must hit interfaces, keep style, and pass tests: high cost of error. Binding both to the same expensive model lets exploration consume the budget quickly.
A more stable split:
- Exploration, listing directories, first-pass retrieval, candidate reading lists: a capable cheaper model, with a cap on output length.
- Design trade-offs, cross-module edits, security-sensitive logic: a stronger model, fed only filtered context.
- Mechanical checks such as formatting and simple unit-test completion: use rules or local tools when possible; do not call a large model.
Here the cheaper model is not a drop-in replacement for the main engine. It buffers exploration cost. The main session consumes high-value context. If cheaper quota can cover billions of exploration tokens while higher-capability quota covers real code changes, the overall bill is usually smoother than “expensive model end to end.” Use your own invoices; do not treat someone else’s plan experience as a promise.
Whether a workday “maxes out” the quota matters less than whether retries run away. If you rarely exhaust quota but burn context on a few hard problems, the bottleneck is task decomposition, not plan tier.
Work backward from a budget cap, not forward from quota
Individual developers can treat model spend like a utility, but they should first write an acceptable unit-price ceiling. A discussable personal band is about one to three currency units per 100 million tokens. Above that band, unless there is clear output (delivery or saved hours), use it for occasional hard problems, not as the all-day default agent. That is willingness to pay, not market price. Teams should price against human time: if an agent stably saves hours of repetitive work each day, a higher unit price can still pay off.
A reverse checklist:
- Set monthly budget and an acceptable mixed unit-price ceiling.
- From the last two weeks of real calls, estimate input, output, and cache shares.
- Compute current mixed unit price and run cache-price ×2 and ×5 sensitivity.
- Mark the exploration share. If it is more than half the budget, force exploration onto a lower unit price.
- Cap per-call context and retries on the main session so one failure does not consume the month.
- For enterprises, list invoicing, contracting entity, and data-residency requirements separately. Being able to invoice only means procurement is possible. It does not raise model quality and should not score as extra cost-efficiency.
Illustrative logic (replace numbers with your bill; do not copy them):
budget = monthly_budgetp_in, p_out, p_cache = three unit pricesr_in, r_out, r_cache = three token shares (sum to 1)unit = r_in * p_in + r_out * p_out + r_cache * p_cachetokens = budget / unit# If cache price rises by k, replace p_cache and recompute
If tokens after a price rise fall below the minimum scale for daily work, it is not “still good enough.” Default routing has failed. Shrink context, change the exploration model, or reduce agent autonomy.
Do not mix availability constraints with price
Network reachability, account region, whether data may leave a designated environment, and whether a contract and invoice are required are hard constraints. If they fail, a low unit price cannot enter the shortlist. Compare in two layers: first filter for stable use, then among remaining options compare mixed unit price and failure rate. Ranking a cheap overseas option with a locally deliverable option on one list leads to something that cannot ship.
Markets move fast. Cache discounts may rise tomorrow; the set of “unlimited” models in a plan may shrink. Do not write a long-term recommendation. Keep a monthly review: shares, hit rate, retries, cost per request. Review is cheaper than a blind plan change.
Minimal practices to land this
- Account separately for the main coding session and exploration subtasks.
- Keep the system prompt short and stable; retrieve large materials on demand.
- On the output side, require patches and conclusions; suppress unrelated long text.
- Do not send local search, formatting, and tests to the model.
- For any “unlimited or free-form use,” ask which models, which cache rules, and what fair-use limits apply.
- Set budget alerts at 70% and 90%, not after the quota is gone.
The cost-efficient choice is not a fixed product name. It is the call path whose mixed unit price still sits inside your willingness to pay, given your input mix, cache hits, and task layering, and that satisfies every constraint. When prices or rules change, recompute with the same formula instead of keeping the old conclusion by habit.
