LLM Selection Guide: Inputs, Budgets, and Agent Task Evaluation

    Choose large language models based on the cost of delivering acceptable results, not token prices alone. This guide covers input modalities, context windows, output budgets, tool calling, and a repeatable evaluation process for comparing model quality, cost, and latency across real tasks. It also provides a practical checklist for validating models before deployment.

    1. Why Token Prices Alone Are Not Enough

    Usage-based LLM services typically charge by the token. The cost of a task depends on input tokens, output tokens, and their respective prices. Comparing prices per million tokens overlooks two important variables: how many model calls a task requires and how many tokens each call actually consumes.

    Reasoning models also generate internal reasoning tokens. Many services bill these as output tokens, and they can count toward the generation budget. As a result, a short final answer may cost considerably more than its visible length suggests.

    The following illustrative code estimates the cost of one call. Replace the prices with the actual rates listed by the service provider; no specific pricing is assumed here.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Usage:
    4. input_tokens: int
    5. output_tokens: int
    6. reasoning_tokens: int = 0 # Tokens consumed by internal reasoning
    7. def cost_per_task(usage: Usage, price_in: float, price_out: float) -> float:
    8. """Prices are per million tokens; returns the cost of one task."""
    9. billable_out = usage.output_tokens + usage.reasoning_tokens
    10. return (usage.input_tokens * price_in + billable_out * price_out) / 1_000_000

    This example treats output_tokens as excluding reasoning_tokens; ensure that the usage values supplied match that accounting convention.

    The cost of one attempt is only a starting point. The more useful comparison is the total cost of producing an acceptable result: the cost per attempt multiplied by the average number of attempts, plus the time cost of human rework.

    2. A Four-Part Model Selection Framework

    Evaluate candidates across four dimensions, in the following order.

    2.1 Input Modalities

    The input types a model supports determine the implementation approach. Video processing, for example, commonly follows one of two paths:

    • Direct video input: A shorter processing pipeline, but token consumption and response latency can be difficult to predict. Providers also impose different limits on video duration and frame rate.
    • Extracted frames as image inputs: More control over processing and more predictable costs, but temporal information is lost, potentially reducing accuracy on questions about actions.

    If the application depends on temporal understanding, such as recognizing procedural steps or reviewing an incident, test direct video input first. If it only needs to extract information from key frames, frame extraction is often more economical.

    2.2 Context Window

    The context-window specification describes capacity, not necessarily the amount available for input. Input, reasoning, and output can share that capacity, depending on the model’s limits and accounting rules.

    For example, even with a context window of around one million tokens, reserving tens of thousands of tokens for output and additional capacity for reasoning reduces the space available for input.

    Leave headroom in production. A common approach is to cap input at a proportion of the context window, then split oversized content into sections or compress it through summarization.

    2.3 Output Budget

    The output budget limits how much a model can generate in one response. It is not the same as the length of the final answer. When reasoning is enabled, internal reasoning and the final response may share the same generation budget.

    When that budget runs out, the answer may be truncated or tool-call arguments may be incomplete.

    Code generation, long-document rewriting, and structured reports are particularly susceptible to truncation. Track the truncation rate as a separate evaluation metric rather than checking only whether an answer appears correct.

    2.4 Tool Calling and Structured Output

    Tool calling requires the model to produce arguments that conform to a defined structure. Check three things:

    • Do the arguments conform to the schema?
    • Can retries correct invalid arguments?
    • Are parallel calls to multiple tools reliable?

    Structured-output failures are often subtle. Missing fields, incorrect types, or extra explanatory text can break downstream programs. Measure the proportion of outputs that are valid on the first attempt.

    3. Turn Specifications into Measurable Criteria

    Specification sheets help narrow the candidate list; they should not determine the final ranking. Base the decision on application-level metrics, including at least the following:

    • Task success rate: The proportion of tasks that meet defined acceptance criteria.
    • First-pass success rate: The proportion that pass without retries, indicating the likely rework burden.
    • Average number of calls: The model calls required to complete a task.
    • Cost per task: Calculated from actual token usage and applicable prices.
    • End-to-end latency: Time from the initial request to a usable result, including tool execution.
    • Truncation rate and tool-call validity rate: Indicators of whether the output budget and structured-output reliability are sufficient.

    Measure these metrics on the same dataset to make comparisons meaningful.

    4. A Repeatable Evaluation Process

    The core principle is to control variables. Use the same tasks, prompts, and tool definitions, changing only the model.

    4.1 Build a Task Set

    Include three categories:

    • Common, high-frequency tasks.
    • Edge cases.
    • Tasks known to be failure-prone.

    Small samples can produce conclusions driven by chance. As a general starting point, prepare at least several dozen examples per task category, and document their sources and labeling criteria.

    4.2 Fix Runtime Settings

    Use a low sampling temperature where possible to reduce random variation. Run each model multiple times and measure the variation in results.

    If the difference between two models is smaller than that variation, the evaluation does not justify declaring one better.

    4.3 Combine Automated Checks with Blind Review

    Prefer automated validation wherever possible. Examples include checking whether JSON is valid, whether generated code passes tests, or whether a numerical result matches the reference answer.

    For open-ended responses that cannot be evaluated automatically, use blind review: reviewers should not know which model produced each answer.

    4.4 Illustrative Evaluation Framework

    The following code shows the basic structure of an evaluation loop. The client is a placeholder; replace it with the API wrapper used by your team.

    1. def run_eval(model_id, tasks, client):
    2. results = []
    3. for task in tasks:
    4. resp = client.chat(
    5. model=model_id,
    6. messages=task["messages"],
    7. tools=task["tools"],
    8. temperature=0,
    9. )
    10. ok = task["checker"](resp) # Automated check returning a Boolean
    11. results.append({
    12. "task_id": task["id"],
    13. "ok": ok,
    14. "usage": resp.usage,
    15. "latency": resp.latency,
    16. })
    17. return results

    After running the evaluation, aggregate success rate, truncation rate, and cost per task for each model, then assess them alongside the other metrics defined above.

    5. Select Models by Task Category

    There is no need to use the same model for every workload. A tiered selection strategy can match different constraints:

    • High-volume image-and-text and structured-output tasks: Establish a baseline with predictable costs and acceptable quality. Compare all subsequent candidates against it.
    • Budget-sensitive tasks requiring long outputs: Treat the output budget as a primary constraint, filtering out candidates with high truncation rates first.
    • Tasks that depend on video timing and sequence: Validate direct video input before deciding whether frame extraction is appropriate.
    • Complex agent tasks: Multi-step planning and tool use require evaluation on the same real task set. A model name’s tier suffix indicates product positioning, not proven task success.

    6. Common Selection Mistakes

    1. Treating specifications as performance rankings. Two models with the same context-window size can perform very differently on actual tasks.
    2. Ignoring reasoning-token costs and budget consumption. Looking only at visible output length can underestimate cost.
    3. Testing only successful examples. Failure cases are especially useful for exposing truncation, hallucinations, and formatting errors.
    4. Treating the context limit as the input limit. Output and reasoning may consume part of the available capacity.
    5. Relying indefinitely on a single evaluation. Providers change model versions and prices. Reevaluate periodically and record the test date.

    7. Pre-Deployment Checklist

    Before switching models, confirm the following:

    • Supported input types cover the application’s needs, and video tasks have been tested for temporal understanding.
    • The output budget accommodates the longest expected output for typical tasks, with headroom.
    • Cost per task is calculated from measured token usage rather than estimates.
    • First-pass success rate, truncation rate, and tool-call validity rate meet predefined thresholds.
    • The test set includes edge cases and failure-prone examples, with enough samples to support the conclusions.
    • Test dates, model versions, and runtime settings are recorded so that evaluations can be repeated.

    LLM selection is not a one-time decision. A consistent task set, measurable acceptance criteria, and periodic reevaluation help teams find the right balance between cost and quality.