Inferensys

Prompt

Tool Selection Justification Trace Evaluation Prompt

A practical prompt playbook for using Tool Selection Justification Trace Evaluation Prompt 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, reader, and constraints for the Tool Selection Justification Trace Evaluation Prompt.

This prompt is designed for AI platform engineers and evaluation leads who need to programmatically assess the quality of reasoning traces generated by tool-using agents. The core job-to-be-done is debugging tool selection failures at scale: when an agent picks the wrong tool, you need to know whether its reasoning was incomplete, irrelevant to the task, or misaligned with the actual capabilities of the tools in its catalog. The ideal user is someone running an evaluation harness against agent traces, typically after a test suite or production log review has surfaced unexpected tool choices. They have access to the agent's full reasoning trace, the tool catalog that was available at decision time, and the user's original task context.

You should use this prompt when you need structured, repeatable scores for justification quality across hundreds or thousands of traces. It is particularly valuable during model migration, prompt refactoring, or tool catalog changes—any scenario where previously reliable tool-selection behavior might silently degrade. The prompt produces three scores (completeness, relevance, and capability alignment) plus a consolidated finding, making it suitable for automated regression gates. Do not use this prompt for real-time agent decision-making; it is an offline evaluation tool. Do not use it to grade the correctness of the tool choice itself—that requires a separate Tool Selection Correctness Grading Prompt. This prompt evaluates the explanation, not the outcome.

Before using this prompt, ensure you have the full reasoning trace available, not just the final tool call. The trace must include the agent's stated rationale for selecting the tool. If your agent does not produce explicit reasoning traces, this prompt cannot function—you will need to instrument your agent to emit chain-of-thought before tool calls. Also verify that your tool catalog descriptions accurately reflect what each tool actually does; the prompt judges alignment against the provided descriptions, so stale or misleading catalog entries will produce misleading evaluation scores. For high-stakes debugging where a single misclassification could block a release, pair this automated evaluation with human spot-checking of a sample of traces to calibrate the judge's behavior against your team's standards.

PRACTICAL GUARDRAILS

Use Case Fit

This evaluation prompt is designed for teams debugging reasoning models that explain their tool choices. It is not a general-purpose tool-use grader. Use it when you need to understand why a tool was selected, not just whether the selection was correct.

01

Good Fit: Reasoning Model Debugging

Use when: you have a model that produces explicit reasoning traces before or alongside tool calls, and you need to diagnose selection errors. Guardrail: Ensure the trace is captured in a structured field separate from the tool call itself so the evaluator prompt can isolate justification text from execution payloads.

02

Good Fit: Tool Catalog Misalignment Detection

Use when: the model consistently picks the wrong tool and you suspect its internal rationale doesn't match actual tool capabilities. Guardrail: Provide the full tool catalog with descriptions inside the evaluation context so the judge can compare the justification against real tool signatures, not assumed ones.

03

Bad Fit: Binary Correctness Grading

Avoid when: you only need a pass/fail on whether the right tool was called. This prompt evaluates justification quality, not selection accuracy. Guardrail: Use the sibling Tool Selection Correctness Grading Prompt for binary decisions and reserve this prompt for trace-quality analysis.

04

Bad Fit: No Reasoning Trace Available

Avoid when: the model does not emit reasoning traces or you cannot extract them reliably. Guardrail: Confirm trace availability in your model's response format before wiring this evaluator into a pipeline. If traces are absent, fall back to argument-accuracy or selection-correctness evaluators.

05

Required Input: Tool Capability Ground Truth

Risk: The judge cannot assess justification-to-capability alignment without knowing what each tool actually does. Guardrail: Always include a structured tool manifest with name, description, and parameter contracts in the evaluation context. Without it, the judge will hallucinate capability assumptions.

06

Operational Risk: Justification Plausibility vs. Truth

Risk: Models can produce fluent, plausible-sounding justifications for incorrect tool selections. The evaluator may be swayed by rhetorical quality rather than factual alignment. Guardrail: Pair this prompt with a ground-truth selection correctness check. Use the justification score only to explain failures, not to override correctness judgments.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for evaluating the quality of reasoning traces that justify tool selection decisions.

