LLM Selection for AI Agents: Cost, Capability, and Business-Specific Re-testing

    This article explains how to choose a large language model for AI agent workloads. It focuses on cost per successful task rather than unit price. It covers defining input types and acceptance criteria, reading context and output budgets, calculating task costs, verifying tool-calling behavior, and building a business test set for re-testing.

    1. The Core Question: Cost per Task, Not Unit Price

    Unit price is the basic billing unit, charged per token. Businesses, however, care about how much it costs to complete one job. An agent task usually involves several rounds of model calls: reading context, planning steps, calling tools, parsing the returned results, correcting errors, and producing the final answer. Each round consumes input tokens and output tokens. Some models also consume thinking tokens.

    You can estimate cost with this formula:

    Cost per successful task = total cost per task ÷ task pass rate

    Total cost per task is the sum of input and output costs across all rounds. The pass rate matters a great deal. If a cheaper model passes only 60% of tasks on the first attempt, you need to run about 1.7 times as many tasks to get each success, so the actual spend may not be lower. A more capable model that needs fewer retries can sometimes cost less per successful task. For this reason, the pass rate should be included when comparing models.

    2. Define Input Types and Acceptance Criteria First

    Before selecting a model, answer two questions. First, what is the business input? Is it plain text, mixed images and text, or video? Second, what counts as a completed task?

    The input type determines the candidate pool. Not all models accept images or video. If the business depends on understanding video directly, first filter for models that support video input. If you only need to extract frames from a video and process them afterward, the candidate pool can include models that support only text and images. In that case, your team takes on extra engineering work for frame extraction, subtitle extraction, and timestamp alignment.

    Acceptance criteria determine how you evaluate results. Common dimensions include:

    • Result accuracy: whether field extraction is correct, or whether generated code passes unit tests;
    • Format compliance: whether the output matches the agreed JSON structure;
    • Tool-calling correctness: whether parameters are complete and calls happen in a reasonable order;
    • Step efficiency: how many calling rounds a task takes, and whether there are repeated operations;
    • Security boundaries: whether tools are called beyond authorized scope, and whether sensitive information leaks.

    The more specific the acceptance criteria, the more reliable the re-test conclusions. If the criteria say only “the answers should be good,” different reviewers will judge the results very differently.

    3. Read the Specifications: Context, Output Budget, and Thinking

    Many people assume a model is more capable because its context window is long. Context length only shows how much information the model can receive in one request. Whether the model uses that information correctly must be verified separately.

    When selecting a model, distinguish three figures:

    1. Context window: the total capacity shared by the input and the output generated in the current round.
    2. Single-response output budget: the maximum number of tokens the model can generate in one response. Limits vary widely across platforms, so check the official documentation for each one.
    3. Thinking budget: when reasoning mode is enabled, the chain of thought uses part of the generation space.

    Pay close attention to how these figures interact. On many platforms, thinking content and the final answer share the same output limit, so longer thinking leaves less room for the answer. Some platforms share one total window between input and generation. You cannot assume that the input can fill the window while the output gets its own full window.

    The following sample code checks whether the budget is sufficient before a request is sent:

    1. def check_budget(input_tokens, context_limit, max_output, reserve_for_thinking):
    2. # When input and output share the window, compute the remaining space first
    3. remaining = context_limit - input_tokens
    4. effective_output = min(max_output, remaining)
    5. answer_budget = effective_output - reserve_for_thinking
    6. if answer_budget <= 0:
    7. raise ValueError("Thinking reservation is too large, so the final answer may be truncated")
    8. return answer_budget

    The function only checks the budget. Read the actual values from each platform’s official documentation.

    4. Cost Accounting: Converting Tokens into Business Metrics

    Cost accounting takes five steps.

    Step 1: Measure the average input tokens for each task type. Input usually includes the system prompt, tool definitions, conversation history, and retrieval results. Tool definitions are often overlooked, but in multi-tool scenarios they can account for a large share of input.

    Step 2: Measure the average output tokens. Record thinking tokens and answer tokens separately, because many platforms bill and cap them differently.

    Step 3: Convert each round’s cost using the official price list. Image and video tokenization usually differs from text, so calculate them separately. Do not estimate them from character counts.

    Step 4: Multiply by the average number of rounds to get the cost per task.

    Step 5: Divide by the pass rate to get the cost per successful task.

    The following code shows the logic for Step 5:

    1. def cost_per_success(tasks, price_in, price_out):
    2. # price_in and price_out are the per-token prices, taken from the official price list for the current day
    3. total = 0.0
    4. passed = 0
    5. for t in tasks:
    6. total += t["input_tokens"] * price_in + t["output_tokens"] * price_out
    7. passed += 1 if t["passed"] else 0
    8. return total / max(passed, 1)

    Prices are affected by factors such as cache hits, batch discounts, and off-peak pricing. When you run the accounting, note the date the prices were taken so the figures can be rechecked later.

    5. Tool Calling Is a Baseline, So Verify Agent Performance Separately

    Most mainstream models now support tool calling, so this capability is more of an entry requirement than evidence of agent quality. What separates models in practice is planning stability in multi-step tasks, accuracy in filling parameters, the ability to recover when a tool returns an error, and the ability to keep the goal consistent across long tasks.

    Common failure modes include:

    • Missing required fields in tool parameters, which causes the call to fail;
    • Repeatedly calling the same tool in a loop, which consumes many rounds;
    • Ignoring error messages from tools and fabricating results;
    • Forgetting early constraints as the context grows longer;
    • Writing speculated content into the final answer as if a tool had returned it.

    Agent design can reduce these risks. Common practices include defining strict structural constraints for tool parameters, limiting the maximum number of tool-calling rounds, requiring each conclusion to cite evidence from tool outputs, adding confirmation steps before key actions, and designing clear exit paths for failure cases.

    6. Build a Business Re-test Set

    The re-test set is the most important asset in the selection process. Draw 50 to 200 tasks from real business logs, and cover the following types:

    • High-frequency simple tasks, such as field extraction, classification, and summarization, used to estimate baseline cost;
    • Structured output tasks, which require strict JSON format to test format stability;
    • Multi-step tool tasks that require two or three consecutive tool calls