Tool-Use Hallucination Detection and Measurement

Tool-Use Hallucination Detection and Measurement

When a language model calls a tool, it makes a claim about the world: that this function exists, accepts these arguments, and will return something meaningful. Tool-use hallucination is the failure of that claim. The model invokes a nonexistent endpoint, passes a malformed argument, fabricates a return value, or chains tool calls in a sequence that cannot succeed. For post-training researchers and evals engineers, detecting and measuring these failures precisely is the prerequisite for fixing them. This post provides a working taxonomy, a measurement protocol, and the failure modes that most evaluation designs miss.

Answer Capsule

Tool-use hallucination detection requires categorising failures across four dimensions: tool existence, argument validity, return-value fabrication, and call-chain coherence. Measurement uses programmatic verifiers against a ground-truth tool schema, pass@k over sampled trajectories, and expert rubrics for semantic correctness. No single metric suffices; a composite score across all four dimensions is the minimum credible signal.

What Is Tool-Use Hallucination?

Tool-use hallucination is not a single failure mode. It is a family of four distinct error types, each requiring a different verifier.

  • Existence hallucination: The model calls a tool that does not exist in the provided schema. For example, calling get_stock_price() when the available tools include only search_web() and read_file().

  • Argument hallucination: The tool exists but the model passes arguments with wrong names, wrong types, or values outside the declared range. A date field receives a string that is not ISO 8601. A required field is omitted.

  • Return-value fabrication: The model generates a plausible-looking tool result without actually invoking the tool, then reasons from that fabricated result. This is the hardest failure to detect without execution infrastructure.

  • Chain-coherence hallucination: Each individual call is syntactically valid, but the sequence is logically impossible. The model reads a file before creating it, or passes the output of step three into step one.

These categories are not mutually exclusive. A single trajectory can contain all four. A measurement protocol that collapses them into one accuracy score loses the diagnostic signal needed for targeted post-training.

How to Measure Tool-Use Hallucination: A Four-Layer Protocol

A credible measurement protocol operates at four layers, each catching failures the layer above it misses.

Layer 1: Schema Validation

Parse every tool call in the trajectory against the declared tool schema. This is fully programmatic. A JSON Schema validator or equivalent catches existence and argument-type errors with zero ambiguity. The output is a binary pass or fail per call, plus a structured error log.

Layer 2: Execution Verification

Run the tool calls in a sandboxed environment and compare actual return values to model-stated return values. This is the only reliable method for detecting return-value fabrication. If execution infrastructure is unavailable, a human expert must review the trajectory and flag any result the model treats as received but that could not have been returned given the inputs.

Layer 3: Chain-Coherence Scoring

Build a dependency graph of the trajectory: which call outputs feed which call inputs. Score coherence as the fraction of input dependencies that are satisfiable given the execution order. A fully coherent trajectory scores 1.0. A trajectory where step two reads a variable that step three would have written scores below 1.0 in proportion to the number of broken dependencies.

Layer 4: Semantic Correctness

Schema validity and execution success do not guarantee that the model used the right tool for the task. A model that calls search_web(query="capital of France") when the task required reading a local configuration file has passed layers one and two but failed the task. Expert rubrics, scored by a domain practitioner or a calibrated LLM-as-judge, are required here. The rubric must specify what correct tool selection looks like for each task class, not just whether calls were syntactically valid.

Measurement Formula: Pass@k for Tool-Use Trajectories

Pass@k, as defined in the Codex paper (Chen et al., 2021), estimates the probability that at least one of k sampled completions is correct. For tool-use evaluation, the formula applies at the trajectory level rather than the token level.

For a task with n sampled trajectories, c of which are fully correct across all four layers:

pass@k = 1 - C(n-c, k) / C(n, k)

where C denotes the binomial coefficient. This estimator is unbiased when n is large relative to k. A practical minimum is n = 20 trajectories per task, with k reported at 1, 5, and 10 to show the distribution of model reliability rather than a single point estimate.

Report pass@k separately for each failure layer. A model with high pass@1 on schema validation but low pass@1 on chain coherence has a different post-training problem than a model with the inverse profile.

Worked Example: A File-Management Agent Task

Illustrative example. Numbers are constructed to demonstrate the measurement protocol, not drawn from a specific model evaluation.

Task: Given a directory listing and a configuration file, rename all files whose names begin with tmp_ to include today's date suffix, then update the configuration file to reflect the new names.

