Cost and Latency-Aware Tool-Use Evaluation
Cost and Latency-Aware Tool-Use Evaluation
Most tool-use benchmarks measure one thing: did the agent call the right tool and get the right answer? That is necessary. It is not sufficient. A production agent that solves a task by issuing fourteen sequential API calls, spending forty seconds and four dollars in inference, is not a viable agent. Cost and latency-aware tool-use evaluation captures what accuracy-only metrics miss: the economic and temporal efficiency of the tool-call trajectory, not just its terminal correctness. This post explains how to design, instrument, and score such evaluations so the signal is actionable for post-training and deployment decisions.
Direct answer: Cost and latency-aware tool-use evaluation measures agent performance across three axes simultaneously: task success, total tool-call cost (token spend plus API fees), and end-to-end latency (wall-clock time or sequential step count). A valid eval assigns a score that rewards correct, cheap, fast trajectories and penalises correct but wasteful ones. Difficulty is calibrated empirically per model and per date, because model efficiency improves and optimal trajectories shift.
Why accuracy alone is an incomplete signal for tool-use agents
Accuracy measures whether the agent reached the correct terminal state. It says nothing about the path. Two agents can both return the correct answer to a multi-step data retrieval task: one with two tool calls and 800 input tokens, one with nine tool calls and 6,000 tokens. Accuracy treats them identically. Cost and latency-aware tool-use evaluation treats them as categorically different.
The practical consequence is training signal distortion. If a reward model or verifier scores only correctness, RLVR fine-tuning will reinforce any trajectory that reaches the right answer, including expensive, slow, redundant ones. The agent learns that verbosity and over-calling are acceptable. In deployment, that translates directly to cost overruns and latency violations.
Three axes define a complete tool-use eval:
Task success rate: binary or graded correctness of the final output, verified against a ground-truth or a deterministic checker.
Trajectory cost: total token consumption (input plus output, across all calls) plus any external API fees incurred. Expressed in a common unit, typically USD or a normalised token count.
Trajectory latency: wall-clock seconds for async evaluations, or sequential step count for environments where parallelism is controlled. Both matter; choose the one that maps to your deployment constraint.
How to instrument a cost and latency-aware tool-use evaluation
Instrumentation precedes scoring. Without reliable per-call telemetry, the eval produces noisy or unverifiable numbers.
A minimal instrumentation protocol has five steps:
Wrap every tool call in a logging interceptor that records: tool name, input payload size (tokens), output payload size (tokens), wall-clock start and end timestamps, and any external API cost if the tool calls a priced service.
Assign a task ID to the entire trajectory so all calls are attributable to one evaluation instance.
Record the full call graph, not just the linear sequence. Agents running parallel tool calls must log which calls were concurrent; sequential step count differs from wall-clock time in parallel execution.
Capture the terminal output and the verifier result (pass/fail or graded score) at the end of the trajectory.
Store raw telemetry before aggregation. Aggregated-only logs make failure-mode analysis impossible.
The output of instrumentation is a trajectory record: a structured log of every tool call with its cost and timing, plus the final correctness verdict. Scoring operates on this record.
Scoring frameworks: combining success, cost, and latency into one signal
Three scoring approaches are in common use. Each encodes a different deployment priority.
Approach | Formula sketch | Best when | Risk |
|---|---|---|---|
Threshold gating | Score = accuracy, only if cost < C_max and latency < L_max | Hard SLA exists (e.g., sub-5s response, sub-$0.10 per task) | Binary cliff; no gradient signal for near-threshold trajectories |
Weighted composite | Score = w1 * success + w2 * (1 - norm_cost) + w3 * (1 - norm_latency) | Training signal for RLVR; reward model needs a continuous score | Weight choice is arbitrary without deployment data; must be revisited |
Pareto frontier analysis | Plot (success rate, mean cost) across model variants; identify non-dominated points | Model selection and ablation; comparing fine-tuning checkpoints | Does not produce a single scalar; harder to use as a reward signal |
For post-training reward signals, the weighted composite is the most tractable. Normalise cost and latency against a baseline trajectory (for example, the cheapest known correct solution for that task), so the penalty is relative rather than absolute. This prevents the score from being dominated by task difficulty variation.
Formula for a normalised composite score:
score = success * (1 - alpha * (cost / cost_baseline - 1) - beta * (latency / latency_baseline - 1))
Alpha and beta are hyperparameters encoding the relative importance of cost and latency efficiency. Set them from deployment requirements, not from intuition. An agent serving interactive users weights beta (latency) higher. An agent running overnight batch jobs weights alpha (cost) higher.
Worked example: a three-tool data retrieval task
Illustrative example. Numbers are constructed to demonstrate the scoring method, not drawn from a specific system.
Task: given a company name and a date range, retrieve its revenue figures from a structured database, convert currency using an FX API, and return a formatted summary. Three tools available: db_query, fx_convert, format_output.
Agent A trajectory:
Calls
db_queryonce (1,200 input tokens, 400 output tokens)Calls
fx_convertonce (200 input tokens, 50 output tokens)Calls
format_outputonce (600 input tokens, 300 output tokens)Total cost: 2,750 tokens. Wall-clock: 3.1 seconds. Correct output: yes.
Agent B trajectory:
Calls
db_querythree times with overlapping queries (4,800 input tokens total)Calls
fx_converttwice (400 input tokens total)Calls
format_outputonce (600 input tokens, 300 output tokens)Total cost: 6,100 tokens. Wall-clock: 7.8 seconds. Correct output: yes.
Cost baseline: 2,750 tokens (Agent A is the cheapest correct solution). Latency baseline: 3.1 seconds.
With alpha = 0.3, beta = 0.2:
Agent A: score = 1 * (1 - 0.3 * (2750/2750 - 1) - 0.2 * (3.1/3.1 - 1)) = 1.00
Agent B: score = 1 * (1 - 0.3 * (6100/2750 - 1) - 0.2 * (7.8/3.1 - 1)) = 1 * (1 - 0.3 * 1.218 - 0.2 * 1.516) = 1 * (1 - 0.365 - 0.303) = 0.332
Both agents are correct. The eval correctly distinguishes them. Agent B would be penalised in RLVR training; Agent A's trajectory would be reinforced. The design of the verifier and rubric is central to producing this signal reliably. For a detailed treatment of rubric construction for multi-criteria tasks, see rubric design for evaluation criteria and weights.
Common failure modes in cost and latency-aware tool-use evaluation
1. Baseline trajectory does not exist for every task. If no known correct solution exists, normalisation is undefined. Detection: check for tasks with no human-verified correct trajectory in the dataset. Fix: require at least one expert-authored gold trajectory per task before the task enters the eval set.
2. Cost metric conflates token price and API price. A db_query call and an fx_convert call may have the same token count but different monetary costs if one calls a priced external API. Detection: audit whether the cost metric accounts for per-call fees or only token counts. Fix: define cost in a single unit (USD) and log both token cost and API fee separately before summing.
3. Latency measurement conflates model inference time and tool execution time. Wall-clock latency includes network round-trips, tool execution, and model inference. These have different optimisation levers. Detection: check whether per-call timestamps are recorded at the interceptor layer, not just at the trajectory level. Fix: log start and end timestamps per call at the wrapper, not at the orchestrator.
4. Parallel tool calls are scored as sequential. An agent that issues three concurrent calls may have a sequential step count of one but a wall-clock time equal to the slowest call. Scoring sequential steps as latency misrepresents parallel agents. Detection: compare sequential step count against wall-clock time; large divergence indicates parallelism. Fix: use wall-clock time for latency when the environment permits parallel execution.
5. Alpha and beta weights are set once and never revisited. As models improve, the distribution of trajectory costs shifts. A weight calibrated six months ago may no longer reflect the deployment constraint. Detection: re-run the baseline trajectory computation quarterly and check whether the score distribution has compressed. Fix: treat alpha and beta as versioned hyperparameters, updated whenever the baseline dataset is refreshed. Difficulty drift in evals is a related problem; the same principle applies to QA sampling strategies for high-cost expert tasks.
6. Tasks are too simple to discriminate on cost. If a task has only one valid tool call, all correct agents will have identical cost and latency. The eval collapses to accuracy. Detection: compute the coefficient of variation of trajectory cost across correct solutions; low variation signals insufficient task complexity. Fix: use tasks with at least two valid tool-call strategies that differ in cost, or tasks where the optimal strategy requires deliberate planning. For agent tasks with complex dependencies, see designing tasks with long dependency chains.
Where this approach breaks down
Cost and latency-aware tool-use evaluation assumes tool costs are measurable and stable. In environments where tool execution cost is non-deterministic (for example, a web_search tool with variable result sizes) or where the same task can be routed through tools of different cost tiers, normalisation against a fixed baseline becomes unreliable. The approach also assumes that the correct terminal output is verifiable. For open-ended generation tasks where correctness is graded by an LLM judge rather than a deterministic checker, the verifier's own cost and latency become part of the measurement problem. In those cases, separate the eval into a correctness track (LLM-judged) and an efficiency track (deterministic), and report them independently rather than collapsing into one composite score.
Scores are also model-specific and date-specific. A trajectory that is cost-efficient for one model family may be inefficient for another due to differences in context window pricing and inference speed. Calibrate baselines per model and per evaluation date. For a broader treatment of how synthetic and expert data compare on cost grounds, see cost per useful training token.
FAQ
What is cost and latency-aware tool-use evaluation?
It is an evaluation framework that scores agent trajectories on three axes: task success, total tool-call cost (tokens plus API fees), and end-to-end latency. Accuracy-only evals miss trajectory efficiency. A complete tool-use eval penalises correct but expensive or slow trajectories so that post-training rewards efficient behaviour, not just correct terminal outputs.
How do I set alpha and beta weights for the composite score?
Set them from deployment requirements. Interactive agents serving users with sub-five-second SLAs should weight beta (latency penalty) higher, typically 0.3 to 0.5. Batch agents where cost dominates should weight alpha (cost penalty) higher. Treat both as versioned hyperparameters and recalibrate when deployment constraints change or when the baseline trajectory distribution shifts.
What counts as a valid baseline trajectory?
A baseline trajectory is the cheapest known correct solution for a given task, authored or verified by a domain expert before the task enters the eval set. It sets the normalisation floor for cost and latency scoring. Tasks without a verified baseline trajectory cannot be reliably scored on efficiency and should be excluded from the efficiency track until a baseline exists.
Can this scoring approach be used as a reward signal in RLVR training?
Yes. The weighted composite score is continuous and differentiable with respect to trajectory choices, making it suitable as a reward signal. The key requirement is that the verifier for task success is deterministic or near-deterministic. If correctness is judged by an LLM, reward hacking risk increases: the agent may learn to game the judge rather than solve the task efficiently. Use programmatic verifiers wherever the task permits.
How does trajectory cost differ from inference cost?
Inference cost is the token cost of one model forward pass. Trajectory cost is the sum of all inference costs and external API fees across every tool call in a complete agent run. A single task may involve ten model calls and five external API calls. Trajectory cost is the operationally relevant metric for deployment budgeting; inference cost per call is useful for diagnosing where within the trajectory the cost is concentrated.
How often should baseline trajectories be refreshed?
At minimum, whenever a new model family enters the evaluation scope, and at least quarterly for active post-training pipelines. Model improvements compress the cost distribution of correct trajectories over time. A baseline that was tight six months ago may now be easily beaten, which reduces the discriminative power of the efficiency penalty. Treat baseline refresh as a scheduled maintenance task, not a one-time setup. The same principle applies to step-level annotation costs discussed in cost of step-level labels per annotated trajectory.
What this means in practice
Accuracy-only tool-use evals are a ceiling, not a floor. They tell you whether an agent can solve a task. They do not tell you whether it can solve it at a cost and speed that makes deployment viable. Cost and latency-aware tool-use evaluation closes that gap by instrumenting trajectories, normalising against expert-verified baselines, and producing a composite score that rewards efficiency alongside correctness. The framework is not complex. The discipline required to maintain it, refreshing baselines, versioning weights, auditing verifiers, is where most in-house eval programs fall short.
If you are building evals or RL environments that require expert-authored, difficulty-calibrated tool-use tasks, get in touch with Chiron Datalabs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.
Most tool-use benchmarks measure one thing: did the agent call the right tool and get the right answer? That is necessary. It is not sufficient. A production agent that solves a task by issuing fourteen sequential API calls, spending forty seconds and four dollars in inference, is not a viable agent. Cost and latency-aware tool-use evaluation captures what accuracy-only metrics miss: the economic and temporal efficiency of the tool-call trajectory, not just its terminal correctness. This post explains how to design, instrument, and score such evaluations so the signal is actionable for post-training and deployment decisions.
Direct answer: Cost and latency-aware tool-use evaluation measures agent performance across three axes simultaneously: task success, total tool-call cost (token spend plus API fees), and end-to-end latency (wall-clock time or sequential step count). A valid eval assigns a score that rewards correct, cheap, fast trajectories and penalises correct but wasteful ones. Difficulty is calibrated empirically per model and per date, because model efficiency improves and optimal trajectories shift.
Why accuracy alone is an incomplete signal for tool-use agents
Accuracy measures whether the agent reached the correct terminal state. It says nothing about the path. Two agents can both return the correct answer to a multi-step data retrieval task: one with two tool calls and 800 input tokens, one with nine tool calls and 6,000 tokens. Accuracy treats them identically. Cost and latency-aware tool-use evaluation treats them as categorically different.
The practical consequence is training signal distortion. If a reward model or verifier scores only correctness, RLVR fine-tuning will reinforce any trajectory that reaches the right answer, including expensive, slow, redundant ones. The agent learns that verbosity and over-calling are acceptable. In deployment, that translates directly to cost overruns and latency violations.
Three axes define a complete tool-use eval:
Task success rate: binary or graded correctness of the final output, verified against a ground-truth or a deterministic checker.
Trajectory cost: total token consumption (input plus output, across all calls) plus any external API fees incurred. Expressed in a common unit, typically USD or a normalised token count.
Trajectory latency: wall-clock seconds for async evaluations, or sequential step count for environments where parallelism is controlled. Both matter; choose the one that maps to your deployment constraint.
How to instrument a cost and latency-aware tool-use evaluation
Instrumentation precedes scoring. Without reliable per-call telemetry, the eval produces noisy or unverifiable numbers.
A minimal instrumentation protocol has five steps:
Wrap every tool call in a logging interceptor that records: tool name, input payload size (tokens), output payload size (tokens), wall-clock start and end timestamps, and any external API cost if the tool calls a priced service.
Assign a task ID to the entire trajectory so all calls are attributable to one evaluation instance.
Record the full call graph, not just the linear sequence. Agents running parallel tool calls must log which calls were concurrent; sequential step count differs from wall-clock time in parallel execution.
Capture the terminal output and the verifier result (pass/fail or graded score) at the end of the trajectory.
Store raw telemetry before aggregation. Aggregated-only logs make failure-mode analysis impossible.
The output of instrumentation is a trajectory record: a structured log of every tool call with its cost and timing, plus the final correctness verdict. Scoring operates on this record.
Scoring frameworks: combining success, cost, and latency into one signal
Three scoring approaches are in common use. Each encodes a different deployment priority.
Approach | Formula sketch | Best when | Risk |
|---|---|---|---|
Threshold gating | Score = accuracy, only if cost < C_max and latency < L_max | Hard SLA exists (e.g., sub-5s response, sub-$0.10 per task) | Binary cliff; no gradient signal for near-threshold trajectories |
Weighted composite | Score = w1 * success + w2 * (1 - norm_cost) + w3 * (1 - norm_latency) | Training signal for RLVR; reward model needs a continuous score | Weight choice is arbitrary without deployment data; must be revisited |
Pareto frontier analysis | Plot (success rate, mean cost) across model variants; identify non-dominated points | Model selection and ablation; comparing fine-tuning checkpoints | Does not produce a single scalar; harder to use as a reward signal |
For post-training reward signals, the weighted composite is the most tractable. Normalise cost and latency against a baseline trajectory (for example, the cheapest known correct solution for that task), so the penalty is relative rather than absolute. This prevents the score from being dominated by task difficulty variation.
Formula for a normalised composite score:
score = success * (1 - alpha * (cost / cost_baseline - 1) - beta * (latency / latency_baseline - 1))
Alpha and beta are hyperparameters encoding the relative importance of cost and latency efficiency. Set them from deployment requirements, not from intuition. An agent serving interactive users weights beta (latency) higher. An agent running overnight batch jobs weights alpha (cost) higher.
Worked example: a three-tool data retrieval task
Illustrative example. Numbers are constructed to demonstrate the scoring method, not drawn from a specific system.
Task: given a company name and a date range, retrieve its revenue figures from a structured database, convert currency using an FX API, and return a formatted summary. Three tools available: db_query, fx_convert, format_output.
Agent A trajectory:
Calls
db_queryonce (1,200 input tokens, 400 output tokens)Calls
fx_convertonce (200 input tokens, 50 output tokens)Calls
format_outputonce (600 input tokens, 300 output tokens)Total cost: 2,750 tokens. Wall-clock: 3.1 seconds. Correct output: yes.
Agent B trajectory:
Calls
db_querythree times with overlapping queries (4,800 input tokens total)Calls
fx_converttwice (400 input tokens total)Calls
format_outputonce (600 input tokens, 300 output tokens)Total cost: 6,100 tokens. Wall-clock: 7.8 seconds. Correct output: yes.
Cost baseline: 2,750 tokens (Agent A is the cheapest correct solution). Latency baseline: 3.1 seconds.
With alpha = 0.3, beta = 0.2:
Agent A: score = 1 * (1 - 0.3 * (2750/2750 - 1) - 0.2 * (3.1/3.1 - 1)) = 1.00
Agent B: score = 1 * (1 - 0.3 * (6100/2750 - 1) - 0.2 * (7.8/3.1 - 1)) = 1 * (1 - 0.3 * 1.218 - 0.2 * 1.516) = 1 * (1 - 0.365 - 0.303) = 0.332
Both agents are correct. The eval correctly distinguishes them. Agent B would be penalised in RLVR training; Agent A's trajectory would be reinforced. The design of the verifier and rubric is central to producing this signal reliably. For a detailed treatment of rubric construction for multi-criteria tasks, see rubric design for evaluation criteria and weights.
Common failure modes in cost and latency-aware tool-use evaluation
1. Baseline trajectory does not exist for every task. If no known correct solution exists, normalisation is undefined. Detection: check for tasks with no human-verified correct trajectory in the dataset. Fix: require at least one expert-authored gold trajectory per task before the task enters the eval set.
2. Cost metric conflates token price and API price. A db_query call and an fx_convert call may have the same token count but different monetary costs if one calls a priced external API. Detection: audit whether the cost metric accounts for per-call fees or only token counts. Fix: define cost in a single unit (USD) and log both token cost and API fee separately before summing.
3. Latency measurement conflates model inference time and tool execution time. Wall-clock latency includes network round-trips, tool execution, and model inference. These have different optimisation levers. Detection: check whether per-call timestamps are recorded at the interceptor layer, not just at the trajectory level. Fix: log start and end timestamps per call at the wrapper, not at the orchestrator.
4. Parallel tool calls are scored as sequential. An agent that issues three concurrent calls may have a sequential step count of one but a wall-clock time equal to the slowest call. Scoring sequential steps as latency misrepresents parallel agents. Detection: compare sequential step count against wall-clock time; large divergence indicates parallelism. Fix: use wall-clock time for latency when the environment permits parallel execution.
5. Alpha and beta weights are set once and never revisited. As models improve, the distribution of trajectory costs shifts. A weight calibrated six months ago may no longer reflect the deployment constraint. Detection: re-run the baseline trajectory computation quarterly and check whether the score distribution has compressed. Fix: treat alpha and beta as versioned hyperparameters, updated whenever the baseline dataset is refreshed. Difficulty drift in evals is a related problem; the same principle applies to QA sampling strategies for high-cost expert tasks.
6. Tasks are too simple to discriminate on cost. If a task has only one valid tool call, all correct agents will have identical cost and latency. The eval collapses to accuracy. Detection: compute the coefficient of variation of trajectory cost across correct solutions; low variation signals insufficient task complexity. Fix: use tasks with at least two valid tool-call strategies that differ in cost, or tasks where the optimal strategy requires deliberate planning. For agent tasks with complex dependencies, see designing tasks with long dependency chains.
Where this approach breaks down
Cost and latency-aware tool-use evaluation assumes tool costs are measurable and stable. In environments where tool execution cost is non-deterministic (for example, a web_search tool with variable result sizes) or where the same task can be routed through tools of different cost tiers, normalisation against a fixed baseline becomes unreliable. The approach also assumes that the correct terminal output is verifiable. For open-ended generation tasks where correctness is graded by an LLM judge rather than a deterministic checker, the verifier's own cost and latency become part of the measurement problem. In those cases, separate the eval into a correctness track (LLM-judged) and an efficiency track (deterministic), and report them independently rather than collapsing into one composite score.
Scores are also model-specific and date-specific. A trajectory that is cost-efficient for one model family may be inefficient for another due to differences in context window pricing and inference speed. Calibrate baselines per model and per evaluation date. For a broader treatment of how synthetic and expert data compare on cost grounds, see cost per useful training token.
FAQ
What is cost and latency-aware tool-use evaluation?
It is an evaluation framework that scores agent trajectories on three axes: task success, total tool-call cost (tokens plus API fees), and end-to-end latency. Accuracy-only evals miss trajectory efficiency. A complete tool-use eval penalises correct but expensive or slow trajectories so that post-training rewards efficient behaviour, not just correct terminal outputs.
How do I set alpha and beta weights for the composite score?
Set them from deployment requirements. Interactive agents serving users with sub-five-second SLAs should weight beta (latency penalty) higher, typically 0.3 to 0.5. Batch agents where cost dominates should weight alpha (cost penalty) higher. Treat both as versioned hyperparameters and recalibrate when deployment constraints change or when the baseline trajectory distribution shifts.
What counts as a valid baseline trajectory?
A baseline trajectory is the cheapest known correct solution for a given task, authored or verified by a domain expert before the task enters the eval set. It sets the normalisation floor for cost and latency scoring. Tasks without a verified baseline trajectory cannot be reliably scored on efficiency and should be excluded from the efficiency track until a baseline exists.
Can this scoring approach be used as a reward signal in RLVR training?
Yes. The weighted composite score is continuous and differentiable with respect to trajectory choices, making it suitable as a reward signal. The key requirement is that the verifier for task success is deterministic or near-deterministic. If correctness is judged by an LLM, reward hacking risk increases: the agent may learn to game the judge rather than solve the task efficiently. Use programmatic verifiers wherever the task permits.
How does trajectory cost differ from inference cost?
Inference cost is the token cost of one model forward pass. Trajectory cost is the sum of all inference costs and external API fees across every tool call in a complete agent run. A single task may involve ten model calls and five external API calls. Trajectory cost is the operationally relevant metric for deployment budgeting; inference cost per call is useful for diagnosing where within the trajectory the cost is concentrated.
How often should baseline trajectories be refreshed?
At minimum, whenever a new model family enters the evaluation scope, and at least quarterly for active post-training pipelines. Model improvements compress the cost distribution of correct trajectories over time. A baseline that was tight six months ago may now be easily beaten, which reduces the discriminative power of the efficiency penalty. Treat baseline refresh as a scheduled maintenance task, not a one-time setup. The same principle applies to step-level annotation costs discussed in cost of step-level labels per annotated trajectory.
What this means in practice
Accuracy-only tool-use evals are a ceiling, not a floor. They tell you whether an agent can solve a task. They do not tell you whether it can solve it at a cost and speed that makes deployment viable. Cost and latency-aware tool-use evaluation closes that gap by instrumenting trajectories, normalising against expert-verified baselines, and producing a composite score that rewards efficiency alongside correctness. The framework is not complex. The discipline required to maintain it, refreshing baselines, versioning weights, auditing verifiers, is where most in-house eval programs fall short.
If you are building evals or RL environments that require expert-authored, difficulty-calibrated tool-use tasks, get in touch with Chiron Datalabs.
Have questions or want personalised guidance? Contact us and we'll be happy to help.