Overview
The Tool Selection evaluator determines whether an LLM selected the most appropriate tool (or tools) for a given task. This evaluator focuses on the what of tool calling - validating that the right tool was chosen - rather than whether the invocation arguments were correct.When to Use
Use the Tool Selection evaluator when you need to:- Validate tool choice decisions - Ensure the LLM picks the most appropriate tool for the task
- Detect hallucinated tools - Identify when the LLM tries to use tools that don’t exist
- Evaluate tool necessity - Check if the LLM correctly determines when tools are (or aren’t) needed
- Assess multi-tool selection - Validate when the LLM needs to select multiple tools for complex tasks
This evaluator validates tool selection correctness, not invocation correctness. For evaluating whether tool arguments are properly formatted, use the Tool Invocation evaluator instead. The two evaluators are complementary — Tool Selection catches wrong-tool errors while Tool Invocation catches malformed-call errors — and are best run together for complete tool-calling coverage.
Supported Levels
The level of an evaluator determines the scope of the evaluation in OpenTelemetry terms. Some evaluations are applicable to individual spans, some to full traces or sessions, and some are applicable at multiple levels.
Relevant span kinds: LLM spans with tool calls, particularly in agentic applications.
Input Requirements
The Tool Selection evaluator requires three inputs:In TypeScript, the fields use camelCase:
availableTools and toolSelection.Formatting Tips
While you can pass full JSON representations for each field, human-readable formats typically produce more accurate evaluations.input (conversation context adapted from input messages):
available_tools (tool descriptions adapted by JSON schemas):
Tool argument descriptions are optional; the focus is on the selection itself so tool names and descriptions are sufficient.
tool_selection (the LLM’s tool selection adapted from tool_calls in the output):
If the LLM did not produce any tool calls, you can put “No tools called” as the
tool_selection input.Output Interpretation
The evaluator returns aScore object with the following properties:
Criteria for Correct (1.0):
- The LLM chose the best available tool for the user query
- The tool name exists in the available tools list
- The tool selection is safe and appropriate
- The correct number of tools were selected for the task
- The LLM used a hallucinated or nonexistent tool
- The LLM selected a tool when none was needed
- The LLM did not use a tool when one was required
- The LLM chose a suboptimal or irrelevant tool
Usage Examples
- Python
- TypeScript
Using Input Mapping
When your data has different field names, use input mapping.- Python
- TypeScript
Configuration
For LLM client configuration options, see Configuring the LLM.Viewing and Modifying the Prompt
You can view the latest versions of our prompt templates on GitHub. The evaluators are designed to work well in a variety of contexts, but we highly recommend modifying the prompt to be more specific to your use case. Feel free to adapt them.- Python
- TypeScript
Using with Phoenix
Evaluating Traces
Run evaluations on traces collected in Phoenix and log results as annotations:Running Experiments
Use the Tool Selection evaluator in Phoenix experiments:API Reference
- Python: ToolSelectionEvaluator
- TypeScript: createToolSelectionEvaluator
Related
- Tool Invocation Evaluator - For evaluating tool invocation correctness
- Correctness Evaluator - For evaluating factual accuracy