Available tools: list_directory(path), rename_file(old_path, new_path), read_file(path), write_file(path, content), get_current_date().

A model produces the following trajectory across 20 sampled runs:

  • Layer 1 (schema validation): 18 of 20 trajectories pass. Two calls invoke get_date() instead of get_current_date().

  • Layer 2 (execution verification): Of the 18 schema-valid trajectories, 14 produce correct file renames. Four fabricate the return value of list_directory(), inventing file names not present in the directory.

  • Layer 3 (chain coherence): Of the 14 execution-correct trajectories, 12 are fully coherent. Two attempt to rename files before listing the directory.

  • Layer 4 (semantic correctness): Of the 12 coherent trajectories, 10 correctly update the configuration file. Two update only the first matching entry.

Pass@1 estimates: schema 0.90, execution 0.70, coherence 0.60, semantic 0.50. The model's primary failure is return-value fabrication, not argument errors. That diagnosis points toward process-supervised training data that penalises ungrounded result claims, not toward schema-format fine-tuning.

Common Failure Modes in Tool-Use Hallucination Measurement

1. Conflating syntactic and semantic correctness

Detection: Pass rates are high on schema validation but task completion rates are low. Fix: Add a semantic correctness layer with expert-authored rubrics. Schema validity is a necessary but not sufficient condition for task success.

2. Evaluating only the final state, not the trajectory

Detection: The eval checks whether the final output is correct but ignores intermediate tool calls. A model that reaches the right answer by fabricating intermediate results will appear to pass. Fix: Log and score every tool call in the trajectory, not just the terminal state.

3. Using a static tool schema across evaluation dates

Detection: Pass rates drift upward without any model update. The model has likely seen the schema or similar schemas in training. Fix: Rotate tool names, argument names, and schema structure periodically. Difficulty is calibrated per model and per date; a schema that challenged a model six months ago may not challenge its successor. This is the same contamination pressure that affects all static evals, and the same logic behind paraphrase perturbation tests for memorization detection.

4. Insufficient sample size for pass@k

Detection: Pass@1 variance is high across repeated measurement runs on the same task set. Fix: Use the unbiased estimator with n >= 20 per task, and report confidence intervals. A single greedy decode is not a measurement; it is an anecdote.

5. No verifier for return-value fabrication

Detection: The eval has no execution sandbox and no human review step for intermediate results. Return-value fabrication is invisible to schema validators. Fix: Either instrument execution infrastructure or include an expert reviewer step that explicitly checks whether each model-stated tool result is consistent with what the tool could have returned given the inputs.

6. Tasks that are too simple to reveal chain-coherence failures

Detection: All trajectories pass coherence scoring because every task requires only one or two tool calls. Fix: Include multi-step tasks with at least four tool calls and at least two dependency edges in the correct trajectory. Single-call tasks do not stress-test planning or sequencing.

Where This Approach Breaks Down

Programmatic verifiers require a fully specified tool schema with deterministic expected outputs. Many real-world agentic tasks involve tools whose outputs are stochastic, external, or time-dependent. In those cases, execution verification is not reproducible, and the measurement protocol must fall back to expert rubrics for layers two and three, accepting higher inter-rater variance.

Pass@k assumes independent samples. If the model's trajectory distribution is strongly peaked (it almost always makes the same sequence of calls), k samples add little information. Report the entropy of the trajectory distribution alongside pass@k to flag this condition.

Semantic correctness rubrics are only as reliable as the experts who write them. Rubric drift, where a rubric that was correct at authoring time becomes ambiguous as the task class evolves, is a real operational cost. Rubrics require versioning and periodic recalibration, not one-time authoring. The same challenge applies to verifiable legal evals, where the ground truth itself changes as case law develops.

Frequently Asked Questions

What is the difference between tool-use hallucination and standard LLM hallucination?

Standard hallucination refers to a model generating false factual claims in prose. Tool-use hallucination refers specifically to failures in structured function-calling behaviour: invoking nonexistent tools, passing invalid arguments, fabricating return values, or sequencing calls incoherently. The failure modes are distinct and require different verifiers. Schema validators catch argument errors; they do not catch fabricated prose facts.

Can LLM-as-judge reliably score tool-use trajectories?

LLM-as-judge is adequate for semantic correctness scoring on well-defined rubrics, provided the judge model is different from the model under evaluation and the rubric is explicit. It is not adequate for schema validation (use a parser) or execution verification (use a sandbox). Agreement between LLM-as-judge and expert human reviewers should be measured and reported; assume it will be imperfect on novel task types.

