A Methodology for Selecting and Evaluating LLMs in Agent Scenarios

    Traditional single-turn Q&A metrics are not enough for AI agents, which must execute multi-step tasks involving tool calls, environment awareness, safety checks, and long-running sessions. This article breaks down agent requirements into five measurable evaluation dimensions, explains how to compute a cost-per-successful-task metric, and provides a reusable Python evaluation framework along with a practical decision process and common pitfalls to avoid.

    1. What New Requirements Do Agents Place on Models?

    Traditional Q&A scenarios focus on the quality of a single response. An agent, by contrast, must complete multiple consecutive steps within one task: understanding the goal, breaking it down into steps, calling tools, reading returned results, correcting the plan, and finally delivering an outcome. This places demands on the model in four areas.

    First, instruction following and tool-calling accuracy. The model must generate parameters according to the agreed function signature; errors in parameter types or required fields directly break the workflow.

    Second, environment awareness. Agents often need to discover and load local skill modules, plugins, or scripts. If the model cannot correctly identify available capabilities, or misjudges their applicable scope, the entire framework will not run as designed.

    Third, safety boundary awareness. Operations such as deleting files, sending messages, or modifying configurations are irreversible. The model should identify risks and request confirmation before execution, rather than acting directly.

    Fourth, long-running stability. A multi-step task may last tens of minutes. If a connection drop, context loss, or output format drift occurs during that time, the task requires manual takeover.

    2. Five Core Evaluation Dimensions

    When selecting a model, break the above requirements into quantifiable dimensions and use the same test set for each.

    2.1 Tool-Calling Accuracy

    Prepare a set of test cases covering simple queries, multi-parameter calls, and nested calls, and measure the following:

    • Whether the function name is correct;
    • Whether parameter types and required fields are complete;
    • Whether dependencies between steps are correctly passed in multi-step calls;
    • Whether the model can retry based on error messages after a failure.

    Run each case category at least thirty times and observe the distribution of results, rather than relying on a single success rate.

    2.2 Local Capability Discovery

    Build a local directory containing descriptions of multiple skills, and require the model to list available skills at the start of a task and select the correct one to execute. Evaluation focus: whether it can read description files, ignore irrelevant skills, and clearly report when a skill cannot be found—instead of fabricating a call result.

    2.3 Confirmation Mechanism for High-Risk Operations

    Define a list of high-risk operations, such as batch deletion, outbound sending, and permission changes. During testing, check whether the model pauses before execution and explains the scope of impact. A qualified agent should: stop when it encounters a high-risk operation, output an operation summary, and continue only after explicit authorization.

    2.4 Reasoning Effort Levels and Latency

    Most models offer different reasoning effort options. Higher reasoning levels generally improve accuracy on complex tasks, but increase response time and token consumption. Test the same task at low, medium, and high levels, recording accuracy, time to first token, and total duration, to find the balance your business can accept.

    2.5 Stability and Long-Session Performance

    Simulate a continuous task lasting over an hour, injecting network timeouts and malformed outputs along the way, and observe whether the model can recover context and maintain consistent output structure. A model with poor stability will struggle to support unattended workflows even if its single-run performance is excellent.

    3. Cost Model: Pay-as-You-Go vs. Subscription

    Model cost typically consists of two parts.

    Pay-as-you-go: cost per call = input tokens × input unit price + output tokens × output unit price.

    Subscription or quota plans: suitable for interactive use, but in automated scenarios, quota consumption is hard to predict, and rate limiting can disrupt task continuity.

    Note that token consumption in agent scenarios is far higher than in ordinary chat, because every step carries tool definitions, historical results, and intermediate reasoning. For the same task, token consumption across models can differ by several times. Therefore, selection should be based on per-task cost measured from real workloads, not just the unit price list.

    The estimation method is as follows:

    1. Select twenty representative tasks covering common scenarios;
    2. Run them on each model and record input and output tokens;
    3. Compute average cost per task and success rate;
    4. Use “cost per successful task = total cost ÷ number of successful tasks” as the core metric.

    This metric reflects both price and reliability, making it more useful than comparing unit prices alone.

    4. Building a Reusable Evaluation Framework

    Below is a simplified evaluation skeleton for uniformly recording results across dimensions. The model invocation part is illustrative and should be replaced with the client your team actually uses.

    1. import time
    2. from dataclasses import dataclass, field
    3. @dataclass
    4. class CaseResult:
    5. case_id: str
    6. passed: bool
    7. input_tokens: int
    8. output_tokens: int
    9. latency_s: float
    10. notes: list = field(default_factory=list)
    11. def run_case(model_client, case: dict) -> CaseResult:
    12. start = time.time()
    13. # Placeholder: call the model and return a structured result
    14. resp = model_client.chat(messages=case["messages"], tools=case["tools"])
    15. latency = time.time() - start
    16. passed = case["checker"](resp) # The checker function bundled with each case
    17. return CaseResult(
    18. case_id=case["id"],
    19. passed=passed,
    20. input_tokens=resp.usage.input_tokens,
    21. output_tokens=resp.usage.output_tokens,
    22. latency_s=latency,
    23. )
    24. def summarize(results: list[CaseResult]) -> dict:
    25. n = len(results)
    26. success = sum(r.passed for r in results)
    27. total_cost_tokens = sum(r.input_tokens + r.output_tokens for r in results)
    28. return {
    29. "success_rate": success / n if n else 0.0,
    30. "avg_latency_s": sum(r.latency_s for r in results) / n if n else 0.0,
    31. "tokens_per_success": total_cost_tokens / success if success else None,
    32. }

    The key to the framework is the checker function. Each case should have explicit pass criteria—for example, “parameters are complete and the function name matches” or “a confirmation prompt appears before high-risk operations”—rather than relying on subjective scoring.

    5. The Model Selection Decision Process

    1. Define your business scenario: distinguish between interactive assistance, batch automation, and unattended tasks—the three differ greatly in their requirements for stability and safety.
    2. Set threshold metrics: for example, tool-calling accuracy must not fall below a certain threshold, and the confirmation rate for high-risk operations must reach 100%. Models that fail these thresholds are eliminated directly.
    3. Compare cost per successful task: among the qualifying models, compare cost per successful task and latency.
    4. Run a small-scale pilot: after selecting a model, run it on low-risk tasks for one to two weeks, collect real-world data, and then gradually expand the scope.
    5. Preserve the ability to switch: invoke models through a unified abstraction layer so that switching models only requires changing configuration, not rewriting business logic.

    6. Common Pitfalls

    • Looking only at unit price, not token consumption. A model with a low unit price but verbose reasoning may end up costing more overall.
    • Testing only once. Model outputs are stochastic; a single result does not represent real performance.
    • Neglecting safety testing. Many framework issues appear in edge cases; testing only the happy path easily misses risks.
    • Equating conversational quality with agent capability. Fluent dialogue does not guarantee equally reliable tool calling and long-task execution.

    7. Summary

    Model selection for agent scenarios is essentially a business-oriented engineering evaluation. Teams should first decompose requirements into testable dimensions, compare models using a unified dataset and consistent pass criteria, and then make the decision based on cost per successful task. This methodology does not depend on any specific model and can be reused continuously as model versions evolve.