AI Agent Model Selection Guide: How to Choose the Underlying LLM

    This guide explains how to choose the large language model behind an AI agent. It covers the difference between the execution layer and the reasoning layer, three questions to answer before selecting a model, six core evaluation dimensions, a sample evaluation framework, per-task cost estimation, and engineering methods for reducing hallucinations.

    1. Where Agent Capabilities Come From

    An AI agent is usually made of three parts: a perception and input interface, an execution layer that calls tools, reads and writes files, and operates web pages, and a reasoning layer, which is the large language model (LLM). The execution layer determines what the agent can do. The reasoning layer determines whether it does the right thing.

    The two layers divide the work this way. The execution layer works like hands and feet, carrying tasks out. The LLM works like a brain, understanding goals, breaking them into steps, and deciding the next action. However well the execution layer is built, the final results stay unreliable if the reasoning layer often misreads instructions or fabricates facts. When selecting a model, treat model capability as a core variable, not just the interface and feature list.

    2. Three Questions to Answer Before Choosing a Model

    1. What type of task is it?

    Different tasks place very different demands on the model:

    • Information organization, format conversion, and summarization require low reasoning depth. Speed and cost matter most.
    • Multi-step workflows, such as reading data, calling APIs, and generating reports, require the model to follow formats reliably and use tools correctly.
    • Code changes, complex decisions, and cross-document reasoning require strong planning and long-context handling.

    2. How costly is an error?

    If the output is only for internal reference, occasional errors may be acceptable. If the result directly affects external publishing, financial data, or system changes, add validation steps and manual confirmation checkpoints. The higher the cost of an error, the more priority should go to factual accuracy and stability, not just the lowest price.

    3. What are the limits on budget and latency?

    Agents often need several rounds of model calls, and a single task may involve dozens of requests. The price and latency of each call get multiplied across those rounds. Estimate cost and time per task, not per call.

    3. Six Core Evaluation Dimensions

    1. Instruction following and format stability

    Ask the model to produce a specified structure, such as JSON with fixed fields or a report with fixed sections. Measuring the format error rate is more reliable than relying on subjective impressions.

    2. Tool-calling accuracy

    Check whether the model selects the right tool, fills in correct parameters, and interprets returned results correctly. Focus on the rates of missing parameters, type errors, and invalid calls.

    3. Factuality and hallucination control

    Sample questions with known answers, record how often the model fabricates information, and observe whether it states uncertainty when it lacks an answer. A model that admits “I don’t know” is generally safer in business settings.

    4. Multi-step planning

    Give the model a task that requires three to five steps. Check whether it skips steps, orders them sensibly, and adjusts its plan after an intermediate failure.

    5. Long-context handling

    When inputs contain many documents or long histories, check whether the model accurately cites key information instead of omitting or confusing details.

    6. Latency and cost

    Latency affects user experience. Cost determines whether deployment at scale is feasible. Calculate both together with task frequency.

    4. Replacing Subjective Impressions with an Evaluation Set

    Many model selection failures happen because teams decide based on a few demos. A more reliable approach is to build an evaluation set tied to your business. Include dozens to hundreds of representative samples, and define a clear pass or fail standard for each one.

    The following is a simplified evaluation framework. Replace the model call function with the API you actually use.

    1. import json
    2. from dataclasses import dataclass
    3. @dataclass
    4. class TestCase:
    5. prompt: str
    6. expected_keys: list # Fields that must appear in the expected output
    7. fact_answer: str = "" # Optional: known factual answer
    8. def call_model(model_name: str, prompt: str) -> str:
    9. """Replace with the actual model call logic."""
    10. raise NotImplementedError
    11. def evaluate(model_name: str, cases: list[TestCase]) -> dict:
    12. format_ok = 0
    13. fact_ok, fact_total = 0, 0
    14. for case in cases:
    15. raw = call_model(model_name, case.prompt)
    16. try:
    17. data = json.loads(raw)
    18. if all(k in data for k in case.expected_keys):
    19. format_ok += 1
    20. except json.JSONDecodeError:
    21. pass
    22. if case.fact_answer:
    23. fact_total += 1
    24. if case.fact_answer in raw:
    25. fact_ok += 1
    26. return {
    27. "format_pass_rate": format_ok / len(cases),
    28. "fact_pass_rate": fact_ok / fact_total if fact_total else None,
    29. }

    The key to this framework is turning “how well it works” into countable metrics. After running the same test cases, you can compare models side by side on format and factuality. Keyword matching is a rough check. Formal evaluations should add human review or more detailed scoring rules.

    5. Estimating Per-Task Cost Using Billing Multipliers

    Many platforms bill by credits or billing multipliers, and each model consumes credits at a different rate. In that case, calculate the combined cost of each task:

    Cost per task = credits per call × average number of calls × price per credit

    The following is an illustrative calculation. The numbers only demonstrate the method.

    • Model A has a low multiplier, but it needs about 8 calls per task on average because format errors trigger retries.
    • Model B has a high multiplier, but it needs only about 3 calls on average because it succeeds more often on the first attempt.

    In this example, the model with the higher multiplier is not necessarily more expensive. The right measure is the total consumption needed to produce one usable result, not the consumption of a single call. Therefore, “higher credit consumption means a stronger model” does not hold. High consumption may reflect greater reasoning depth, or it may simply reflect higher pricing. Use evaluation data to decide.

    6. Controlling Hallucinations with Engineering Measures

    Even with a capable model, hallucinations cannot be fully eliminated. Common engineering practices include:

    • Retrieval augmentation: Retrieve material from trusted data sources first. Then have the model answer based on that material and require it to cite sources.
    • Structured output and validation: Require a fixed output structure. Use code to automatically validate fields, numeric ranges, and cited sources.
    • Staged execution: Split complex tasks into planning, execution, and review steps. The review step can use a separate prompt or stricter rules.
    • Human confirmation checkpoints: Operations such as deleting data, sending content externally, or changing permissions must be confirmed by a person.
    • Fallback on failure: When a tool call fails, log the error and let the agent switch to a backup approach instead of forcing a conclusion.

    The common goal of these measures is to treat model output as a draft to be verified, not as a final result.

    7. Implementation Advice and Common Pitfalls

    Recommended selection process

    1. List the three to five most common task types in your business and define the success criteria for each.
    2. Prepare evaluation samples for each task type, with expected results labeled.
    3. Run the same samples on each candidate model. Record the format pass rate, tool-calling accuracy, factuality, and average latency.
    4. Calculate the combined cost per task, then make a weighted decision that includes quality metrics.
    5. Run a small pilot for one to two weeks. Observe feedback from real users and the types of errors they encounter.
    6. Set up regular re-testing, because model version updates can change performance.

    Common pitfalls

    • Judging only by demo results and ignoring failure rates.
    • Looking only at the per-call price and ignoring the multiplying effect of retries and multi-round calls.
    • Assuming the most capable model suits every task. Using an expensive model for simple tasks adds unnecessary cost.
    • Overlooking hallucination risk and treating a model’s confident tone as proof of correctness.

    Model selection ultimately balances quality, cost, and risk. Standardizing and quantifying the evaluation process keeps your decisions stable even as models change quickly.