How many tasks are needed for a reliable tool-use eval?

The minimum depends on the variance of the metric and the effect size you need to detect. For pass@1 with a target standard error below 0.05, a rough lower bound is 100 tasks with n = 20 samples each, assuming moderate task-level variance. Fewer tasks are acceptable for diagnostic purposes but not for model comparison or release decisions. Stratify tasks by tool count and dependency depth to ensure coverage of the failure space.

Does synthetic data work for tool-use post-training?

Synthetic trajectories generated from a fixed schema can cover argument-format failures efficiently. They are poor at covering return-value fabrication and chain-coherence failures, because the generator must itself plan correctly to produce correct trajectories, and incorrect trajectories must be deliberately authored rather than sampled. Expert-authored tasks, where a practitioner designs the tool schema, the correct trajectory, and the plausible failure trajectories, provide higher signal density for the failure modes that matter most.

How do you prevent schema memorization from inflating pass rates?

Rotate tool names, argument names, and schema structure across evaluation versions. Use paraphrase perturbation: vary the phrasing of the task description while holding the correct trajectory constant, then check whether pass@k drops. A large drop on paraphrase suggests the model is pattern-matching to surface form rather than reasoning about the tool schema. Treat pass rates on any static schema as an upper bound on true capability, not a point estimate.

What This Means in Practice

Tool-use hallucination is not one problem. It is four problems with four different verifiers and four different post-training implications. A measurement protocol that collapses them into a single accuracy number will misdiagnose the model and misdirect the training intervention. The four-layer protocol described here, schema validation, execution verification, chain-coherence scoring, and semantic correctness, is the minimum structure for a credible eval. Apply pass@k at the trajectory level, report it per layer, and rotate schemas to control for memorization. The diagnostic value is in the layer-by-layer profile, not the aggregate.

If you are building tool-use evals or RL environments that require expert-authored, verifiable task trajectories across engineering, manufacturing, or technical domains, talk to Chiron Datalabs about expert-authored tasks for your domain.

Have questions or want personalised guidance? Contact us and we'll be happy to help.

When a language model calls a tool, it makes a claim about the world: that this function exists, accepts these arguments, and will return something meaningful. Tool-use hallucination is the failure of that claim. The model invokes a nonexistent endpoint, passes a malformed argument, fabricates a return value, or chains tool calls in a sequence that cannot succeed. For post-training researchers and evals engineers, detecting and measuring these failures precisely is the prerequisite for fixing them. This post provides a working taxonomy, a measurement protocol, and the failure modes that most evaluation designs miss.

Answer Capsule

Tool-use hallucination detection requires categorising failures across four dimensions: tool existence, argument validity, return-value fabrication, and call-chain coherence. Measurement uses programmatic verifiers against a ground-truth tool schema, pass@k over sampled trajectories, and expert rubrics for semantic correctness. No single metric suffices; a composite score across all four dimensions is the minimum credible signal.

What Is Tool-Use Hallucination?

Tool-use hallucination is not a single failure mode. It is a family of four distinct error types, each requiring a different verifier.

  • Existence hallucination: The model calls a tool that does not exist in the provided schema. For example, calling get_stock_price() when the available tools include only search_web() and read_file().

  • Argument hallucination: The tool exists but the model passes arguments with wrong names, wrong types, or values outside the declared range. A date field receives a string that is not ISO 8601. A required field is omitted.

  • Return-value fabrication: The model generates a plausible-looking tool result without actually invoking the tool, then reasons from that fabricated result. This is the hardest failure to detect without execution infrastructure.

  • Chain-coherence hallucination: Each individual call is syntactically valid, but the sequence is logically impossible. The model reads a file before creating it, or passes the output of step three into step one.

These categories are not mutually exclusive. A single trajectory can contain all four. A measurement protocol that collapses them into one accuracy score loses the diagnostic signal needed for targeted post-training.

How to Measure Tool-Use Hallucination: A Four-Layer Protocol

A credible measurement protocol operates at four layers, each catching failures the layer above it misses.

Layer 1: Schema Validation

Parse every tool call in the trajectory against the declared tool schema. This is fully programmatic. A JSON Schema validator or equivalent catches existence and argument-type errors with zero ambiguity. The output is a binary pass or fail per call, plus a structured error log.

