Inferensys

Prompt

Tool Selection Correctness Grading Prompt Template

A practical prompt playbook for using Tool Selection Correctness Grading Prompt Template in production AI workflows.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROMPT PLAYBOOK

When to Use This Prompt

Define the job, ideal user, required context, and constraints for the Tool Selection Correctness Grading prompt.

This prompt is designed for agent platform teams and evaluation engineers who need to programmatically verify that a language model selected the correct tool from a defined catalog. The core job-to-be-done is binary classification: given a user task, a conversation context, and a list of available tools, did the model choose the right one? This is not a prompt for generating tool calls; it is a grading prompt that acts as an LLM judge to score a prior model's decision. The ideal user is someone building a CI/CD evaluation harness who needs a repeatable, automatable signal to gate a model or prompt update before it reaches production.

Use this prompt when you have a closed tool catalog and a golden dataset of expected tool selections. It works best when the correct tool choice is unambiguous given the context. You must provide the full tool catalog with descriptions, the user's input, any relevant conversation history, and the model's actual tool selection. The prompt produces a structured pass/fail judgment with a justification, making it suitable for automated precision/recall tracking across test suites. Do not use this prompt when the correct tool is ambiguous or when multiple tools could reasonably satisfy the request—this is a correctness grader, not a preference judge. For those cases, use a pairwise comparison or rubric-based evaluation instead.

This prompt is a component in a larger evaluation pipeline, not a standalone product feature. It assumes you already have a test suite of examples where the ground-truth tool selection is known. Wire it into your regression testing framework to catch tool-selection regressions when you change system prompts, update tool descriptions, or swap models. The output is designed to be machine-readable, but the justification field provides human-readable debugging information when a test case fails. Always pair this prompt with human spot-checking of a sample of judgments, especially when adding new tools to the catalog or when the judge model disagrees with your ground truth. The judge can be wrong, and calibration against human ratings is essential before trusting automated pass/fail decisions at scale.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Understand the operational boundaries before embedding it in a CI/CD pipeline or agent evaluation harness.

01

Good Fit: Deterministic Tool Catalogs

Use when: you have a closed, versioned tool catalog with unique names and strict schemas. The prompt excels at binary pass/fail grading against a known set of tools. Guardrail: Pin the tool catalog version in your eval config to prevent drift between the catalog used for grading and the one served to the agent.

02

Bad Fit: Semantic Equivalence Without Ground Truth

Avoid when: multiple tools can reasonably satisfy the same intent and you lack a golden dataset of correct selections. The prompt forces a binary choice and will penalize valid alternatives. Guardrail: Use a pairwise comparison or preference prompt instead when tool selection is subjective.

03

Required Input: Golden Tool-Call Dataset

Risk: Without a labeled dataset mapping inputs to correct tool selections, the prompt produces unverifiable judgments. Guardrail: Invest in curating a golden dataset before running this prompt. Start with 50-100 hand-labeled examples covering common and edge-case scenarios.

04

Operational Risk: Catalog Drift

Risk: The tool catalog changes between evaluation runs, invalidating prior golden datasets and causing false regressions. Guardrail: Version-lock the tool catalog in your test harness. Run a schema diff on catalog updates and flag any test cases that reference deprecated or renamed tools.

05

Operational Risk: Precision-Recall Blind Spots

Risk: The prompt produces per-example pass/fail judgments but doesn't automatically aggregate precision and recall across a test suite. Teams may miss systemic over-selection or under-selection patterns. Guardrail: Wrap the prompt in a harness that computes precision, recall, and a confusion matrix per tool across the full test suite.

06

Not a Replacement: Human Review for Safety-Critical Tools

Risk: A binary pass/fail judgment from an LLM judge is not sufficient for tools that trigger payments, access PII, or modify production infrastructure. Guardrail: Route all tool-selection evaluations for high-risk actions to a human review queue. Use this prompt only as a pre-filter to flag obvious failures.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for grading whether an agent selected the correct tool from a provided catalog.

This section provides the core prompt template for evaluating tool selection correctness. The template is designed to be copied directly into your evaluation harness, with placeholders that you replace with your specific tool catalog, agent trace, and grading criteria. It produces a binary pass/fail judgment with a structured justification, making it suitable for automated regression testing, CI/CD gates, and batch evaluation pipelines. The prompt assumes you have a golden dataset or ground-truth label for which tool should have been selected in each scenario.

text
You are an expert evaluator grading an AI agent's tool selection decision. Your task is to determine whether the agent chose the correct tool from the provided tool catalog, given the user's request and available context.