This section provides the core prompt template for grading tool selection justification traces. The prompt is designed to evaluate whether an agent's reasoning for choosing a specific tool is complete, relevant to the task, and aligned with the actual capabilities of the selected tool. Use this template as the foundation for automated evaluation pipelines, debugging tool selection failures, or comparing reasoning quality across model versions. The template uses square-bracket placeholders that you must replace with your specific tool catalog, task context, and evaluation criteria before use.

text
You are an expert evaluator grading the quality of reasoning traces that justify tool selection decisions. Your job is to assess whether the provided justification correctly explains why a specific tool was chosen for a given task.

## INPUTS

**Task Description:**
[TASK_DESCRIPTION]

**Available Tools (with capabilities):**
[TOOL_CATALOG]

**Selected Tool:**
[SELECTED_TOOL_NAME]

**Justification Trace:**
[JUSTIFICATION_TRACE]

**Actual Tool Capabilities (ground truth):**
[TOOL_CAPABILITIES_REFERENCE]

## EVALUATION CRITERIA

Evaluate the justification trace across three dimensions, each scored 1-5:

1. **Completeness (1-5):** Does the justification address why this tool was chosen over alternatives? Does it mention relevant capabilities and constraints? Are there gaps in reasoning?
   - 1: No meaningful justification provided
   - 3: Mentions some relevant factors but misses key alternatives or constraints
   - 5: Thoroughly addresses tool selection rationale, compares alternatives, and acknowledges limitations

2. **Relevance to Task (1-5):** Does the justification connect tool capabilities to specific task requirements? Is the reasoning task-grounded rather than generic?
   - 1: Justification is unrelated to the actual task
   - 3: Makes some task-relevant points but includes irrelevant or generic statements
   - 5: Every point directly connects tool capabilities to specific task requirements

3. **Alignment with Actual Capabilities (1-5):** Does the justification accurately describe what the selected tool can do? Are there hallucinated capabilities or omissions?
   - 1: Claims capabilities the tool does not have or fundamentally misunderstands the tool
   - 3: Mostly accurate but contains minor errors or omissions about tool capabilities
   - 5: Perfectly accurate representation of tool capabilities with no hallucinations or omissions

## OUTPUT FORMAT

Return a JSON object with this exact structure:
{
  "completeness_score": <integer 1-5>,
  "relevance_score": <integer 1-5>,
  "alignment_score": <integer 1-5>,
  "aggregate_score": <float 1.0-5.0>,
  "justification_summary": "<2-3 sentence summary of the overall quality>",
  "strengths": ["<specific strength 1>", "<specific strength 2>"],
  "weaknesses": ["<specific weakness 1>", "<specific weakness 2>"],
  "hallucinated_capabilities": ["<capability claimed but not present>"],
  "missing_capabilities": ["<relevant capability not mentioned>"],
  "improvement_suggestions": "<actionable suggestion for better justification>"
}

## CONSTRAINTS

- Base scores strictly on the justification trace content, not on whether the tool selection itself was correct
- If the justification mentions capabilities not in the reference, flag them as hallucinated
- If the justification omits clearly relevant capabilities from the reference, flag them as missing
- The aggregate score is the mean of the three dimension scores
- If the justification trace is empty or missing, score all dimensions as 1

Adaptation guidance: Replace [TASK_DESCRIPTION] with the specific task the agent was trying to accomplish. Populate [TOOL_CATALOG] with your full tool list including descriptions—this provides context for what alternatives were available. [SELECTED_TOOL_NAME] should be the tool the agent actually chose, and [JUSTIFICATION_TRACE] is the raw reasoning text you want to evaluate. The [TOOL_CAPABILITIES_REFERENCE] is critical: provide the authoritative description of what the selected tool actually does, drawn from your tool documentation or schema. This ground truth enables hallucination detection. For batch evaluation, wrap this prompt in a harness that iterates over test cases and collects structured outputs for analysis.