Layer 2: Execution Verification

Run the tool calls in a sandboxed environment and compare actual return values to model-stated return values. This is the only reliable method for detecting return-value fabrication. If execution infrastructure is unavailable, a human expert must review the trajectory and flag any result the model treats as received but that could not have been returned given the inputs.

Layer 3: Chain-Coherence Scoring

Build a dependency graph of the trajectory: which call outputs feed which call inputs. Score coherence as the fraction of input dependencies that are satisfiable given the execution order. A fully coherent trajectory scores 1.0. A trajectory where step two reads a variable that step three would have written scores below 1.0 in proportion to the number of broken dependencies.

Layer 4: Semantic Correctness

Schema validity and execution success do not guarantee that the model used the right tool for the task. A model that calls search_web(query="capital of France") when the task required reading a local configuration file has passed layers one and two but failed the task. Expert rubrics, scored by a domain practitioner or a calibrated LLM-as-judge, are required here. The rubric must specify what correct tool selection looks like for each task class, not just whether calls were syntactically valid.

Measurement Formula: Pass@k for Tool-Use Trajectories

Pass@k, as defined in the Codex paper (Chen et al., 2021), estimates the probability that at least one of k sampled completions is correct. For tool-use evaluation, the formula applies at the trajectory level rather than the token level.

For a task with n sampled trajectories, c of which are fully correct across all four layers:

pass@k = 1 - C(n-c, k) / C(n, k)

where C denotes the binomial coefficient. This estimator is unbiased when n is large relative to k. A practical minimum is n = 20 trajectories per task, with k reported at 1, 5, and 10 to show the distribution of model reliability rather than a single point estimate.

Report pass@k separately for each failure layer. A model with high pass@1 on schema validation but low pass@1 on chain coherence has a different post-training problem than a model with the inverse profile.

Worked Example: A File-Management Agent Task

Illustrative example. Numbers are constructed to demonstrate the measurement protocol, not drawn from a specific model evaluation.

Task: Given a directory listing and a configuration file, rename all files whose names begin with tmp_ to include today's date suffix, then update the configuration file to reflect the new names.

Available tools: list_directory(path), rename_file(old_path, new_path), read_file(path), write_file(path, content), get_current_date().

A model produces the following trajectory across 20 sampled runs:

  • Layer 1 (schema validation): 18 of 20 trajectories pass. Two calls invoke get_date() instead of get_current_date().

  • Layer 2 (execution verification): Of the 18 schema-valid trajectories, 14 produce correct file renames. Four fabricate the return value of list_directory(), inventing file names not present in the directory.

  • Layer 3 (chain coherence): Of the 14 execution-correct trajectories, 12 are fully coherent. Two attempt to rename files before listing the directory.

  • Layer 4 (semantic correctness): Of the 12 coherent trajectories, 10 correctly update the configuration file. Two update only the first matching entry.

Pass@1 estimates: schema 0.90, execution 0.70, coherence 0.60, semantic 0.50. The model's primary failure is return-value fabrication, not argument errors. That diagnosis points toward process-supervised training data that penalises ungrounded result claims, not toward schema-format fine-tuning.

Common Failure Modes in Tool-Use Hallucination Measurement

1. Conflating syntactic and semantic correctness

Detection: Pass rates are high on schema validation but task completion rates are low. Fix: Add a semantic correctness layer with expert-authored rubrics. Schema validity is a necessary but not sufficient condition for task success.

2. Evaluating only the final state, not the trajectory

Detection: The eval checks whether the final output is correct but ignores intermediate tool calls. A model that reaches the right answer by fabricating intermediate results will appear to pass. Fix: Log and score every tool call in the trajectory, not just the terminal state.

3. Using a static tool schema across evaluation dates

Detection: Pass rates drift upward without any model update. The model has likely seen the schema or similar schemas in training. Fix: Rotate tool names, argument names, and schema structure periodically. Difficulty is calibrated per model and per date; a schema that challenged a model six months ago may not challenge its successor. This is the same contamination pressure that affects all static evals, and the same logic behind paraphrase perturbation tests for memorization detection.

4. Insufficient sample size for pass@k

Detection: Pass@1 variance is high across repeated measurement runs on the same task set. Fix: Use the unbiased estimator with n >= 20 per task, and report confidence intervals. A single greedy decode is not a measurement; it is an anecdote.

5. No verifier for return-value fabrication

