LLM Selection for Agent Workloads: Cost and Capability Evaluation
This article explains how to select large language models for agent-based workloads by evaluating total cost per accepted task rather than unit price alone. It covers input modalities, acceptance criteria, context and output limits, pricing components, agent capability metrics, reproducible benchmark design, tiered routing strategies, and ongoing production monitoring.
1. Low Unit Price Does Not Mean Low Total Cost
The same file read, code generation, or tool call may cost several times more on one model than another. But per-call cost is only one part of the bill. If a cheaper model needs three retries before passing acceptance, its total cost may exceed that of a more expensive model that passes on the first attempt. When selecting a model, compare the total cost of completing an accepted task, not the list price per million tokens.
A simple approximation can help estimate this:
Average cost per accepted task ≈ cost per attempt ÷ pass rate per attempt
This assumes failed attempts are fully redone. In real workloads, failures can also introduce manual correction costs, added latency, and a worse user experience. Once these factors are included, the selection conclusion often differs from one based on unit price alone.
2. Define Input Modalities and Acceptance Criteria First
The first step in model selection is to confirm the input modalities required by the business. Common inputs include plain text, images, video, and structured documents. Different models do not support exactly the same input types. If the workload requires direct video understanding, first confirm whether candidate models natively support video input. If they do not, a common approach is to extract frames, transcribe audio, and then pass the results to the model. The two approaches differ significantly in cost and accuracy and need to be tested separately.
Acceptance criteria also need to be defined in advance. For structured output, check whether the format can be parsed, required fields are present, and numeric fields match the source. For tool calls, check whether the tool name is correct, parameter types are valid, and required parameters are not missing. For code generation, check compilation, unit tests, and static analysis results. The more specific the acceptance criteria, the more reliable the subsequent comparison will be.
3. Understand the Key Numbers in Model Specifications
Specification parameters in model documentation are easy to misread. Three concepts need to be distinguished clearly.
1. Context window
The context window is the total number of tokens a single request can hold. In most services, the total window is occupied by both the input and the content generated in that turn. This means that when input approaches the window limit, the available output space shrinks accordingly. Use the official documentation for each service to determine exact calculation rules; do not infer them from experience.
2. Maximum output limit
The output limit is the maximum number of tokens the model can generate in a single response. It is not the word limit of the final answer. When reasoning mode is enabled, the model generates a thinking process before producing the answer, and this content also consumes the generation budget. In some services, the chain of thought and the final answer share the same output limit. Therefore, setting a large output limit does not guarantee a sufficiently complete answer; actual usage still needs to be observed.
3. Pricing basis
Pricing pages usually distinguish input tokens and output tokens. Some also distinguish cache hits, thinking tokens, or conversion rules for images and video. When comparing prices, you must unify the units and calculate different billing items separately. The following function shows a basic cost estimation method:
def estimate_cost(input_tokens: int,output_tokens: int,thinking_tokens: int,price_in: float,price_out: float,price_think: float | None = None) -> float:"""Prices are per million tokens. If no separate thinking price is provided, thinking tokens are billed at the output price."""think_price = price_think if price_think is not None else price_outcost = (input_tokens * price_in+ output_tokens * price_out+ thinking_tokens * think_price) / 1_000_000return cost
The value of this code is that it separates billing items, making it easy to replace price parameters for different models. In actual use, read the parameters from the official pricing page and record the query date, because prices may change at any time.
4. Evaluating Agent Capabilities
Agent success rate is determined by multiple stages. The model’s reasoning capability is only one of them. Whether task decomposition is reasonable, tool descriptions are clear, and context is effectively managed also affects the final result. Therefore, judging agent capability solely by version numbers, tier suffixes in model names, or context length is usually unreliable.
Agent capability evaluation can be broken down into the following dimensions:
- Tool selection accuracy: whether the model selects the correct tool among multiple available tools.
- Argument validity rate: whether generated arguments match the types and value ranges defined by the tool.
- Multi-step task completion rate: whether the model can complete the full workflow when a task requires multiple steps.
- Error recovery capability: whether the model can identify the problem and adjust its strategy when a tool returns an error.
- Cost and latency: how many tokens and how much time are required to complete the same task.
These metrics can all be measured directly within the same test task set, and they are more useful than promotional materials.
5. Re-test with the Same Task Set
Selection conclusions should be driven by business data. A recommended approach is to build a representative evaluation set that covers high-frequency scenarios and boundary scenarios in actual business workloads. Start with dozens of samples, and increase the number of samples for key scenarios as appropriate.
The re-test process needs to satisfy the following conditions:
- Fix variables: all candidate models use the same prompts, tool definitions, and input data.
- Record metrics: for each call, record pass or fail, input and output token counts, latency, and number of manual corrections.
- Separate statistics: calculate pass rates by task type to avoid average values hiding weaknesses in a particular task category.
- Keep logs: save raw requests and responses to support later troubleshooting of failure causes.
Below is an illustrative code snippet for an evaluation loop. call_model and validate need to be implemented according to the actual interface and business rules:
import jsonfrom dataclasses import dataclass, asdict@dataclassclass Case:case_id: strprompt: strexpected: dictdef run_benchmark(models, dataset, tools, validate, call_model):records = []for model in models:for case in dataset:resp = call_model(model=model, prompt=case.prompt, tools=tools)ok = validate(resp, case.expected)records.append({"model": model,"case_id": case.case_id,"passed": ok,"input_tokens": resp["usage"]["input_tokens"],"output_tokens": resp["usage"]["output_tokens"],"latency_ms": resp["latency_ms"],})return recordsdef summarize(records):summary = {}for r in records:m = summary.setdefault(r["model"], {"total": 0, "passed": 0, "tokens": 0})m["total"] += 1m["passed"] += int(r["passed"])m["tokens"] += r["input_tokens"] + r["output_tokens"]for m in summary.values():m["pass_rate"] = m["passed"] / m["total"]return summaryif __name__ == "__main__":# records = run_benchmark(MODELS, DATASET, TOOLS, validate, call_model)# print(json.dumps(summarize(records), ensure_ascii=False, indent=2))pass
After the run, combine pass rate with unit cost. If a model has a higher pass rate, even if its unit price is higher, its cost per accepted task may still be lower.
6. Tiered Trial Strategy
A single model usually cannot satisfy all scenarios at once. A more practical approach is to tier models by task type:
- High-frequency image-text and structured tasks: start with lower-cost models to establish a baseline, and record pass rates and usage.
- Tasks requiring longer generated content: focus on output limits and pricing, while also checking the completeness of long outputs.
- Direct video understanding tasks: prioritize testing candidate models that natively support video input, and compare them with frame-extraction approaches.
- Complex agent tasks: use pass rate and cost per accepted task as the main basis for selecting the primary model.
After tiering, routing and escalation mechanisms can also be designed. For example, a low-cost model can process requests first, and if the output fails validation, a stronger model can retry. This design requires sufficiently reliable validation logic; otherwise, the escalation mechanism will also let erroneous results through.
7. Ongoing Maintenance After Launch
Model versions, prices, and capabilities continue to change. Selection conclusions should be reviewed periodically. It is recommended to rerun the evaluation set every quarter or after each version change, and to record the test date and the parameter versions used.
Production environments also need to monitor three types of data: token usage, task failure rate, and end-to-end latency. These data can reveal cost anomalies and also indicate degradation in model effectiveness. If evaluation set samples contain real user data, anonymize them before storage and restrict access.
In summary, the core of model selection is to compare price, input capabilities, and task pass rate in the same table, draw conclusions using the same task set, and then use models in tiers by scenario. This produces more reliable results than looking only at parameters or promotional materials, and it makes it easier to adjust when budgets change.