Next steps: After adapting the template, run it against a sample of 20-50 justification traces and manually review the scores for calibration. Pay special attention to the hallucinated_capabilities field—false positives here indicate the evaluator is too strict, while false negatives mean it's missing fabricated claims. Adjust the scoring rubric descriptions if needed before scaling to full evaluation pipelines. For production use, pair this prompt with a JSON schema validator to catch malformed outputs before they enter your metrics pipeline.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Tool Selection Justification Trace Evaluation Prompt. Each variable must be populated before the prompt is sent to the judge model. Missing or malformed inputs are the most common cause of unreliable scores.

PlaceholderPurposeExampleValidation Notes

[TOOL_CATALOG]

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

tools: [{name: "search_knowledge_base", description: "Queries the internal wiki", parameters: {query: string, max_results: integer}}]

Must be valid JSON array. Each tool object requires name, description, and parameters fields. Empty catalog allowed for abstention test cases only.

[AGENT_TASK]

The original task or user request that triggered the tool selection decision

Find the latest Q3 revenue report and summarize the key findings

Must be non-empty string. Should match the exact task presented to the agent under evaluation. Truncation beyond 2000 tokens may degrade context accuracy.

[TOOL_SELECTION]

The actual tool call the agent made, including tool name and arguments

tool: search_knowledge_base, arguments: {query: "Q3 2024 revenue report", max_results: 5}

Must be valid JSON with tool and arguments keys. Null allowed for abstention test cases. Tool name must be checked against [TOOL_CATALOG] names.

[JUSTIFICATION_TRACE]

The reasoning trace or explanation the agent produced for why it selected this tool

I chose search_knowledge_base because the user asked for a specific report and this tool indexes all internal documents by date and topic

Must be non-empty string. Minimum 20 characters to ensure substantive trace. Traces under 50 characters should be flagged as potentially insufficient.

[CONTEXT_HISTORY]

Prior conversation turns, tool outputs, or retrieved context available to the agent before the selection decision

[{role: "user", content: "What were our Q3 numbers?"}, {role: "assistant", content: "I'll need to look that up. Which region?"}]

Must be valid JSON array of message objects or null. Each message requires role and content fields. Null allowed for first-turn evaluation scenarios.

[EVALUATION_RUBRIC]

Scoring criteria defining what constitutes a complete, relevant, and capability-aligned justification

completeness: Does the trace explain why this tool over alternatives? relevance: Does the trace connect tool capabilities to task requirements? alignment: Does the trace accurately reflect the tool's actual documented capabilities?

Must be valid JSON object with at least one scoring dimension. Each dimension requires a description string. Missing dimensions will cause the judge to apply undefined criteria.

[EXPECTED_TOOL]

The ground-truth correct tool for this task, used for comparison scoring

search_knowledge_base

Must be a string matching a tool name in [TOOL_CATALOG] or null. Null indicates the correct behavior is abstention. Mismatch between [EXPECTED_TOOL] and [TOOL_SELECTION] triggers justification quality analysis rather than binary pass/fail.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Tool Selection Justification Trace Evaluation Prompt into an automated evaluation pipeline with validation, retries, and human review gates.

This prompt is designed to operate as a scoring step inside an automated evaluation harness, not as a one-off manual review tool. The typical integration pattern is: a test suite executes an agent against a set of scenarios, the agent produces tool calls and reasoning traces, and this prompt grades the quality of the justification trace for each tool selection decision. The harness should feed the prompt a structured input containing the task context, the available tool catalog with descriptions, the tool that was selected, and the reasoning trace the agent produced. The output is a structured score object that downstream systems can log, aggregate, and alert on.

Validation and retry logic is critical because the prompt produces structured JSON output. Implement a JSON schema validator that checks for required fields (justification_completeness_score, task_relevance_score, capability_alignment_score, overall_score, failure_flags) and enforces score ranges (e.g., 1–5 for individual dimensions). If validation fails, retry up to two times with the same input and an added instruction to strictly follow the output schema. After three failures, log the raw response and escalate for manual review. For high-stakes evaluation pipelines (e.g., pre-deployment gates), route all overall_score values below 3 to a human review queue with the original trace and the model's critique attached.

