Practical Guide to LLM Evaluation and Selection for AI Agent Scenarios

    Selecting large language models (LLMs) for AI agent scenarios requires a fundamentally different evaluation methodology compared to traditional chatbot applications. This guide explores how to build a reproducible evaluation bench, control variables effectively, and assess models across five core dimensions: instruction following, tool calling accuracy, skill recognition, long-term stability, and total task cost. We also discuss weighted decision-making, hierarchical routing strategies, common evaluation pitfalls, and practical steps for deploying an evaluation pipeline in production environments.

    1. Why Agent Evaluation Differs from Chat Scenarios

    Chat scenario evaluation is highly subjective: determining whether a response is fluent or informative can often be done with a quick manual review. Agent scenarios are entirely different. The model is no longer just an “answerer” but a “continuous decision-maker.” It must maintain its objective without drifting across multi-turn interactions, correctly identify available skills and tools, generate valid parameters, self-correct upon failure, and proactively pause to request confirmation when encountering high-risk actions.

    This brings three fundamental differences:

    1. Errors accumulate. A slip of the tongue in a chat is harmless, but a wrong tool parameter in an Agent can trigger a string of irreversible side effects.
    2. The evaluation object shifts from “text” to “trajectory.” What needs to be examined is the complete execution chain: thinking, calling, observing results, and making subsequent decisions.
    3. Cost metrics change. It is no longer about the price per million tokens, but rather “how much money, time, and manual fallback is required to complete a real task.”

    Therefore, evaluation methodology must be rebuilt from the ground up; you cannot simply transfer rankings from chat leaderboards.

    2. Controlling Variables: Building a Reproducible Evaluation Bench

    The most common point of failure in evaluation is uncontrolled variables. A frequent mistake is using different system prompts, memory contents, or tool whitelists for different models, resulting in differences that cannot be properly attributed.

    The correct approach is to clone N isomorphic Agent instances, changing only the underlying model:

    1. # Evaluation bench config example (same config, only the model field differs)
    2. agent:
    3. system_prompt: "shared/system.md" # Shared by all candidates
    4. memory:
    5. store: "shared/memory_store" # Same memory snapshot
    6. max_turns: 40
    7. skills:
    8. registry: "shared/skills.yaml" # Same skill registry
    9. tools:
    10. allowlist: ["fs_read", "fs_write", "http_get", "sql_query", "shell"]
    11. confirmation_required: ["fs_write", "shell", "sql_query"]
    12. model:
    13. id: "<candidate>" # The only variable
    14. reasoning_effort: high # Enable high reasoning if available
    15. temperature: 0
    16. task_suite: "shared/tasks_v3.jsonl"

    Three key constraints:

    • Memory and skills must come from the same snapshot. Otherwise, performance differences in long-horizon tasks will be polluted by memory quality.
    • Tool whitelists and confirmation strategies must be consistent. This ensures a fair comparison of whether “high-risk actions are proactively intercepted.”
    • Task sets must be fixed and replayable. Each task should come with explicit success criteria (assertion scripts) to avoid scoring drift caused by manual evaluation.

    3. Five Core Evaluation Dimensions

    1. Instruction Following and Constraint Retention

    Assign the Agent tasks with multiple constraints (format constraints, forbidden actions, priority sequences) and count constraint violations. Focus on observing whether constraints are “forgotten” after long conversations, as this is a primary source of long-horizon task failures.

    2. Tool Calling Accuracy

    Evaluate across three levels: whether tools are called when needed (recall), whether they are falsely triggered when not needed (false positives), and whether the parameters are legally and semantically correct. The third level is the most easily overlooked; many models can generate valid JSON but fill in incorrect paths, time ranges, or pagination parameters.

    3. Skill Recognition and High-Risk Action Confirmation

    This is the stage where Agent frameworks are most prone to “silent failure”: the model failing to load local skills, or neglecting to request confirmation before executing deletions, writes, or scripts. When evaluating, specifically construct induction tasks to measure the trigger rate of confirmation requests. This item is recommended as a veto item—if a model does not meet the standard, it is eliminated immediately and does not participate in subsequent weighted scoring.

    4. Long-Term Stability

    Let the Agent run continuously for 30+ turns and observe three metrics: goal drift (whether it deviates from the initial task), context bloat rate, and whether interruptions or manual reboots occur. Staying online without dropping out for a long duration holds more engineering value than a single impressive turn.

    5. Single-Task Cost and Latency

    Calculate based on the “total consumption to complete a task,” rather than the unit price:

    1. Single-task cost = (input_tokens × price_in + output_tokens × price_out)
    2. + retry_count × single_retry_cost
    3. + manual_fallback_hours × labor_rate

    In practice, a “cheap unit price but high total cost” scenario is common. Models may repeatedly trial-and-error and re-enter the same context, consuming multiple times the tokens of an efficient model. Once retries and manual fallbacks are factored in, the rankings often completely reverse.

    4. Weighted Decision and Hierarchical Routing

    Collect the results into a table and score them based on business weights (example weights can be adjusted according to the scenario):

    Dimension Weight Description
    High-risk action confirmation rate Veto Eliminate if unmet
    Tool calling accuracy 30% Directly impacts the proportion that can be automated
    Instruction following/constraint retention 25% Determines the rework rate
    Long-term stability 20% Determines if unattended operation is possible
    Single-task cost 15% Score after normalization
    Latency 10% Interaction experience

    Evaluation conclusions are rarely “pick one model to rule them all.” A more pragmatic approach is hierarchical routing: a main model handles the long-term unattended main link; high-difficulty reasoning nodes are routed to candidates with stronger reasoning capabilities; high-frequency lightweight tasks (classification, extraction, formatting) are offloaded to low-cost models; for cost-sensitive scenarios that require stability, caching and context pruning are used to compress token consumption.

    1. def route(task):
    2. if task.risk_level == "high":
    3. return model_strong # Prioritize strong constraint following
    4. if task.estimated_tokens < 2000 and task.type in ("classify", "extract"):
    5. return model_cheap # Cost priority
    6. return model_main # Stability priority

    5. Common Pitfalls

    • Testing only the first-turn performance: The true value of an Agent appears after 20 turns.
    • Ignoring confirmation mechanisms: Models that do not intercept high-risk actions are unusable in production engineering.
    • Using unit price instead of total cost: Token consumption differences can completely wipe out price advantages.
    • Task set too small: A dozen tasks are insufficient to differentiate candidates. It is recommended to use 50+ tasks covering failure recovery scenarios.
    • Not recording full trajectories: Without trajectories, attribution is impossible. Logging and monitoring alerts should be first-class citizens in the evaluation bench. Trajectories and metrics should be uniformly saved to log services and object storage for easy replay and comparison.

    6. Implementation Recommendations

    First, use 20 tasks for a smoke test to eliminate unqualified models. Then expand to 50–100 tasks for formal evaluation. Finally, validate with a small-traffic gradual rollout in the production environment, continuously tracking three metrics: success rate, single-task cost, and manual intervention rate, re-evaluating monthly. Models iterate rapidly; selection is not a one-time decision but a continuous process. The combination of general capabilities in model services, container platforms, logging, and monitoring provided by Baidu AI Cloud can support the complete closed loop of this evaluation bench, from initial setup to continuous operation.