Choosing and Combining LLMs for AI Agents: A Practical Guide to Model Selection

    Selecting models for AI agents requires a very different approach from chat benchmarks. This article explains how to design evaluation scenarios, identify the capabilities agent frameworks actually depend on, analyze cost structures, assign models by role, and set up observability and rollout steps for production agent systems.

    Model selection for AI agents cannot follow the “higher benchmark score is better” mindset used for chat evaluation. A real task typically spans intent clarification, plan decomposition, local skill or tool retrieval, parameter filling, execution, result validation, and failure fallback. The model has to work continuously along this chain, and instability at any link shows up as interrupted tasks, repeated calls, unauthorized operations, or runaway costs. What you should compare, therefore, is “behavior within a given agent framework,” not isolated question-answering ability.

    Define Evaluation Scenarios Before Arguing About Model Strength

    Before running a head-to-head comparison, fix the task families first. Cover at least four categories: short-range code modifications, multi-file refactoring, operations that require reading local instructions or skill documentation, and workflows involving high-risk actions such as deletion, publishing, payment, or permission changes. Each task family should use the same system prompt, the same tool list, the same temperature and timeout policy, and a record of whether higher-effort reasoning was enabled. Otherwise, the difference between a “strong model” and a “budget model” may simply be a difference in test conditions.

    Evaluation should not only look at whether the task ultimately succeeds. Record at least: whether the plan is executable, whether tool choices are correct, whether parameters are complete, whether the model can recover from error messages, whether it pauses for confirmation before high-risk actions, total tokens and latency, and the variance across three repeated runs of the same task. A model with high variance is not suitable as a long-running online executor.

    The Capabilities Agent Frameworks Actually Rely On

    Many teams treat “writes good code” as the only criterion, but agent failures often occur at the framework layer.

    First is skill and tool discoverability. The model must select the correct tool from a given list based on the task description, rather than inventing a nonexistent call. If the model ignores local skill documentation or treats natural-language instructions as authorized actions, strong execution downstream is meaningless. In engineering terms, keep tool descriptions short and explicit, and constrain them with a few positive and negative examples. During evaluation, deliberately construct tools with similar names but different purposes and measure the mis-selection rate.

    Second is permission boundaries. High-risk actions must go through explicit confirmation. Confirmation is not a slogan in the prompt; it is a runtime policy: without a confirmation token, the executor refuses to proceed. The model’s job is to recognize risk and generate a confirmation request; the gateway’s job is to enforce the block. If a model repeatedly skips asking during evaluation, adding more prompt text is not enough—demote it to read-only planning or deny it direct access to write-capable tools.

    Third is long-horizon consistency. A primary model must maintain goals, constraints, and completed steps across a long session instead of re-planning every turn. The longer the context, the higher the cost of re-reading history and the easier it is for early errors to propagate into later steps. In practice, compress “goal, constraints, current plan, verified facts” into a short state and periodically replace the raw long log.

    Explaining “Expensive” and “Burns Fast” Through Cost Structure

    Price cannot be judged by per-call unit cost alone. Agent costs roughly consist of four parts: input context, reasoning process, tool round trips, and failure retries. High-reasoning modes add thinking overhead; long system prompts and repeatedly pasted code inflate input; incorrect tool calls trigger another round of correction. So a cheaper model with more retries may not produce a lower total bill, while a pricier model that converges in one planning pass may be the better deal.

    Do task-level accounting rather than model-level slogans. Set budget caps per task family, such as maximum rounds, maximum input length, and maximum tool calls. On exceeding a cap, degrade automatically: stop digging deeper and instead output the current diff, blockers, and a human handoff point. Subscriptions or plans suit stable, predictable coding workloads; pay-as-you-go APIs suit bursts and experiments. The two can coexist, but must be metered by the same quota service so an unattended “primary session” cannot drain the entire allowance.

    Also distinguish the interactive entry point from the execution entry point. Work that requires frequent trial and error, design review, or short creative bursts can stay in the interactive interface where a human can interrupt at any time. Work that involves long batch processing, repository inspection, or low-risk patches is better routed to an execution channel with quotas, logging, and circuit breakers. Wiring your most expensive or least stable capability to the fully automatic executor by default is rarely the cost-optimal choice.

    A Workable Combination Instead of One Model for Everything

    A more robust approach is to divide roles rather than hunt for a single do-everything model.

    The planner role decomposes tasks, identifies risks, and lists acceptance criteria; it can use a heavier reasoning configuration, but with a limited number of rounds. The executor role calls tools according to the confirmed plan, modifies code, and reports diffs; prioritize models with high tool-hit rates in your target framework, stable long sessions, and predictable per-task consumption. The validator role is read-only: it checks results against acceptance criteria and holds no write permissions. The batch role handles formatting, summarization, and log classification with a cheaper configuration.

    Routing should follow explicit rules rather than letting a single model “freely decide everything.” For example: force confirmation whenever deletion, external publishing, secrets, or permissions are involved; after two consecutive tool-parameter errors, switch to a more conservative execution strategy; compress state once the context exceeds a threshold; stop automatic execution when a task exceeds its budget. These rules belong in the gateway and must not depend on the model’s goodwill.

    Illustrative logic:

    1. on_task(task):
    2. plan = planner.draft(task, tools, risk_policy)
    3. if plan.risk == high and not confirmed(plan):
    4. return ask_user(plan)
    5. state = compress(plan, repo_facts)
    6. for step in plan.steps:
    7. if budget.exceeded(step):
    8. return handoff(state)
    9. result = executor.run(step, state)
    10. if not validator.accept(result, step.criteria):
    11. state = record_failure(state, result)
    12. if retries(step) >= 2:
    13. return handoff(state)
    14. return validator.summary(state)

    What this logic emphasizes is separation of responsibilities and budget circuit-breaking; specific models are replaceable implementations. When swapping models, keep the tool protocol, confirmation tokens, and log fields unchanged so that real differences become comparable.

    What to Observe to Avoid “Feels Strong”

    Build a minimal observability set before going live: task success rate, human handoff rate, tool first-hit rate, missed high-risk confirmations, per-task input and output tokens, retry count, end-to-end latency, and failure type distribution. Missed confirmations should be a hard metric—a single unconfirmed high-risk execution should block that route, not be counted as acceptable variance.

    Keep the regression set small and stable. Every time you adjust prompts, tool descriptions, or routing thresholds, rerun the same batch of tasks. Averages alone are not enough; watch the tail as well. The most expensive ten percent of tasks usually come from context bloat and retry loops. Address the tail with state compression, restricting readable file scope, and caching verified facts—not by blindly increasing reasoning effort.

    Log the model’s plans, actual tool names, parameter validation results, and human confirmation records, but do not store secrets or unrelated private data. Audit fields should include at least task ID, routing decision, budget consumption, and final status. In enterprise environments, these capabilities can live on a unified logging, monitoring and alerting, object storage, and permission stack; if you are already on a general-purpose cloud platform such as Baidu AI Cloud, reuse its existing audit and quota capabilities instead of building an untraceable one-off evaluation script.

    Rollout Sequence

    Step one: build a baseline with ten real tasks, fixing the tool list and risk policy. Step two: measure the success rate and per-task cost of “heavy-reasoning planner plus stable executor” versus “a single model doing everything end to end.” Step three: implement high-risk confirmation and budget circuit-breaking as gateway rules. Step four: only routes that pass regression go into the long-running primary channel; everything else stays at a staffed interactive entry point.

    The conclusion is straightforward: an agent’s “perfect match” is not a specific model, but a system where planning, execution, validation, confirmation, and budgeting are separated—each reliable, stoppable, and accountable. Models can be swapped; the framework and its constraints should not change with the marketing cycle.