LLM Agent Evaluation: Capabilities, Costs, and Model Selection

    Learn how to evaluate LLM agents across instruction understanding, planning, self-checking, output consistency, and resource usage. This article outlines a model-independent testing framework, Python examples, token-based cost calculations, and practical criteria for choosing models for structured text analysis tasks.

    1. Why Agent Capabilities Need Separate Evaluation

    Public large language model benchmarks typically focus on single-turn question answering or code generation. Agent workflows require a model to break down goals, call tools, inspect intermediate results, and correct errors across multiple interactions. These capabilities do not fully overlap. A model that performs well on single-turn benchmarks may drift from instructions, omit steps, or repeat actions during a longer workflow.

    For developers, model selection usually involves three sets of constraints:

    1. Capability: Can the model understand real requirements and complete tasks reliably?
    2. Engineering: Is the runtime framework easy to adapt? Are interfaces consistent? Can the underlying model be replaced without changing business logic?
    3. Cost: Are token usage and billing predictable, and is ongoing use affordable?

    This article uses a common task as an example: analyzing a text across several dimensions, such as sentiment, topics, entities, and summarization, then producing a structured report. The workflow is short and its results are verifiable, making it a useful starting point for agent evaluation.

    2. Breaking Down a Basic Agent Task

    A minimal text analysis agent typically includes the following stages:

    • Task interpretation: Convert the user’s natural-language request into an explicit list of subtasks.
    • Planning: Determine the execution order and the required inputs and output formats for each step.
    • Execution: Use a model or tool to complete each step.
    • Self-checking: Verify output format, field completeness, and business rules.
    • Correction: If validation fails, rerun the step with information about the error.
    • Aggregation: Combine intermediate results into a final report.

    Evaluation should record performance at each stage rather than simply checking whether the final output is correct. When a result is wrong, the evaluation should distinguish among interpretation errors, planning flaws, execution failures, and problems that self-checking failed to detect.

    3. Designing Evaluation Criteria

    Build a scorecard around the following five dimensions. Each can use a 0–5 scale or a binary pass/fail assessment.

    3.1 Instruction Understanding

    Instruction understanding measures whether the model correctly identifies user intent, including implicit requirements. For example, when asked to “analyze this customer review,” the model should infer relevant dimensions such as sentiment, topics, and key entities rather than produce only a one-sentence summary.

    Test method: Write ten differently worded requests with the same intent and compare their output structures. Large differences in the analysis dimensions suggest inconsistent instruction understanding.

    3.2 Task Planning

    Planning measures whether the model can break a complex goal into reasonable steps while preserving dependencies. For example, entity extraction should precede relationship analysis based on those entities.

    Test method: Ask the model to provide a plan before execution, then compare it with a human-authored reference plan. Count missing steps, ordering errors, and redundant steps.

    3.3 Self-Checking and Correction

    Self-checking is a key capability that distinguishes agents from ordinary question-answering systems. An effective checking process should identify:

    • Missing fields or incorrect field types.
    • Classification labels outside a predefined set.
    • Summaries that exceed the agreed length.
    • Conclusions that contradict facts in the source text.

    Correction requires the model to repair the result using the error feedback rather than generate unrelated content. Tests can deliberately inject errors—for example, an invalid label in an intermediate result—to see whether the model detects and fixes them.

    3.4 Output Structure Consistency

    Downstream steps in an agent workflow often depend on structured outputs from earlier steps. Format consistency therefore directly affects system reliability.

    Measure format compliance across 100 consecutive runs and record the types of parsing failures.

    3.5 Resource Usage

    Resource usage includes input tokens, visible output tokens, internal reasoning tokens, and the number of interaction rounds needed to complete a task. Consumption can vary substantially between models performing the same task, so it should be measured separately alongside capability scores.

    4. Testing Method and Example Code

    To compare models under consistent conditions, place model calls behind a common interface and separate business logic from model-specific implementations.

    The following example illustrates a general evaluation framework. The model client is a placeholder interface and does not depend on any vendor-specific API.

    1. from dataclasses import dataclass, field
    2. from typing import Protocol, List, Dict
    3. class ChatModel(Protocol):
    4. """Common model interface implemented by model-specific adapters."""
    5. def complete(self, messages: List[Dict[str, str]]) -> "ModelResponse":
    6. ...
    7. @dataclass
    8. class ModelResponse:
    9. text: str
    10. input_tokens: int
    11. output_tokens: int # Includes visible output and internal reasoning tokens
    12. latency_seconds: float
    13. @dataclass
    14. class RunRecord:
    15. task_id: str
    16. passed_format_check: bool
    17. steps_planned: int
    18. steps_expected: int
    19. self_check_fixes: int
    20. total_input_tokens: int = 0
    21. total_output_tokens: int = 0
    22. notes: List[str] = field(default_factory=list)
    23. def run_task(model: ChatModel, task_id: str, prompt: str, validator) -> RunRecord:
    24. record = RunRecord(task_id=task_id, passed_format_check=False,
    25. steps_planned=0, steps_expected=5, self_check_fixes=0)
    26. messages = [{"role": "user", "content": prompt}]
    27. for attempt in range(3): # Allow up to three attempts
    28. resp = model.complete(messages)
    29. record.total_input_tokens += resp.input_tokens
    30. record.total_output_tokens += resp.output_tokens
    31. ok, error_msg = validator(resp.text)
    32. if ok:
    33. record.passed_format_check = True
    34. break
    35. record.self_check_fixes += 1
    36. messages.append({"role": "assistant", "content": resp.text})
    37. messages.append({"role": "user",
    38. "content": f"Output validation failed: {error_msg}. "
    39. "Please correct the result and return it again."})
    40. return record

    The framework has three main design principles:

    1. A common interface: Replacing the underlying model requires changing only the adapter, not the evaluation logic.
    2. Complete records: Preserve inputs, outputs, and correction counts for later analysis.
    3. Measurable correction behavior: Correction counts help quantify reliability. Fewer corrections generally indicate a higher first-attempt success rate.

    The example provides the basic call-and-validation loop. Stage-level measurements and complete input/output records should be captured as part of the evaluation.

    Test samples should cover texts of different lengths, writing styles, and domains, with at least 20 samples per category. Two annotators should independently produce reference answers to reduce bias from a single annotator.

    5. Cost Modeling: Usage-Based Billing vs. Monthly Subscriptions

    Agent costs are often underestimated because one task may trigger multiple model calls, with context counted again in each round.

    Estimate task cost using:

    Cost per task = input tokens × input price per token + output tokens × output price per token

    When internal reasoning tokens are billed as output tokens, longer reasoning increases cost. Include those tokens in the calculation according to the model’s billing rules.

    The following hypothetical example illustrates the calculation. The figures do not represent actual pricing; amounts are expressed in Chinese yuan (CNY).

    1. def task_cost(input_tokens: int, output_tokens: int,
    2. price_in_per_m: float, price_out_per_m: float) -> float:
    3. return (input_tokens / 1_000_000) * price_in_per_m \
    4. + (output_tokens / 1_000_000) * price_out_per_m
    5. # Assumptions: 40,000 input tokens and 15,000 output tokens per task,
    6. # including reasoning tokens.
    7. # Prices: CNY 2 per million input tokens and CNY 8 per million output tokens.
    8. per_task = task_cost(40_000, 15_000, 2.0, 8.0)
    9. print(f"Estimated cost per task: CNY {per_task:.3f}") # CNY 0.200
    10. daily_tasks = 200
    11. print(f"Estimated usage-based cost for {daily_tasks} tasks per day: "
    12. f"CNY {per_task * daily_tasks:.1f}")

    Usage-based billing lets teams pay for what they consume, making it suitable for experimentation. Its drawback is that costs rise with call volume and may be difficult to forecast.

    Monthly subscriptions make the base cost fixed, but usually impose usage limits. Check the contract or service terms to understand how excess usage is handled.

    Calculate two thresholds when comparing options:

    • Break-even volume: Divide the monthly subscription fee by the usage-based cost per task. Below that monthly task volume, usage-based billing is cheaper; above it, a subscription may be cheaper, provided its allowance covers the workload.
    • Capacity headroom: Divide the subscription allowance by average task consumption to estimate how many tasks it supports, then assess whether that capacity covers peak demand.

    6. Managing Token Usage from Long Reasoning

    Some models produce lengthy internal reasoning during testing. For simple tasks, this may add little improvement in quality while substantially increasing latency and token usage.

    Practical controls include:

    1. Tiered model calls: Use a model or mode with shorter reasoning for simple steps, reserving deeper reasoning for complex planning and correction.
    2. Context trimming: Keep only the history relevant to the current step instead of allowing the entire conversation to grow indefinitely.
    3. Structured output constraints: Specify formats and length limits in prompts to reduce unnecessary text.
    4. Intermediate-result caching: Reuse analysis results for identical inputs to avoid repeated computation.
    5. Budget thresholds: Set a maximum token budget per task. Stop and record tasks that exceed it to limit consumption from abnormal loops.

    The following code illustrates a basic budget guard:

    1. class BudgetExceeded(Exception):
    2. pass
    3. class BudgetGuard:
    4. def __init__(self, max_tokens: int):
    5. self.max_tokens = max_tokens
    6. self.used = 0
    7. def charge(self, tokens: int) -> None:
    8. self.used += tokens
    9. if self.used > self.max_tokens:
    10. raise BudgetExceeded(
    11. f"Used {self.used} tokens, exceeding the limit of {self.max_tokens}"
    12. )

    Call charge after each model invocation to stop further execution when accumulated usage exceeds the budget. Because this check occurs after a call, it detects an overrun rather than preventing that call from exceeding the limit.

    7. Balancing Capability and Cost

    Evaluation rarely identifies a single best model for every requirement. One model may understand instructions well but produce unnecessarily long plans. Another may execute consistently yet misinterpret more complex requests.

    Selection should reflect the application’s tolerance for errors:

    • Accuracy-sensitive workloads: Prioritize self-checking and correction, accepting higher token usage where necessary.
    • High-volume, low-margin workloads: Prioritize predictable costs and consistent output formats.
    • Projects with frequently changing requirements: Keep the framework and model layers separate so that switching models does not require rewriting business logic.

    The engineering foundation is a model-call interface, with prompts, validation rules, and evaluation samples maintained in version control. When a new model becomes available, teams can run the same dataset and compare results instead of relying on subjective impressions.

    8. Common Evaluation Mistakes

    Mistake 1: Judging capability from a handful of examples.
    A few trials rarely expose long-tail failures. Build a fixed evaluation dataset and run regression tests regularly.

    Mistake 2: Checking only the final output.
    A correct final result can hide inefficient intermediate steps, including repeated unsuccessful corrections. These inefficiencies become expensive at scale.

    Mistake 3: Ignoring reasoning-token billing.
    Whether reasoning is visible does not determine whether it consumes billable resources. Cost estimates must include all billed output tokens.

    Mistake 4: Treating a monthly allowance as unlimited usage.
    Allowances typically have scope restrictions and peak-use limits. Confirm availability under peak demand before deployment.

    9. Conclusion

    LLM agent evaluation should cover five dimensions: instruction understanding, planning, self-checking, output structure consistency, and resource usage. Use a common interface and fixed test samples, and record performance throughout the workflow rather than relying on isolated trials.

    For cost comparisons, calculate input and output charges separately and use break-even volume to assess usage-based billing against monthly subscriptions.

    For basic text analysis tasks, the practical sequence is to build the evaluation framework, compare candidate models using real samples, and make the selection based on measured results. Separating the framework from the model reduces migration costs and allows teams to evaluate new models without repeatedly rebuilding their systems.