Evaluating LLM Stability and Speed in Agent Workflows

    This article explains how to systematically evaluate large language models for agent use, focusing on context caching, tool-call reliability, first-token latency, output throughput, reasoning overhead, and multimodal input. It outlines a reproducible testing method with task sets, metrics, logging, and controlled conditions, then discusses how to interpret results, avoid common pitfalls, and prepare for model version changes.

    1. Why Test Versions Deserve Systematic Evaluation

    Before an official release, large model vendors often provide intermediate or limited-time test versions. These versions usually come without complete announcements or performance documentation, so developers can only understand their behavior through actual calls. For teams building agents, the test period is a window to map capability boundaries, but it is also easy to draw conclusions from the subjective feel of a few calls.

    Subjective experience is not without value. It can indicate direction. For example, a task that returns quickly or a tool call that does not fail is a useful signal. However, agent tasks often involve a dozen or more continuous operations, and a single success or failure cannot reflect overall reliability. Evaluation should therefore turn impressions into metrics that can be counted and reproduced.

    In addition, test versions usually have a defined validity period or a later replacement plan. If a team binds business logic directly to a version name, it will face significant migration costs when that version goes offline. The second goal of evaluation is therefore to test replaceability: whether prompts, tool definitions, and log structures can remain unchanged when the model is switched.

    2. Core Requirements for Models in Agent Scenarios

    The difference between an agent and ordinary question answering is that the model must make repeated decisions in a loop: read the context, decide whether to call a tool, parse the tool result, and decide the next step. This structure imposes three main types of requirements on the model.

    2.1 Context Caching and Input Cost

    Agent sessions are usually long. Each request carries the system prompt, history messages, tool definitions, and the contents of files that have been read, and most of this prefix remains unchanged across turns. If the server can identify and reuse the computation for this prefix, it can significantly reduce latency and input cost.

    The core metric for this capability is cache hit rate, which is the proportion of input tokens that hit the cache out of all input tokens. Another useful metric is the ratio of cache reads to uncached input. The higher the ratio, the more fully repeated prefixes in long sessions are reused.

    Note that caching behavior is affected by prefix stability. If a timestamp or random identifier is inserted at the beginning of the system prompt on every turn, the cache will almost never hit. Therefore, even if the model itself supports caching, the prompt structure on the application side must be adjusted accordingly.

    2.2 Stability of Tool Calls

    Tool calling is critical to agent reliability. A complete tool call includes three parts: selecting the correct tool, generating call content that conforms to the parameter schema, and correctly processing the returned result. If any part fails, subsequent steps may deviate from the goal.

    In testing, it is recommended to split tool-call failures into several categories and count them separately:

    • The expected tool was not selected.
    • Parameters do not conform to the schema definition, such as missing required fields or type errors.
    • Key parameters such as paths and identifiers are inconsistent with the task context.
    • The call succeeds, but the model ignores or misreads the returned content.

    Categorized statistics help teams determine whether the problem lies in model capability, tool descriptions, or parameter validation on the system side.

    2.3 Output Speed and Reasoning Overhead

    The speed perceived by users of an agent is mainly determined by two metrics. First-token latency is the time from sending a request to receiving the first output token, and it affects the initial feel of the interaction. Output throughput is the number of tokens generated per second, and it affects the completion time of long answers.

    In addition, some models perform internal reasoning before output, and these reasoning tokens are also counted in output billing and time. The proportion of reasoning tokens in output tokens can help determine how much computation the model invests in complex tasks. If the proportion is too high, simple tasks may become slower due to overthinking; if it is too low, accuracy on complex tasks may be affected. Teams should observe the relationship between this ratio and success rate by task type.

    2.4 Multimodal Input

    Some models support multimodal input such as images. In an agent, this means the model can directly read screenshots, charts, or scanned documents, eliminating an extra recognition step. During testing, the accuracy of multimodal input should be verified separately, and whether the model supports image output should be confirmed. Input capability and output capability are often asymmetric, so the ability to read images does not mean the model can generate them.

    3. Building a Reproducible Testing Method

    The problem with subjective testing is that it has few samples and inconsistent conditions. A reproducible method should include the following elements.

    3.1 Build a Task Set

    The task set should cover typical agent workflows, such as reading configuration files, parsing structured data, comparing two texts, querying logs, and reading images to extract information. Prepare several samples for each task category and record the expected results. The number of samples should be sufficient to support statistical judgment; a few calls on a single task are not enough to draw conclusions.

    The same task should be run multiple times with the same prompt, the same tool definitions, and the same context length to reduce bias caused by randomness.

    3.2 Define Metrics

    The following metrics can be calculated directly from request logs:

    • Cache hit rate = number of cached input tokens / total number of input tokens;
    • Cache reuse ratio = number of cached input tokens / number of uncached input tokens;
    • Reasoning ratio = number of reasoning tokens / number of output tokens;
    • Tool call success rate = number of successful tool calls / number of tool calls initiated;
    • Task completion rate = number of tasks whose final result passes validation / total number of tasks.

    3.3 Example Code

    The following code shows how to aggregate the metrics above from log records. The field names are illustrative only; the actual log structure should follow the team’s instrumentation conventions.

    1. def summarize_runs(records):
    2. total_input = sum(r["input_tokens"] for r in records)
    3. cached_input = sum(r["cached_tokens"] for r in records)
    4. uncached_input = total_input - cached_input
    5. total_output = sum(r["output_tokens"] for r in records)
    6. reasoning = sum(r["reasoning_tokens"] for r in records)
    7. calls = sum(r["tool_calls"] for r in records)
    8. ok_calls = sum(r["tool_calls_ok"] for r in records)
    9. return {
    10. "cache_hit_rate": cached_input / total_input if total_input else 0.0,
    11. "cache_reuse_ratio": cached_input / uncached_input if uncached_input else 0.0,
    12. "reasoning_ratio": reasoning / total_output if total_output else 0.0,
    13. "tool_success_rate": ok_calls / calls if calls else 0.0,
    14. }

    The function guards against empty denominators to avoid division-by-zero errors when the sample size is zero.

    3.4 Control Variables

    The following conditions should be fixed during testing: prompt version, tool descriptions, sampling parameters such as temperature, request concurrency, and network environment. Latency data should use the median and high-percentile values across multiple runs, not the fastest single result.

    4. How to Interpret Test Results

    After obtaining the data, do not compare a single number in isolation. Judge it in the context of task characteristics.

    High cache metrics indicate a stable session prefix, which is suitable for multi-turn agents. However, if the team’s tasks are mostly single-turn question answering, the cache benefit is limited, and the weight of this metric should be reduced.

    Tool call success rate should be examined by category. If failures are concentrated in parameter type errors, the problem may be that the tool schema definition is not clear enough, and improving the tool description is often more effective than switching models. If failures are concentrated in tool selection, check whether the responsibilities and boundaries between tools overlap.

    Latency data needs to distinguish first-token latency from overall completion time. For streaming interactive interfaces, first-token latency determines whether users feel lag; for background batch tasks, throughput and total time are more important.

    There is no absolute good or bad for the reasoning ratio. It needs to be considered together with task success rate. If simple tasks have a high reasoning ratio without improved success rate, the model is consuming resources where reasoning is not needed.

    5. Common Pitfalls

    First, replacing statistics with one or two calls. A small sample is easily affected by chance, especially for latency, where network fluctuations and server load can cause significant differences.

    Second, looking at only a single metric. Fast speed but unstable tool calls can cause the entire task chain to fail, and the time saved may be consumed by retries.

    Third, ignoring prompt structure. Caching, tool calls, and output quality all depend on prompt stability. If the model is changed without checking the prompts at the same time, test results may be distorted.

    Fourth, treating a test version as a long-term dependency. Test versions may go offline at any time, so business code should access models through a unified model invocation layer and place model names in configuration rather than hardcoding them in scattered locations.

    6. Implementation Recommendations

    It is recommended to proceed with evaluation in the following steps:

    1. Identify typical agent tasks in the business, organize them into a task set, and annotate expected results.
    2. Fix test conditions, run each candidate model one by one, and record complete logs.
    3. Use a unified script to calculate each metric and display results grouped by task category.
    4. Set launch thresholds, such as minimum requirements for tool call success rate, task completion rate, and first-token latency.
    5. Keep switchability in the model invocation layer to prepare for future version changes.

    After completing these steps, the team can compare different models using the same standard and quickly retest when models are updated, avoiding reliance on experience-based judgment for every change.