LLM Selection for Agent Workloads: Cost, Capabilities, and Production Evaluation

    Choosing a large language model for production agents requires more than comparing token prices. This article presents a three-layer decision framework covering input modality and context definitions, output and thinking budgets, and unit-task cost calculation. It also explains how to evaluate agent success with real retest datasets, automated acceptance checks, tiered routing, canary rollouts, and common pitfalls. Readers can use these methods to compare models by cost per accepted business task and by real retest data rather than by list price or model-name suffixes.

    1. Correcting a Premise: Unit Price Is Not the First Variable

    For tasks such as reading files, writing code, and calling tools, the per-turn cost can differ by one to two orders of magnitude across models. However, treating unit price as the primary criterion often leads to a more expensive result: a cheaper model may fail on the first attempt and require three to five retries plus manual repair, while a more expensive model may pass on the first attempt and cost less overall.

    The more useful questions are therefore: Can the cheaper tier pass acceptance in one attempt? Can the more expensive tier significantly reduce rework? The objective function for model selection is not “how much per million tokens,” but “how much per accepted business task.”

    2. A Three-Layer Decision Framework

    Proceed in a fixed order to avoid premature price comparisons when information is incomplete.

    1. Input layer: Does the task require text, images, or video? Is the context window sufficient, and is the stated limit a “total window” or a “maximum input”?
    2. Output layer: How large is the per-generation budget? Is the thinking mechanism enabled, and does thinking consume the generation budget?
    3. Cost layer: Calculate unit-task cost on a real task set, including turns, retry rate, and cache benefits.

    3. Input Side: Modality and Context Definitions

    3.1 Modality Determines the Candidate Set

    For batch image-text understanding tasks such as receipt recognition, screenshot classification, and document extraction, prioritize tiers that have stable image-text input and low throughput cost. For tasks that require direct video understanding, such as long-video summarization or screen-recording analysis, the candidate set narrows immediately because not all models natively support video input. If a candidate model does not support video, the usual fallback is frame extraction and conversion to images, which introduces additional preprocessing cost and accuracy loss. This must be included in the solution design.

    3.2 “Million-Token Context” Is Not One Concept

    Vendors do not use a unified way to describe context, and three common formulations mean very different things:

    • Total window: Input and current generation share the same budget. Filling the input reduces the space available for output.
    • Maximum input: Only the input side is constrained; output has a separate limit.
    • Unit notation differences: K versus M conversion and whether 1024-based units are used can make nominal values non-equivalent.

    In engineering, do not treat numbers from different definitions as exactly equal for capacity planning. Convert them to token counts under a unified definition and leave a safety margin.

    1. # Normalize definitions before capacity validation to avoid misuse of nominal values
    2. def fits(total_window, prompt_tokens, reserved_output, safety=0.9):
    3. usable = int(total_window * safety)
    4. return prompt_tokens + reserved_output <= usable

    3.3 Real Benefits and Costs of Long Context

    The value of a long window is that it reduces slicing and retrieval pipelines, but attention cost rises with length, and first-token latency and cost increase accordingly. A more stable practice is to keep a small number of highly relevant retrieved fragments and use the long window for “whole-file-level” tasks rather than blindly injecting all content.

    4. Output Side: Output Budget and Thinking Mechanism

    Output budget is not the same as final answer length. This is one of the most commonly misunderstood points. When the thinking mechanism is enabled, the chain of thought and the final answer usually share the same generation budget; the stated “thinking limit” is often the sum of both.

    This leads to two direct conclusions:

    • If the budget is set too tightly for complex reasoning tasks, the model may exhaust the quota during thinking and return an empty answer or truncated content.
    • If thinking is enabled for simple extraction tasks, you pay for reasoning that is not needed.

    An engineering recommendation is to model the budget explicitly as “thinking reserve + answer reserve” and configure it by task type.

    1. BUDGET = {
    2. "extract": {"thinking": 0, "answer": 2048},
    3. "code": {"thinking": 8192, "answer": 8192},
    4. "agent": {"thinking": 4096, "answer": 4096},
    5. }

    Also note that some models have default output limits. If not set explicitly, the limit may be far below the maximum supported by the hardware. Long code generation being silently truncated often comes from this.

    5. Cost Side: Calculate by Unit Task Cost

    Cost comparison is meaningful only when cost is written as a calculable expression:

    1. Unit task cost = Σ(input tokens at turn i × input unit price + output tokens × output unit price)
    2. × (1 + retry rate) − cache hit benefit

    Four key levers:

    • Turns: Multi-turn tool calls in agent tasks repeatedly bill input tokens, making turns the most sensitive variable.
    • Retry rate: Every 10 percentage point improvement in first-pass success usually saves more than switching to a lower-unit-price model.
    • Cache: Stable prefixes such as system prompts, tool definitions, and long documents can significantly reduce cost when cached, provided the prefix is byte-for-byte stable.
    • Output share: Thinking-heavy tasks have a high output token share, which amplifies the weight of output unit price.
    1. def task_cost(p_in, p_out, turns, in_tok, out_tok, retry=0.0, cache_hit=0.0):
    2. per_turn = in_tok * p_in * (1 - cache_hit) + out_tok * p_out
    3. return per_turn * turns * (1 + retry)

    6. Agent Scenarios: Name Suffixes Do Not Indicate Success Rate

    Suffixes such as Max, Flash, and Pro in model names only reflect vendor positioning tiers; they are not a basis for agent success rate. Likewise, context length and tool-calling support are only admission conditions, not guarantees of effectiveness. What really determines agent performance is tool-selection accuracy, validity of parameter filling, consistency of multi-turn state, and the ability to self-correct after failure.

    6.1 Build a Retest Task Set

    Use the same set of 30 to 100 real business tasks for horizontal retesting, covering four sample types: normal paths, boundary inputs, cases requiring multiple tools in sequence, and adversarial samples that must fail and then be corrected.

    6.2 Metric Definitions

    • First-pass success rate: The proportion that passes acceptance without human intervention (primary metric).
    • Average turns and tool calls: Directly related to cost.
    • Parameter validity rate: Whether tool-call parameters pass schema validation.
    • P95 latency: Tail latency under long context determines interactive experience.
    • Truncation rate: The proportion of incomplete answers caused by insufficient output budget.

    6.3 Acceptance Must Be Automated

    Write “acceptance” as executable assertions rather than manual visual inspection:

    1. def verify(result, case):
    2. return (schema_ok(result, case.schema)
    3. and value_in_range(result, case.range)
    4. and not truncated(result))

    7. Implementation: Tiered Routing and Canary Rollout

    The conclusion is rarely “choose one model for everything.” More commonly, it is tiering: route high-frequency, structured, low-difficulty tasks to a low-cost tier to establish a cost baseline; route budget-sensitive tasks that need a larger generation budget to a large-output tier; route tasks involving native video input to a tier that supports that modality; and assign complex agents to the retest winner while retaining an upgrade path.

    1. def route(task):
    2. if task.needs_video: return "tier_video"
    3. if task.difficulty > 0.7: return "tier_agent"
    4. if task.volume == "high": return "tier_cheap"
    5. return "tier_balanced"

    Three supporting practices: log input and output tokens and turns across the full chain for continuous unit-cost calculation; run canary rollouts and rollbacks for routing results; and fix the prefixes of prompts and tool definitions to capture cache benefits.

    8. Common Pitfalls

    • Using nominal context limits directly for capacity planning while ignoring the shared window between input and generation.
    • Treating the output limit as answer length, causing long code to be truncated.
    • Enabling thinking uniformly for all tasks and paying for simple tasks.
    • Comparing only unit price without comparing first-pass success rate and rework cost.
    • Inferring agent capability from model-name suffixes.
    • Switching all traffic without retesting on a real task set.

    9. Conclusion

    Model selection is a measurable engineering problem: input form determines the candidate set, output budget and thinking mechanism determine feasibility, unit-task cost determines the final tradeoff, and retest data from the same task set determines which model goes live. Treat specifications as admission conditions and retests as the decision basis to obtain both cost and effectiveness. If your organization already uses Baidu AI Cloud model services together with general logging and monitoring capabilities, these metrics can be connected to the existing observability stack to form a continuous model-selection loop.