Model choice and temperature settings matter for judge consistency. Use a model with strong instruction-following and structured output capabilities (e.g., GPT-4o, Claude 3.5 Sonnet) at temperature 0 or very low temperature (0.0–0.1) to maximize scoring reproducibility. Avoid using the same model family as the agent under test for evaluation, as self-preference bias can inflate scores. Log the judge model version alongside every score so that score drift from judge model updates can be detected. Store evaluation results in a structured format (JSON columns in a database or Parquet files) with fields for test_case_id, agent_model_version, judge_model_version, timestamp, and all score dimensions. This enables longitudinal tracking of justification quality across agent iterations.

Integration with CI/CD and alerting turns this prompt from a diagnostic tool into a production gate. Wire the evaluation harness into your agent's pull request pipeline: run the full test suite, compute aggregate metrics (mean overall score, distribution of failure flags), and fail the build if the mean score drops below a defined threshold or if any critical failure flag (e.g., hallucinated_capability) appears in more than 1% of test cases. For ongoing monitoring, run a subset of evaluation scenarios daily against production agent traces and trigger an alert if justification quality degrades. The failure flags field is particularly actionable—use it to route specific failure categories (e.g., missing_capability_reference, circular_reasoning) to the engineering team responsible for the agent's tool-use prompts.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the Tool Selection Justification Trace Evaluation output. Use this contract to parse and validate the LLM judge response before storing scores or triggering downstream workflows.

Field or ElementType or FormatRequiredValidation Rule

justification_trace

string

Must be non-empty and contain at least one reasoning step referencing a tool capability from [TOOL_CATALOG]

tool_selected

string

Must exactly match a tool name in [TOOL_CATALOG] or be 'none' if no tool was appropriate

justification_completeness_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive; parse check with two-decimal precision tolerance

relevance_to_task_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive; null not allowed

capability_alignment_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive; score must be 0.0 if tool_selected is not in [TOOL_CATALOG]

overall_score

number (0.0-1.0)

Must be the mean of the three component scores rounded to two decimal places; validate computed value against provided overall_score

missing_capabilities

array of strings

If present, each string must reference a capability from [TOOL_CATALOG] that was needed but absent; empty array allowed

hallucinated_capabilities

array of strings

If present, each string must be flagged if it does not appear in any tool description within [TOOL_CATALOG]; null allowed if no hallucinations detected

PRACTICAL GUARDRAILS

Common Failure Modes

When evaluating tool selection justification traces, these failure modes surface first in production. Each card identifies a specific breakage pattern and the guardrail that catches it before it reaches downstream systems.

01

Plausible-Sounding but Wrong Justification

What to watch: The model produces a fluent, confident justification that references tool capabilities incorrectly—claiming a tool can do something it cannot, or citing a non-existent parameter as the reason for selection. The trace reads well but is factually disconnected from the actual tool schema. Guardrail: Cross-reference every capability claim in the justification against the provided tool catalog schema. Add a schema-grounding check that flags claims not directly supported by the tool's description, parameter list, or documented behavior.

02

Post-Hoc Rationalization of a Wrong Choice

What to watch: The model selects the wrong tool first, then constructs a justification that retroactively explains the incorrect choice. The reasoning appears coherent but the conclusion is wrong, making the trace actively misleading for debugging. Guardrail: Evaluate the justification trace independently from the tool selection correctness. Use a separate grading pass that checks whether the justification would lead a reviewer to the correct tool, not whether it defends the chosen one.

03

Missing Negative Reasoning

What to watch: The justification only explains why the selected tool fits but never addresses why alternative tools were rejected. This omission hides selection errors where multiple tools could plausibly apply and the model picked the wrong one without considering trade-offs. Guardrail: Require the justification prompt to include a 'rejected alternatives' section. Grade whether the trace explicitly rules out at least one other candidate tool with a capability-based reason, not just a preference statement.

04

Over-Confidence on Ambiguous Tool Boundaries

What to watch: When two tools have overlapping capabilities, the model picks one and justifies it with absolute certainty, ignoring the ambiguity. In production, this produces brittle selections that fail when the overlapping tool would have been safer or more appropriate. Guardrail: Add an ambiguity detection check. If the task sits in an overlap zone between tools, the justification should acknowledge the ambiguity and explain the tie-breaking logic. Flag justifications that express certainty when the tool catalog shows functional overlap.

