Practical Evaluation and Engineering of LLM Selection for AI Agents

    Selecting large language models (LLMs) for AI agents requires looking beyond general Q&A performance to evaluate task loop completion, tool utilization, and cost efficiency. This article provides a comprehensive framework for evaluating and engineering LLM-based agents, covering environment setup, five key task categories, cost accounting, troubleshooting, and scoring mechanisms to build reliable agent systems.

    1. The Core Problem of LLM Selection: Can the Model Support a Complete Task Loop?

    When integrating an LLM into an agent, the system’s goal shifts from generating satisfactory text to completing real tasks involving inputs, constraints, tool operations, and acceptance criteria.

    For example, organizing a design experience document into an installable skill package requires reading files, understanding content, identifying applicable scenarios, organizing directories, writing instructions, and checking whether the result complies with loading rules. Web development requires handling execution environments, file modifications, page validation, and error fixing. Knowledge base management involves retrieval, deduplication, source retention, and consistency updates.

    These tasks share common characteristics: the model must maintain goal consistency across multiple steps and adjust subsequent actions based on facts returned by tools. Therefore, agent selection should focus on the following capabilities:

    • Instruction Execution: Understanding goals, constraints, and delivery boundaries.
    • Tool Usage: Selecting the correct tools and properly handling parameters and return results.
    • State Management: Remembering completed steps to avoid repetition or omission.
    • Risk Control: Adhering to authorization requirements for actions like deletion, overwriting, sending, and submitting.
    • Result Verification: Checking actual deliverables rather than merely claiming task completion.
    • Cost Control: Delivering stably within a reasonable time and resource budget.

    This means a model excelling at general Q&A may not be suitable as the core of a long-running agent. Conversely, a model with less flashy expression but stable execution, good tool adaptation, and low error recovery costs might better fit engineering needs. This article provides evaluation methods and implementation suggestions without offering unverified model rankings or performance conclusions.

    2. Establish a Fair Environment Before Discussing Capability Differences

    1. Fix Agent Configuration to Prevent Object Drift

    When evaluating different models, change only the model itself while keeping the following factors consistent:

    • System instructions and task prompts;
    • Initial memory and historical context;
    • Installed skills and their versions;
    • Tool lists, descriptions, and permissions;
    • Working directory, input files, and initial data;
    • Network access conditions and execution resources;
    • Timeout, retry, and task stopping rules.

    If one experimental group has more complete tool descriptions while another lacks a skill index, the final difference cannot be directly attributed to model capability. Similarly, multiple test groups should not share a writable directory. Files generated by one agent might be read by another, causing task leakage. A safer approach is to create an independent workspace for each run and copy inputs from the same read-only snapshot.

    2. Separate “Unified Constraint” and “Best Configuration” Comparisons

    Models differ in inference settings, context capacity, and calling methods. Do not assume settings with similar names represent equivalent computational effort. Therefore, organize two types of experiments:

    Unified Constraint Experiment: Compare under the same budget, time limit, and task requirements to answer “who is more suitable under actual procurement constraints.”

    Best Configuration Experiment: Allow each model to use configurations suitable for itself to answer “what level can be achieved after reasonable optimization.”

    Report both results separately. Otherwise, configuration differences may be mistaken for capability differences, and the cost increase brought by high configurations may be overlooked.

    3. Use Repeated Runs Instead of Relying on a Single Success

    Agent tasks involve a degree of randomness; web states, tool anomalies, and generation paths can all affect results. It is recommended to run the same task repeatedly and record:

    • First-run success rate;
    • Final acceptance pass rate;
    • Number of human interventions;
    • Task duration;
    • Input and output token consumption;
    • Number of tool calls;
    • Failure recovery process.

    Evaluation should retain failure samples rather than only showcasing the most ideal run. In actual deployment, stability is often more important than occasional high-quality output.

    3. Cover Key Agent Capabilities with Five Task Categories

    Category 1: Packaging Experience Documents into Reusable Skills

    A skill package is not a simple copy of a prompt, but a capability description and associated resources that can be discovered, understood, and correctly executed. A maintainable skill package usually needs to specify:

    1. Applicable scenarios and trigger conditions;
    2. Input requirements and prerequisite dependencies;
    3. Standard execution flow;
    4. Deliverables and acceptance criteria;
    5. Inapplicable scenarios and risk boundaries;
    6. Examples, templates, or necessary resources;
    7. Version information and maintenance instructions.

    The directory structure and metadata must comply with the actual specifications of the agent framework being used; do not assume that any format will be automatically loaded.

    Test tasks can require the agent to read a local experience document, organize it into a publishable skill package, and perform a self-check. The most important observation here is not whether the text is neatly formatted, but whether the model can transform implicit experience into executable rules. For example, “the design should have a sense of hierarchy” in the original document needs to be clarified into information priority, layout organization, and acceptance methods; “do not directly modify important content” needs to be translated into pre-modification confirmation, difference preview, or backup requirements.

    Validation should be divided into three levels:

    • Structure Validation: Are the files complete and are the reference paths valid?
    • Loading Validation: Can the framework recognize the skill, and does it meet the actual registration rules?
    • Usage Validation: In a new task, can the agent select the skill and complete the work according to the process?

    Self-checks should not stop at vague statements like “there may be compatibility issues” but should point out specific risks, such as undeclared dependencies, conflicts between examples and rules, overly broad trigger scopes, or missing referenced files. Additionally, if planning to publish publicly, check the usage permissions of the original materials and remove personal information, internal paths, access credentials, and business content unsuitable for public disclosure.

    Category 2: Completing Web Development and Verifying Results

    Web tasks can simultaneously test requirement understanding, code modification, tool calling, and visual inspection capabilities. Task descriptions should clearly define the page purpose, required components, interactive behavior, adaptation scope, and acceptance criteria, avoiding subjective requirements like “make a beautiful page.”

    Validation should at least include:

    • Can the page open normally?
    • Are core interactions effective?
    • Is there obvious overflow on different screen sizes?
    • Do inputs have necessary validation?
    • Are there obvious runtime errors?
    • Do clickable elements have clear feedback?
    • Are form labels and keyboard operations reasonable?

    It is crucial to distinguish between “generated code” and “delivered usable page.” After the model writes the file, it should start or check the running environment, verify the actual result, and fix errors based on feedback. Tool permissions should also be controlled. Development tasks should not default to allowing arbitrary dependency installation, external network access, or modifying files outside the workspace. Necessary operations should be executed in an isolated environment, and newly added dependencies and modification scopes should be recorded.

    Category 3: Creating Presentations and Accompanying Text

    Presentation tasks are not purely typesetting tests; they observe whether the model possesses information organization and narrative planning capabilities. Provide a clear audience, presentation purpose, content source, and length scope for the task, then check:

    • Does the opening explain the problem and goal?
    • Does the content unfold around the main thread?
    • Do the data and conclusions correspond?
    • Does each page have a clear information focus?
    • Do the charts accurately express the original material?
    • Do the speaker notes supplement necessary background?
    • Can the final file be opened and read normally?

    Special attention must be paid to factual consistency. When data is missing, items to be supplemented or explanations of insufficient information should be marked, rather than fabricating numbers to enhance persuasiveness. Visual effects can be evaluated manually, but a fixed scoring rubric should be used, and the generation source should be hidden as much as possible to reduce subjective bias.

    Category 4: Knowledge Base Organization and Incremental Maintenance

    Knowledge base tasks are suitable for testing the model’s ability to handle sources, duplicate content, conflicting information, and long-term state. You can provide a set of documents containing duplicate entries, outdated instructions, and partial conflicts, requiring classification, deduplication, indexing, and update suggestions.

    Key validation points include:

    • Are sources and update times retained?
    • Are original facts distinguished from model summaries?
    • Are conflicts identified rather than arbitrarily merged?
    • Can new content be found via retrieval?
    • Is the repeated generation of existing entries avoided?
    • Are necessary confirmations performed for overwrite and delete operations?

    In engineering implementation, it is recommended to separate “proposing changes” from “executing changes.” The agent first generates a change list, and after the system completes rule validation or human approval, the changes are applied. For repeated runs, idempotency should also be checked: when processing the same batch of inputs again, the system should not continuously generate duplicate entries or meaningless changes.

    Category 5: Executing Browser Automation Tasks

    Browser automation often more easily exposes long-chain execution problems. Pages contain navigation, ads, dynamic content, and irrelevant text, and tools may return large amounts of page information. If the agent repeatedly reads the entire page at every step or continuously retries when the state is unclear, token consumption will increase rapidly.

    Tests can cover searching, cross-page organizing, form filling, and result exporting, but operations involving external submission, payment, or sending messages should have clear confirmation steps. Evaluation focuses include:

    • Does it plan the access path first?
    • Does it accurately identify page states?
    • Does it extract only task-relevant information?
    • Can it handle load failures or element changes?
    • Are there progress-less looping operations?
    • Does it request authorization before irreversible actions?
    • Are verifiable result records saved?

    Text in web pages may also contain instructions unrelated to the user’s goals. Web content should be treated as untrusted input and should not be allowed to override system rules or authorization boundaries.

    4. Convert “Feels Expensive” into Accountable Costs

    Comparing only single-call prices does not reflect the actual economics of an agent. A single task may involve multi-turn reasoning, tool returns, error retries, and human fixes. Therefore, a more meaningful metric is the average cost per successful task:

    Cost per successful task = Total cost during evaluation ÷ Number of accepted tasks.

    Total cost should be calculated based on the actual billing method, including model calls, tool execution, compute resources, and human intervention costs if necessary. If certain costs lack reliable data, they should be listed separately rather than forcing a precise number.

    Token consumption can be further broken down into:

    • System instructions and historical context;
    • User input and business materials;
    • Tool return content;
    • Model output;
    • Other usage recorded or billed by the service.

    Do not directly interpret high consumption for a task as “deeper reasoning.” Long outputs, repeated file reads, invalid tool calls, and failure loops can all cause consumption to rise. For high-consumption samples, trace the execution path to locate the problem: whether it is overly long context, redundant tool responses, or the model repeatedly choosing the wrong path. Find the cause first to determine whether to switch models or optimize the framework.

    5. Distinguish Model Defects from System Integration Issues

    An agent failing to recognize local skills does not necessarily mean the model lacks skill usage capabilities; a high-risk operation not requesting confirmation is not necessarily solely caused by model judgment errors. Troubleshoot in the following order:

    1. Does the skill file exist, and do permissions allow reading?
    2. Does the skill meet loading specifications?
    3. Does the framework provide the skill index to the model?
    4. Are the tool descriptions complete and accurate?
    5. Are permission rules truly enforced by the execution layer?
    6. Did the model receive the necessary context?
    7. Do the tool returns express a clear success or failure state?

    Security requirements in particular cannot exist only in prompts. Operations like deletion, overwriting, and external sending must be checked for permissions and approval status by the tool execution layer. Even if the model requests a non-compliant action, the system should be able to refuse execution. A reliable architecture requires both model-layer constraints and execution-layer controls; security cannot be entirely entrusted to the model’s self-discipline.

    6. Establish Reusable Scoring and Delivery Mechanisms

    It is recommended to break down evaluation results into multiple dimensions rather than directly giving a vague total score.

    Evaluation Dimension Main Observation Content Suggested Basis
    Task Completion Are required deliverables complete? Acceptance checklist
    Output Quality Is content, code, or structure correct? Automated tests & manual review
    Execution Stability Is performance consistent across repeated runs? Multiple run records
    Security & Compliance Are permission and confirmation requirements followed? Tool audit logs
    Resource Efficiency Are cost, time, and calls reasonable? Usage and execution logs
    Maintainability Can results be further modified and reused? File structure, docs, and change logs

    Different businesses should adopt different weights. Internal draft generation can prioritize cost and speed; tasks involving knowledge base writes, account operations, or external publishing should place safety and traceability higher. For severe issues like unauthorized operations or leaking sensitive information, independent elimination conditions should be set rather than letting high scores in other dimensions offset the risk.

    Each run should also retain the task version, configuration snapshot, deliverables, acceptance results, and desensitized tool logs. These materials facilitate reproducibility and help teams conduct regression tests after model or framework updates.

    7. From Selecting Models to Building Reliable Systems

    The ultimate goal of agent selection is not to find a single model that outperforms on all tasks, but to find an execution solution suitable for business constraints. In practice, layering can be done based on task risk and complexity: simple organizing tasks use lower-cost configurations, complex planning tasks are allocated more resources, sensitive operations must undergo approval, and deterministic checks are delegated to rules, tests, and validation programs.

    Task routing and multi-stage processing also increase maintenance costs, so they should be introduced after clear benefits are gained, not just for the sake of architectural complexity. A truly reliable agent system needs to form a closed loop of “Plan - Execute - Verify - Fix - Deliver.” The model is responsible for understanding and decision-making, tools for actual operations, the execution layer for permission boundaries, and the acceptance mechanism for confirming results.

    When evaluation criteria shift from “are the answers amazing” to “can the task be stably completed, can failures be recovered, can costs be controlled, and can operations be audited,” LLM selection becomes a sustainable, iterative engineering process rather than a one-time subjective experience.