# TOOL CATALOG
[TOOL_CATALOG]

# USER REQUEST
[USER_REQUEST]

# AVAILABLE CONTEXT
[CONTEXT]

# AGENT'S SELECTED TOOL
[SELECTED_TOOL_NAME]

# EXPECTED CORRECT TOOL (GROUND TRUTH)
[EXPECTED_TOOL_NAME]

# GRADING INSTRUCTIONS
1. Compare the agent's selected tool against the expected correct tool.
2. If the selected tool matches the expected tool exactly, the grade is PASS.
3. If the selected tool differs from the expected tool, the grade is FAIL.
4. If the agent selected no tool but the expected tool is present, the grade is FAIL with abstention noted.
5. If the agent selected a tool but the expected tool indicates no tool should be called, the grade is FAIL with over-action noted.

# OUTPUT FORMAT
Return a JSON object with the following structure:
{
  "grade": "PASS" | "FAIL",
  "selected_tool": "[tool name or null]",
  "expected_tool": "[tool name or null]",
  "justification": "Brief explanation of why the grade was assigned, referencing specific tool capabilities from the catalog.",
  "failure_category": null | "wrong_tool" | "abstention_error" | "over_action" | "hallucinated_tool"
}

# CONSTRAINTS
- Only use tools listed in the TOOL CATALOG for your evaluation.
- If the agent selected a tool not present in the catalog, set failure_category to "hallucinated_tool".
- Do not evaluate argument correctness; only evaluate tool selection.
- Base your judgment solely on the provided context and tool catalog.

To adapt this template for your evaluation pipeline, replace each square-bracket placeholder with your actual data. The [TOOL_CATALOG] should contain the full list of available tools with their names and descriptions, formatted consistently with how they were presented to the agent. The [USER_REQUEST] and [CONTEXT] should match exactly what the agent received. The [SELECTED_TOOL_NAME] comes from the agent's trace, and [EXPECTED_TOOL_NAME] comes from your golden dataset. For batch evaluation, wrap this prompt in a loop that iterates over your test cases, collecting grades and failure categories for precision/recall calculation. If your tool catalog is large, consider truncating it to only relevant tools to reduce token usage and improve grading accuracy. Always validate the output JSON structure before aggregating results, as malformed judge outputs can corrupt your metrics.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Tool Selection Correctness Grading Prompt. Each placeholder must be populated before the judge prompt can produce a reliable pass/fail decision.

PlaceholderPurposeExampleValidation Notes

[TOOL_CATALOG]

Complete list of available tools with names, descriptions, and parameter schemas the agent could have chosen from

search_kb(query: str), create_ticket(title: str, priority: int), escalate(reason: str)

Must be a valid JSON array of tool definitions. Each tool must have a unique name field. Empty catalog triggers a schema validation failure before grading.

[AGENT_TASK]

The original task or instruction given to the agent that required tool selection

Find all open high-priority tickets related to billing and summarize them

Must be a non-empty string. Vague tasks like 'do something' should be rejected in pre-validation. Task must be resolvable by at least one tool in [TOOL_CATALOG].

[TOOL_CALL_MADE]

The actual tool call produced by the agent under evaluation, including tool name and arguments

{"tool": "search_kb", "arguments": {"query": "billing tickets high priority"}}

Must be a valid JSON object with tool and arguments keys. Null or missing tool key is a valid abstention signal. Parse check required before grading.

[GROUND_TRUTH_TOOL]

The correct tool name that should have been selected for this task, as determined by human annotation or golden dataset

search_kb

Must exactly match a tool name in [TOOL_CATALOG]. Use null when the correct action is abstention. Mismatch between ground truth and catalog is a pre-validation error.

[CONTEXT]

Optional conversation history, prior tool outputs, or environmental state available to the agent at decision time

Previous call returned: 3 tickets found. User said: 'focus on billing'

Can be null or empty string. When provided, must be a string under 8000 tokens. Truncation warning should fire if exceeded. Context must not contain the ground truth label.

[CONSTRAINTS]

Optional explicit rules about tool preference, disallowed tools, or conditional selection logic the agent was instructed to follow

Do not use escalate tool for billing issues. Prefer search_kb over create_ticket for information retrieval.

Can be null. When provided, must be a string. Constraints that contradict [GROUND_TRUTH_TOOL] indicate a test design error and should be flagged in pre-validation.

[OUTPUT_FORMAT]

Expected structure for the judge's response, typically a JSON schema with pass, justification, and metadata fields

