This prompt is designed for agent platform teams and evaluation engineers who need to measure how accurately a model selects tools from a defined catalog. The job-to-be-done is regression testing: you have a golden dataset of inputs paired with correct tool choices, and you need to compute precision, recall, and confusion matrices across tool categories. Use this when your tool catalog has changed, your system prompt has been updated, or you're comparing model versions and need quantitative evidence that tool selection behavior hasn't degraded. The prompt expects a batch of test cases, each containing a user input, the available tool definitions, and the ground-truth tool name that should have been selected.
Prompt
Tool Selection Precision and Recall Evaluation Prompt

When to Use This Prompt
Understand the job, the reader, and the constraints before deploying the Tool Selection Precision and Recall Evaluation Prompt.
Do not use this prompt when you need to evaluate argument accuracy, call sequencing, or whether the model should have abstained. Those are separate evaluation surfaces covered by sibling prompts in this pillar. This prompt also assumes you already have a golden dataset with authoritative labels—if you're still building that dataset or need human annotators to establish ground truth, start there first. The prompt produces aggregate metrics, not per-case debugging traces; if you need to diagnose why a specific tool selection failed, pair this with the Tool Selection Justification Trace Evaluation Prompt or the Tool Use Error Categorization prompt. For high-risk domains where tool misuse could cause harm, always route low-precision tool categories to human review before accepting the metrics as a release gate.
The ideal reader is comfortable running batch evaluation pipelines, understands precision/recall trade-offs, and can interpret confusion matrices. You'll need a test harness that iterates over your golden dataset, sends each case through the model under test, collects the model's tool choice, and then feeds both the predictions and ground truth into this evaluation prompt. The prompt itself acts as the judge—it does not call tools. Wire it into your CI/CD pipeline so that every prompt or model change triggers a regression run. If your tool catalog is large or changes frequently, consider stratifying your test cases by tool category to catch category-specific drift before it affects aggregate numbers.
Use Case Fit
This prompt computes precision and recall for tool selection against a golden dataset. It is designed for regression testing pipelines, not for live agent decision-making. Understand where it excels and where it breaks.
Good Fit: Regression Testing After Tool Catalog Changes
Use when: you add, remove, or rename tools in your agent's catalog and need to verify the model still selects the correct tool across a known test suite. Guardrail: Run this prompt against a frozen golden dataset before every deployment. A drop in recall signals that the model now misses tools it previously selected correctly.
Good Fit: Comparing Model Versions for Tool Selection Quality
Use when: evaluating a new model checkpoint or provider to determine if tool selection behavior has improved or degraded. Guardrail: Always compare precision and recall together. A model with high precision but low recall may be too conservative, while high recall with low precision indicates over-calling.
Bad Fit: Real-Time Guardrails in Production Agents
Avoid when: you need to block a bad tool call before it executes. This prompt is an offline evaluation tool, not a low-latency production gate. Guardrail: Use a lightweight schema validator or allowlist check for runtime enforcement. Reserve this prompt for pre-deployment and post-hoc analysis.
Bad Fit: Evaluating Argument Quality or Call Sequencing
Avoid when: you need to grade whether the arguments passed to a tool are correct or whether multi-step calls follow the right order. This prompt only measures tool selection precision and recall. Guardrail: Pair this prompt with a dedicated argument accuracy rubric and a call sequencing validator for full coverage.
Required Input: Labeled Golden Dataset
Risk: Without a high-quality set of expected tool selections, precision and recall metrics are meaningless. Guardrail: Invest in curating a golden dataset that covers common cases, edge cases, and abstention scenarios. Each record must include the input context and the correct tool name from the catalog.
Operational Risk: Tool Name Aliasing and Catalog Drift
Risk: If tool names change between evaluation runs, false negatives will inflate recall drops and trigger false alarms. Guardrail: Normalize tool names before comparison. Maintain a mapping of deprecated tool names to current names and apply it during metric computation to avoid flagging intentional renames as failures.
Copy-Ready Prompt Template
A reusable prompt for computing precision and recall of tool selection against a golden dataset.
This prompt template evaluates an agent's tool selection decisions against a golden dataset of correct tool choices. It is designed to be called once per test case, receiving the agent's selected tool, the ground-truth correct tool, the full tool catalog available at decision time, and the user context that prompted the selection. The output is a structured JSON object containing per-tool precision, recall, and F1 scores, an aggregate confusion matrix, and a list of misclassifications with diagnostic notes. Use this prompt when you need to regression-test tool selection behavior after changing the tool catalog, system prompt, or model version.
textYou are an evaluation harness for tool selection accuracy. Your job is to compare an agent's chosen tool against the ground-truth correct tool for a given user request and produce structured metrics. ## INPUTS - Agent Selected Tool: [AGENT_SELECTED_TOOL] - Ground Truth Correct Tool: [GROUND_TRUTH_TOOL] - Available Tool Catalog (at decision time): [TOOL_CATALOG] - User Request Context: [USER_CONTEXT] - Previous Test Results (for aggregate computation): [PREVIOUS_RESULTS] ## OUTPUT SCHEMA Return a single JSON object with this exact structure: { "per_tool_metrics": [ { "tool_name": "string", "true_positives": number, "false_positives": number, "false_negatives": number, "precision": number, "recall": number, "f1_score": number } ], "aggregate_confusion_matrix": { "labels": ["string"], "matrix": [[number]] }, "misclassifications": [ { "user_context": "string", "selected_tool": "string", "ground_truth_tool": "string", "error_type": "wrong_tool | hallucinated_tool | missed_call | over_call", "diagnostic_note": "string" } ], "aggregate_precision": number, "aggregate_recall": number, "aggregate_f1": number, "total_test_cases": number } ## CONSTRAINTS - If [AGENT_SELECTED_TOOL] is "NONE" or null, treat it as the agent choosing not to call any tool. - If [GROUND_TRUTH_TOOL] is "NONE" or null, the correct decision was to abstain from calling a tool. - A hallucinated tool is any tool name in [AGENT_SELECTED_TOOL] that does not appear in [TOOL_CATALOG]. - Update [PREVIOUS_RESULTS] incrementally: add this test case's counts to the running totals before computing metrics. - If [PREVIOUS_RESULTS] is empty or null, initialize all counts to zero. - Precision = true_positives / (true_positives + false_positives). If denominator is zero, precision is 1.0. - Recall = true_positives / (true_positives + false_negatives). If denominator is zero, recall is 1.0. - F1 = 2 * (precision * recall) / (precision + recall). If both are zero, F1 is 0.0. - Do not fabricate tool names or metrics. Derive everything from the provided inputs. ## RISK LEVEL [RISK_LEVEL] ## EXAMPLES [EXAMPLES]
Adapt this template by replacing the square-bracket placeholders with values from your evaluation harness. For batch evaluation, call this prompt once per test case and accumulate results in [PREVIOUS_RESULTS]. The [TOOL_CATALOG] should be the exact tool definitions available at decision time—include tool names, descriptions, and parameter schemas so the evaluator can detect hallucinated tools. Set [RISK_LEVEL] to "HIGH" if tool misuse could cause data loss, financial impact, or safety incidents; this should trigger additional human review of misclassifications before accepting aggregate metrics. Provide at least three [EXAMPLES] covering correct selection, incorrect selection, and correct abstention to calibrate the evaluator's judgment.
Prompt Variables
Required inputs for the Tool Selection Precision and Recall Evaluation Prompt. Each placeholder must be populated before the prompt can produce reliable metrics against a golden dataset.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[TOOL_CATALOG] | Defines the universe of valid tools the model could have selected, including names, descriptions, and parameter schemas. | [ {"name": "search_kb", "description": "Search the knowledge base."}, {"name": "create_ticket", "description": "Create a support ticket."} ] | Must be a valid JSON array of tool objects. Each object requires a 'name' field. Empty catalog is invalid. Validate with JSON Schema before prompt assembly. |
[GOLDEN_LABELS] | The ground-truth tool selections for each test case, used to compute precision and recall. | [ {"case_id": "001", "expected_tools": ["search_kb"]}, {"case_id": "002", "expected_tools": ["create_ticket", "search_kb"]} ] | Must be a JSON array with case_id and expected_tools fields. expected_tools must be a subset of tool names in [TOOL_CATALOG]. Null or empty expected_tools indicates correct abstention. Validate cross-reference against catalog. |
[MODEL_PREDICTIONS] | The actual tool selections made by the model under evaluation, keyed to the same case IDs as the golden labels. | [ {"case_id": "001", "predicted_tools": ["search_kb"]}, {"case_id": "002", "predicted_tools": ["search_kb"]} ] | Must be a JSON array with case_id and predicted_tools fields. Case IDs must match [GOLDEN_LABELS] exactly. Missing case IDs will be treated as abstention. Validate ID alignment before scoring. |
[EVALUATION_CONTEXT] | Optional per-case context such as user utterance, conversation history, or task description that the model used when making its tool selection. | [ {"case_id": "001", "context": "User asked: How do I reset my password?"} ] | Optional. If provided, must be a JSON array with case_id and context fields. Used only for error analysis and justification; does not affect metric computation. Null allowed per case. |
[CONFUSION_MATRIX_FORMAT] | Specifies the output structure for per-tool confusion matrices, including true positives, false positives, false negatives, and true negatives. | "standard" | Must be one of: 'standard', 'normalized', or 'both'. 'standard' returns raw counts. 'normalized' returns proportions. 'both' returns both. Validate against allowed enum values. |
[ABSTENTION_LABEL] | Defines how the model signals no tool should be called, used to distinguish intentional abstention from missing predictions. | "none" | Must be a string matching the abstention token used in [MODEL_PREDICTIONS]. Common values: 'none', 'null', 'no_tool', or an empty array. Must be consistent across all predictions. Validate token presence in predictions where abstention is expected. |
[OUTPUT_SCHEMA] | Defines the expected JSON structure for the evaluation report, including precision, recall, F1, per-tool metrics, and confusion matrices. | { "type": "object", "properties": { "aggregate_precision": {"type": "number"}, "aggregate_recall": {"type": "number"} }, "required": ["aggregate_precision", "aggregate_recall"] } | Must be a valid JSON Schema object. Required fields must include aggregate_precision, aggregate_recall, and per_tool_metrics at minimum. Validate schema before passing to prompt to ensure output parsing contract is enforceable. |
Implementation Harness Notes
How to wire the Tool Selection Precision and Recall Evaluation Prompt into a regression testing pipeline with validation, retries, and metric aggregation.
This prompt is designed to operate as a batch evaluation step, not a real-time guard. Feed it a golden dataset of test cases where each record contains the user input, the available tool catalog at that moment, and the expected correct tool name. The prompt returns a structured JSON object with per-case predictions, confusion matrix entries, and aggregate precision/recall metrics. Wire this into a CI/CD pipeline that runs on every prompt or tool catalog change, comparing the new metrics against a stored baseline to detect regressions before deployment.
Construct the input payload by assembling the [TOOL_CATALOG] as a JSON array of tool definitions (name, description, parameters), the [TEST_CASES] as an array of objects with input, expected_tool, and optional context, and the [OUTPUT_SCHEMA] as the exact JSON structure you expect back. Use a model with strong JSON mode and low temperature (0.0–0.1) for deterministic scoring. Implement a retry wrapper: if the response fails to parse as valid JSON or is missing required fields (aggregate_metrics, per_case_results), retry up to 2 times with an error message appended to the prompt. After 3 total attempts, fail the evaluation run and alert the pipeline owner—do not silently pass a broken eval.
Post-process the output by extracting aggregate_metrics.precision, aggregate_metrics.recall, and aggregate_metrics.f1 for each tool. Store these alongside the confusion_matrix and per_case_results in your evaluation database. Compare against the previous run's metrics using a threshold (e.g., precision drop > 0.02 triggers a warning, > 0.05 blocks deployment). For high-stakes tool-use workflows where a wrong tool call could trigger destructive actions, add a human review gate on any case where predicted_tool differs from expected_tool and the expected_tool is classified as high-risk in your tool catalog metadata. Log every evaluation run with the prompt version, model version, tool catalog hash, and test suite hash for full traceability.
Expected Output Contract
Fields, types, and validation rules for the precision/recall evaluation output. Use this contract to parse the LLM response, validate it before metric aggregation, and catch malformed results in CI/CD.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
tool_selection_results | array of objects | Must be a non-empty JSON array. Each element must be an object with the fields defined in subsequent rows. | |
tool_selection_results[].test_case_id | string | Must match an [INPUT_TEST_CASE_ID] from the provided dataset. Non-matching IDs trigger a parse error. | |
tool_selection_results[].predicted_tool | string or null | Must be a tool name from the [TOOL_CATALOG] or null if the model abstained. Unknown tool names trigger a hallucination flag. | |
tool_selection_results[].ground_truth_tool | string or null | Must be a tool name from the [TOOL_CATALOG] or null. Null indicates the correct action was abstention. | |
tool_selection_results[].match | boolean | Must be true if predicted_tool equals ground_truth_tool (case-sensitive, trimmed), false otherwise. Null not allowed. | |
per_tool_metrics | object | Keys must be tool names from [TOOL_CATALOG] plus an 'abstention' key. Each value must be an object with precision, recall, and f1 numeric fields. | |
per_tool_metrics.[TOOL_NAME].precision | number | Must be a float between 0.0 and 1.0 inclusive. Computed as true_positives / (true_positives + false_positives). Return 0.0 if denominator is 0. | |
per_tool_metrics.[TOOL_NAME].recall | number | Must be a float between 0.0 and 1.0 inclusive. Computed as true_positives / (true_positives + false_negatives). Return 0.0 if denominator is 0. | |
per_tool_metrics.[TOOL_NAME].f1 | number | Must be a float between 0.0 and 1.0 inclusive. Computed as 2 * (precision * recall) / (precision + recall). Return 0.0 if denominator is 0. | |
aggregate_metrics | object | Must contain macro_precision, macro_recall, macro_f1, and accuracy fields, all floats between 0.0 and 1.0. | |
confusion_matrix | object of objects | Keys must be all tool names from [TOOL_CATALOG] plus 'abstention'. Values are objects with same keys and integer counts. Row sums must equal total predictions for that class. | |
evaluation_metadata | object | Must contain model_version (string), evaluation_timestamp (ISO 8601 string), and total_test_cases (integer matching length of tool_selection_results). |
Common Failure Modes
Tool selection evaluation breaks in predictable ways. These are the most common failure modes when computing precision and recall against golden datasets, with practical mitigations for each.
Golden Dataset Drift
What to watch: Tool catalogs change—tools are added, deprecated, or renamed—but golden labels reference stale tool names. Precision and recall metrics become meaningless when the ground truth no longer matches the current tool surface. Guardrail: Version-lock golden datasets to specific tool catalog snapshots. Run a schema diff before each eval run and flag any tool name mismatches between the catalog and the labels.
Ambiguous Tool Boundaries
What to watch: Two tools have overlapping functionality, and the golden label picks one while the model picks the other. Both are defensible choices, but precision/recall treats one as wrong. This inflates false-positive rates and erodes trust in the metrics. Guardrail: Define an equivalence class for functionally interchangeable tools. Treat selections within the same class as correct during metric computation. Document boundary cases in the golden dataset with rationale.
Context-Dependent Correctness
What to watch: A tool choice is correct only given specific conversation context, user intent, or prior tool outputs—but the golden label was created without that full context. The eval penalizes the model for missing information the annotator had. Guardrail: Include full conversation traces and tool call history in golden dataset entries. Require annotators to document the context assumptions behind each label. Reject labels where context is incomplete.
Abstention Misclassification
What to watch: The model correctly abstains from calling a tool when information is insufficient, but the golden label expects a tool call. Or the model calls a tool when it should have asked for clarification. Both cases distort precision/recall because abstention isn't treated as a valid decision. Guardrail: Add an explicit abstention class to the tool taxonomy. Compute separate metrics for abstention precision and recall. Weight abstention errors differently from tool selection errors in aggregate scores.
Confusion Matrix Blind Spots
What to watch: Aggregate precision and recall hide per-tool performance. A model with 95% overall precision might have 40% precision on a critical high-risk tool. Teams ship with false confidence because the aggregate looks fine. Guardrail: Always report per-tool precision, recall, and F1 alongside aggregate metrics. Set minimum per-tool thresholds for safety-critical tools. Flag any tool with recall below 90% for manual review before deployment.
Label Noise Propagation
What to watch: Human annotators make mistakes—wrong tool labels, inconsistent judgments, or fatigue errors. When 5-10% of golden labels are wrong, precision/recall metrics become unreliable and model improvements become indistinguishable from noise. Guardrail: Require dual annotation with inter-annotator agreement measurement. Flag and re-adjudicate samples where annotators disagree. Track label quality metrics alongside model performance metrics. Run periodic label audits on random samples.
Evaluation Rubric
Use this rubric to grade tool selection precision and recall against a golden dataset. Each criterion targets a specific failure mode that breaks downstream agent reliability. Run per-test-case and aggregate across your eval suite before shipping prompt or tool catalog changes.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Tool Name Precision | All selected tool names exist in the provided [TOOL_CATALOG] with exact name match | Hallucinated tool name not in catalog; fuzzy match to similar tool name | Parse selected tool names; check set membership against catalog tool name list; flag any name with zero Levenshtein distance to catalog entry but non-zero to selected name |
Tool Name Recall | All tools from [GOLDEN_TOOL_SELECTIONS] are present in model output with exact name match | Missing golden tool; model selected subset or empty set when action was required | Compare set of selected tool names to golden set; compute recall = |intersection| / |golden|; flag if recall < 1.0 |
Selection Count Precision | Number of selected tools equals number of golden selections; no extra calls | Over-selection: model called tools not in golden set; under-selection: model omitted required tools | Count selected tools; compare to golden count; flag mismatch; categorize as over-selection or under-selection |
Abstention Correctness | Model abstains (selects no tools) only when [GOLDEN_TOOL_SELECTIONS] is empty; model acts only when golden set is non-empty | False positive: model calls tools when golden says abstain; false negative: model abstains when golden says act | Binary check: model output empty vs non-empty against golden empty vs non-empty; compute abstention precision and recall separately |
Tool Selection Order Independence | Set of selected tool names matches golden set regardless of output order | Model selected correct tools but evaluator penalized due to ordering mismatch in set comparison | Sort both selected and golden tool name lists before comparison; use set equality not list equality; document that order is not scored here |
Confidence Threshold Alignment | Per-call confidence scores from [CONFIDENCE_SCORES] are >= [MIN_CONFIDENCE_THRESHOLD] for all selected tools | Low-confidence correct selection flagged as failure; high-confidence incorrect selection passed | Extract confidence score per selected tool; compare to threshold; route below-threshold calls to human review queue; do not auto-fail correct low-confidence selections |
Aggregate F1 Score | F1 >= [PASS_F1_THRESHOLD] across full test suite | Precision-recall tradeoff masks failure: high precision with low recall or vice versa | Compute per-case precision and recall; macro-average across suite; calculate F1; fail if below threshold; log per-tool breakdown for diagnosis |
Regression Gate | No test case that previously passed now fails; new failures require explicit approval | Silent regression: prompt or catalog change broke previously passing tool selection without detection | Run full golden suite against baseline and candidate; diff pass/fail per case; block release if any new failure lacks [APPROVAL_TICKET] reference |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base prompt with a small golden dataset of 20–50 examples. Skip confusion matrix formatting and output only precision, recall, and F1 per tool plus aggregate. Replace strict JSON Schema enforcement with a looser structure check.
codeEvaluate tool selection against [GOLDEN_DATASET]. Return JSON with: - per_tool: {tool_name: {precision, recall, f1}} - aggregate: {precision, recall, f1} - missed_calls: [list of expected tools not selected] - false_calls: [list of selected tools not expected]
Watch for
- Missing edge cases where multiple tools are valid
- Overly strict exact-match that penalizes functionally equivalent selections
- No handling of optional tool calls in the golden dataset

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us