Detection: The eval has no execution sandbox and no human review step for intermediate results. Return-value fabrication is invisible to schema validators. Fix: Either instrument execution infrastructure or include an expert reviewer step that explicitly checks whether each model-stated tool result is consistent with what the tool could have returned given the inputs.

6. Tasks that are too simple to reveal chain-coherence failures

Detection: All trajectories pass coherence scoring because every task requires only one or two tool calls. Fix: Include multi-step tasks with at least four tool calls and at least two dependency edges in the correct trajectory. Single-call tasks do not stress-test planning or sequencing.

Where This Approach Breaks Down

Programmatic verifiers require a fully specified tool schema with deterministic expected outputs. Many real-world agentic tasks involve tools whose outputs are stochastic, external, or time-dependent. In those cases, execution verification is not reproducible, and the measurement protocol must fall back to expert rubrics for layers two and three, accepting higher inter-rater variance.

Pass@k assumes independent samples. If the model's trajectory distribution is strongly peaked (it almost always makes the same sequence of calls), k samples add little information. Report the entropy of the trajectory distribution alongside pass@k to flag this condition.

Semantic correctness rubrics are only as reliable as the experts who write them. Rubric drift, where a rubric that was correct at authoring time becomes ambiguous as the task class evolves, is a real operational cost. Rubrics require versioning and periodic recalibration, not one-time authoring. The same challenge applies to verifiable legal evals, where the ground truth itself changes as case law develops.

Frequently Asked Questions

What is the difference between tool-use hallucination and standard LLM hallucination?

Standard hallucination refers to a model generating false factual claims in prose. Tool-use hallucination refers specifically to failures in structured function-calling behaviour: invoking nonexistent tools, passing invalid arguments, fabricating return values, or sequencing calls incoherently. The failure modes are distinct and require different verifiers. Schema validators catch argument errors; they do not catch fabricated prose facts.

Can LLM-as-judge reliably score tool-use trajectories?

LLM-as-judge is adequate for semantic correctness scoring on well-defined rubrics, provided the judge model is different from the model under evaluation and the rubric is explicit. It is not adequate for schema validation (use a parser) or execution verification (use a sandbox). Agreement between LLM-as-judge and expert human reviewers should be measured and reported; assume it will be imperfect on novel task types.

How many tasks are needed for a reliable tool-use eval?

The minimum depends on the variance of the metric and the effect size you need to detect. For pass@1 with a target standard error below 0.05, a rough lower bound is 100 tasks with n = 20 samples each, assuming moderate task-level variance. Fewer tasks are acceptable for diagnostic purposes but not for model comparison or release decisions. Stratify tasks by tool count and dependency depth to ensure coverage of the failure space.

Does synthetic data work for tool-use post-training?

Synthetic trajectories generated from a fixed schema can cover argument-format failures efficiently. They are poor at covering return-value fabrication and chain-coherence failures, because the generator must itself plan correctly to produce correct trajectories, and incorrect trajectories must be deliberately authored rather than sampled. Expert-authored tasks, where a practitioner designs the tool schema, the correct trajectory, and the plausible failure trajectories, provide higher signal density for the failure modes that matter most.

How do you prevent schema memorization from inflating pass rates?

Rotate tool names, argument names, and schema structure across evaluation versions. Use paraphrase perturbation: vary the phrasing of the task description while holding the correct trajectory constant, then check whether pass@k drops. A large drop on paraphrase suggests the model is pattern-matching to surface form rather than reasoning about the tool schema. Treat pass rates on any static schema as an upper bound on true capability, not a point estimate.

What This Means in Practice

Tool-use hallucination is not one problem. It is four problems with four different verifiers and four different post-training implications. A measurement protocol that collapses them into a single accuracy number will misdiagnose the model and misdirect the training intervention. The four-layer protocol described here, schema validation, execution verification, chain-coherence scoring, and semantic correctness, is the minimum structure for a credible eval. Apply pass@k at the trajectory level, report it per layer, and rotate schemas to control for memorization. The diagnostic value is in the layer-by-layer profile, not the aggregate.

If you are building tool-use evals or RL environments that require expert-authored, verifiable task trajectories across engineering, manufacturing, or technical domains, talk to Chiron Datalabs about expert-authored tasks for your domain.

Have questions or want personalised guidance? Contact us and we'll be happy to help.

© 2026 CHIRON, SAN FRANCISCO, CA