{"pass": boolean, "justification": string, "selected_tool": string, "expected_tool": string}

Must be a valid JSON Schema or example structure. Default schema should be applied if null. Output format must include a pass field for binary gating.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Tool Selection Correctness Grading prompt into an evaluation pipeline with validation, retries, logging, and human review gates.

The Tool Selection Correctness Grading prompt is designed to operate as a deterministic evaluation step within a larger CI/CD or regression testing pipeline, not as a one-off manual check. To integrate it, you will need a test harness that iterates over a golden dataset of test cases, each containing a user request, the available tool catalog at the time of the request, and the expected correct tool name. For each test case, the harness injects the model's actual tool selection into the [ACTUAL_TOOL_SELECTION] placeholder and the expected tool into [EXPECTED_TOOL_SELECTION], then calls the LLM judge. The judge returns a structured JSON object with a pass boolean and a justification string, which the harness parses to compute aggregate precision and recall across the entire test suite.

A robust implementation must include validation of the judge's output against a strict JSON schema before accepting the result. If the judge returns malformed JSON, a missing pass field, or an unexpected value, the harness should retry the grading call once with a stronger format instruction appended to the prompt. If the retry also fails, the test case should be flagged for human review and excluded from aggregate metrics to avoid corrupting your precision/recall calculations. Log every grading call—including the prompt version, model used, input test case ID, raw judge output, and validation status—so that you can trace judge drift or flakiness over time. For high-stakes tool-use workflows where a wrong tool call could trigger a destructive action, set a minimum precision threshold (e.g., 0.98) as a CI/CD gate and require a human sign-off on the full justification log for any failing test case before a new prompt or model version can be deployed.

When choosing a model for the judge, prefer a fast, cost-efficient option with strong instruction-following and JSON output capabilities. The judge's task is classification with justification, not complex reasoning, so a smaller model often suffices. However, if your tool catalog is large or tools have overlapping capabilities, test the judge's agreement rate with human annotators on a calibration set before trusting it in automation. Avoid wiring this prompt directly into a production agent's runtime decision loop; it is an offline evaluation tool. The next step after establishing your grading harness is to run it against your existing test suite, establish a baseline precision/recall score, and then integrate it into your prompt versioning pipeline so that every proposed change to system instructions or tool descriptions is automatically scored before release.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the JSON output produced by the Tool Selection Correctness Grading Prompt. Use this contract to parse and validate the model's response before integrating it into evaluation pipelines.

Field or ElementType or FormatRequiredValidation Rule

verdict

string (enum: 'pass', 'fail')

Must be exactly 'pass' or 'fail'. Case-sensitive. No other values allowed.

selected_tool

string or null

Must match a tool name from the provided [TOOL_CATALOG] or be null if no tool was selected. Trim whitespace before comparison.

expected_tool

string or null

Must match a tool name from the provided [TOOL_CATALOG] or be null if the correct action is abstention. Trim whitespace before comparison.

justification

string

Must be a non-empty string between 20 and 500 characters. Must reference specific tool capabilities from [TOOL_CATALOG] or explain abstention reasoning.

confidence_score