05

Context-Argument Mismatch in Justification

What to watch: The justification references user intent, task requirements, or constraints that are not actually present in the input context. The model hallucinates a reason for tool selection by inventing user needs that sound plausible but were never stated. Guardrail: Extract every factual claim in the justification and check whether it is grounded in the provided input context. Use a grounding verification step that requires each claim to cite a specific span from the user request or conversation history.

06

Justification Drift Across Model Versions

What to watch: A justification trace that scored well on one model version produces different reasoning on the next version—same tool selection, but the explanation quality degrades or shifts to emphasize irrelevant factors. This breaks evaluation consistency and makes score trends unreliable. Guardrail: Maintain a golden dataset of justification traces with expected reasoning patterns. Run regression tests that compare justification structure and key reasoning points across model versions, not just final tool selection accuracy.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to grade the quality of tool selection justification traces. Each criterion should be scored independently, then aggregated into a final pass/fail or numeric score based on your threshold requirements.

CriterionPass StandardFailure SignalTest Method

Tool-Context Alignment

Justification explicitly references the user's stated goal and explains why the selected tool is the best match from the provided catalog.

Justification is generic, ignores the user's goal, or selects a tool without connecting its purpose to the task.

LLM-as-judge pairwise check: does the trace connect [USER_GOAL] to the tool's documented purpose in [TOOL_CATALOG]?

Capability Grounding

Justification references specific capabilities, parameters, or return types from the tool definition. No invented features.

Justification attributes a capability to the tool that is not present in [TOOL_CATALOG] or describes a parameter that does not exist.

Schema diff check: extract claimed capabilities from the trace and validate each against the tool's JSON Schema definition.

Alternative Rejection Reasoning

Justification explains why at least one plausible alternative tool was not selected, based on documented differences.

Only the chosen tool is mentioned; no alternatives are considered even when [TOOL_CATALOG] contains functionally overlapping tools.

LLM-as-judge check: given [TOOL_CATALOG], identify overlapping tools and verify the trace addresses at least one.

Abstention Consideration

Justification explicitly states whether no tool call is appropriate and why, even if a tool is ultimately selected.

Trace proceeds directly to tool selection without any check for whether the request requires a tool at all.

Binary check: does the trace contain an abstention evaluation step before tool selection?

Argument Preview Quality

Justification previews which arguments will be populated and why those values are appropriate given [INPUT_CONTEXT].

Trace selects a tool but provides no reasoning about argument values or uses placeholder reasoning like 'will fill as needed'.

LLM-as-judge check: compare previewed arguments against [INPUT_CONTEXT] for relevance and completeness.

Uncertainty Disclosure

Justification flags any ambiguity in the request, missing required arguments, or low-confidence tool matches.

Trace expresses full confidence when [INPUT_CONTEXT] is ambiguous or missing required fields for the selected tool.

Confidence probe: inject ambiguous [INPUT_CONTEXT] variants and verify the trace surfaces uncertainty.

Trace Conciseness

Justification is complete but avoids filler text, repetition, or irrelevant background. Under 200 words for a single tool selection.

Trace exceeds 300 words, repeats the same point, or includes information not relevant to tool selection.

Word count check plus LLM-as-judge redundancy scan: flag repeated sentences or off-topic content.

Schema Compliance

Output trace follows the required [OUTPUT_SCHEMA] with all required fields present and correctly typed.

Output is missing required fields, uses wrong types, or nests justification in an unexpected structure.

JSON Schema validator: run [OUTPUT_SCHEMA] validation and reject on any violation.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single reasoning model and a small hand-labeled dataset of 20-30 tool-selection traces. Replace [TOOL_CATALOG] with a simplified list of 3-5 tools. Drop the inter-rater reliability check and use a single judge pass. Accept qualitative review of justification scores over strict numeric thresholds.

Watch for

  • Overly generous scoring when the justification sounds plausible but misrepresents the tool's actual capability
  • Missing edge cases where the model selected the right tool for the wrong reason
  • Judge leniency on incomplete traces that skip prerequisite reasoning steps
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.