number (float, 0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive. Parse as float and check bounds. Null not allowed.

error_category

string (enum) or null

If verdict is 'fail', must be one of: 'wrong_tool', 'should_have_abstained', 'should_have_acted', 'hallucinated_tool'. If verdict is 'pass', must be null.

tool_catalog_version

string

If provided in [TOOL_CATALOG], must match the version identifier exactly. Used for traceability across catalog changes.

evaluation_timestamp

string (ISO 8601)

If present, must parse as a valid ISO 8601 datetime string. Used for audit trail and time-based regression analysis.

PRACTICAL GUARDRAILS

Common Failure Modes

Tool selection grading fails in predictable ways. These are the most common failure modes when evaluating whether an agent chose the right tool, along with practical guardrails to catch them before they reach production.

01

Tool Catalog Drift

What to watch: The evaluation prompt references tool names, descriptions, or parameter schemas that no longer match the live tool catalog. The judge marks correct selections as wrong because its reference is stale. Guardrail: Version-lock the tool catalog in the eval harness. Run a schema diff check before each eval suite to detect drift between the judge's reference catalog and the agent's actual tool definitions.

03

Context Window Truncation

What to watch: The evaluation prompt includes the full conversation history plus the tool catalog plus grading criteria. In long agent traces, the judge's context window cuts off earlier turns, causing it to miss evidence that would justify the tool selection. Guardrail: Truncate conversation history to the most recent N turns relevant to the tool decision. If full history is needed, chunk the evaluation and aggregate scores with a meta-judge that receives summaries of each chunk.

04

Justification-Only Grading

What to watch: The judge reads a well-written justification and marks the selection correct even when the tool choice is objectively wrong. Fluent rationalization masks incorrect decisions. Guardrail: Require the judge to produce the binary pass/fail verdict before writing the justification. Use a two-pass approach: first pass scores correctness blind to reasoning, second pass writes the explanation. Cross-validate with a separate justification-quality check that flags mismatches between verdict and reasoning.

05

Ambiguous Task-to-Tool Mapping

What to watch: The user request could reasonably be handled by multiple tools, but the golden dataset assumes only one correct answer. The judge penalizes valid alternative selections, inflating false-negative rates. Guardrail: Annotate golden datasets with acceptable tool sets, not single correct answers. Configure the grading prompt to accept any tool in the approved set. Track per-example ambiguity rates and flag test cases where the acceptable set grows too large for meaningful evaluation.

06

Judge Model Bias Toward Common Tools

What to watch: The judge model shares the same training distribution as the agent model and exhibits the same biases—favoring frequently used tools over correct but rare ones. Both models agree on the wrong answer, producing misleadingly high scores. Guardrail: Use a different model family for the judge than for the agent under test. Include adversarial test cases where the correct tool is deliberately obscure. Monitor score correlation between judge and agent model families to detect shared blind spots.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to grade the output of the Tool Selection Correctness Grading Prompt Template. Each criterion defines a pass standard, a failure signal, and a test method that can be automated in a CI/CD pipeline or evaluation harness.

CriterionPass StandardFailure SignalTest Method

Binary Pass/Fail Accuracy

The pass boolean matches the ground-truth label for the test case.

False positive (pass when it should fail) or false negative (fail when it should pass).

Compare pass field against golden dataset label; compute precision, recall, and F1 over a test suite of at least 50 cases.

Justification Completeness

The justification field references the chosen tool, the required tool, and the reason for the match or mismatch.

Justification is missing, generic, or omits the tool name or the decision rationale.

Check that justification contains the tool name from tool_selected and at least one reason keyword from the tool catalog description.

Tool Catalog Grounding

The tool_selected value exactly matches a name entry in the provided [TOOL_CATALOG].

The output references a tool not present in the catalog or hallucinates a tool name.

Validate tool_selected against the [TOOL_CATALOG] JSON schema; flag any value not in the catalog name set.

Context Alignment

The justification correctly references the user request in [INPUT] and the agent's intended action in [AGENT_CONTEXT].

Justification ignores the provided context or fabricates a user need not present in [INPUT].

Check for substring overlap between justification and key terms from [INPUT] and [AGENT_CONTEXT]; flag if overlap is below 20%.

Output Schema Compliance

The JSON output contains all required fields: pass, tool_selected, required_tool, justification, and confidence.

Missing field, extra field, or wrong type (e.g., pass as string instead of boolean).

Validate against a strict JSON Schema that enforces field presence, types, and enum values; reject on first violation.

Confidence Score Range

The confidence field is a number between 0.0 and 1.0 inclusive.

Confidence is negative, greater than 1.0, null, or a non-numeric string.

Parse confidence as float; assert 0.0 <= confidence <= 1.0; flag out-of-range or unparseable values.

Required Tool Identification

The required_tool field matches the ground-truth expected tool for the test case.

The field contains a tool name that does not match the expected tool in the golden dataset.

Compare required_tool against the golden dataset's expected_tool field; compute exact-match accuracy across the test suite.

Abstention Handling

When no tool is required, pass is true, tool_selected is null, and required_tool is null.

The output forces a tool selection when [AGENT_CONTEXT] indicates no action was needed, or returns a false negative.

Test with a dedicated abstention subset where expected_tool is null; verify pass is true and both tool fields are null.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a small catalog of 3–5 tools. Remove the precision/recall tracking harness and focus on binary pass/fail per test case. Use a single frontier model without calibration against human labels.

Simplify the output schema to:

json
{
  "correct_tool_selected": true,
  "selected_tool": "[TOOL_NAME]",
  "expected_tool": "[TOOL_NAME]",
  "justification": "[BRIEF_REASON]"
}

Watch for

  • Overly generous passes when the model picks a functionally similar but wrong tool
  • Justifications that sound plausible but misread the tool catalog
  • No baseline to detect regressions when you iterate the prompt
Prasad Kumkar

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.