Inferensys

Prompt

Tool-Use Justification in Reasoning Trace Prompt

A practical prompt playbook for using Tool-Use Justification in Reasoning Trace 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

Defines the specific job, ideal user, and operational constraints for the Tool-Use Justification in Reasoning Trace Prompt.

This prompt is designed for agent evaluation teams who need to programmatically grade whether an AI agent's reasoning trace provides a valid, sufficient, and non-superfluous justification for every tool call it makes. The core job-to-be-done is moving beyond binary tool-use correctness (did it call the right API?) to auditing the agent's decision-making transparency. You should use this prompt when you are building an evaluation harness for an agent that uses external tools (APIs, databases, MCP servers) and you need to ensure its internal monologue actually explains why a tool is needed, what it expects to get back, and how the result will advance the task. The ideal user is an AI engineer or evaluation lead who already has a dataset of agent traces with tool calls and needs to add a 'justification quality' score to their existing eval pipeline.

Required context for this prompt includes: the full reasoning trace leading up to the tool call, the tool's name and schema (parameters and description), the arguments passed, and the broader task context. Without the reasoning trace, the judge has nothing to evaluate. Without the tool schema, the judge cannot assess whether the justification correctly anticipates the tool's function. Do not use this prompt for evaluating the correctness of the tool's output, the final answer quality, or the agent's overall task success—those are separate evaluation surfaces. This prompt is also inappropriate for agents that do not expose a reasoning trace, or for simple classification/routing models where tool use is a single-step decision without a chain-of-thought.

The primary constraint is that this prompt produces a structured justification quality score with specific flags, not a free-text critique. The output must be machine-readable to be wired into a CI/CD pipeline or an evaluation dashboard. The prompt is designed to catch three critical failure modes: missing rationale (the agent calls a tool with no explanation), tool-call mismatches (the justification describes one action but the arguments do something else), and unnecessary tool invocation (the agent calls a tool when the information is already present in the context or could be derived without an external call). Before integrating this prompt, ensure your evaluation dataset includes examples of each failure mode so you can calibrate the judge's sensitivity. If your agent operates in a high-stakes domain (finance, healthcare, legal), you must pair this automated evaluation with human spot-checks on a sample of flagged traces to prevent subtle justification failures from becoming systemic trust issues.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Tool-Use Justification in Reasoning Trace Prompt works and where it introduces risk. Use these cards to decide if this evaluation prompt fits your agent architecture before integrating it into your eval harness.

01

Good Fit: Agent Evaluation Pipelines

Use when: you are evaluating agent traces where tool calls are expected and must be justified. This prompt excels at grading whether the reasoning before a tool call explains why the tool is needed, what information is missing, and how the result will be used. Guardrail: Pair with a tool-call correctness evaluator to separate justification quality from tool selection accuracy.

02

Bad Fit: Non-Tool Workflows

Avoid when: the model is not calling tools or the reasoning trace is purely conversational. This prompt will flag missing tool justifications where none are expected, producing false negatives. Guardrail: Use a router to skip this evaluator when the trace contains zero tool calls, or gate it behind a tool-call presence check.

03

Required Input: Complete Reasoning Trace with Tool Schemas

Risk: Without the full reasoning trace and the tool definitions available to the agent, the judge cannot determine if a justification matches the tool's purpose. Guardrail: Always pass the agent's system prompt, tool schemas, and the complete trace including tool call arguments. Missing context produces unreliable scores.

04

Operational Risk: Latency-Sensitive Pipelines

Risk: Evaluating justification quality requires reading long reasoning traces and comparing them against tool definitions. This adds latency to your eval loop. Guardrail: Sample traces for justification review rather than running on every request. Use this evaluator in async batch evaluation, not in synchronous guardrails.

05

Operational Risk: Subjective Justification Standards

Risk: Different reviewers disagree on what counts as sufficient justification. Without clear anchors, the LLM judge drifts toward leniency or harshness. Guardrail: Calibrate the rubric with annotated examples showing minimum acceptable justification, over-justification, and missing rationale. Run inter-rater reliability checks weekly.

06

Bad Fit: Opaque Reasoning Models

Avoid when: the model does not expose its reasoning trace or only returns final tool calls. This prompt requires step-by-step reasoning to evaluate justification quality. Guardrail: If your model provider hides reasoning, use a tool-call outcome evaluator instead. This prompt only works when the reasoning surface is observable.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for grading whether tool calls in an agent reasoning trace are properly justified, with placeholders for your specific tools, trace format, and scoring rubric.

The following prompt template evaluates an agent's reasoning trace to determine whether each tool call is adequately justified. It checks for missing rationale, mismatches between stated intent and the tool actually called, and unnecessary tool invocations that could have been handled through reasoning alone. The template is designed to be dropped into an evaluation harness that feeds it agent traces and receives structured justification scores in return.

text
You are an evaluation judge grading the quality of tool-use justification in an agent reasoning trace. Your job is to assess whether each tool call in the trace is properly justified, not whether the tool call itself was correct.

## INPUT

[AGENT_REASONING_TRACE]

## AVAILABLE TOOLS

[TOOL_DEFINITIONS]

## EVALUATION CRITERIA

For each tool call in the trace, evaluate the following dimensions:

1. **Rationale Presence**: Does the reasoning trace contain an explicit justification for why this tool is being called before the call occurs? Score as PRESENT, PARTIAL, or ABSENT.

2. **Rationale-Tool Alignment**: Does the stated justification actually match the tool being called? Score as ALIGNED, MISALIGNED, or UNCLEAR. Flag MISALIGNED cases where the agent says it will call one tool but calls another, or where the justification describes an action the selected tool cannot perform.

3. **Necessity Assessment**: Is the tool call necessary given the stated goal and available information? Score as NECESSARY, REDUNDANT (same information already available), PREMATURE (could have reasoned further first), or UNNECESSARY (task achievable without any tool).

4. **Argument Justification**: Are the arguments passed to the tool explained in the reasoning trace? Score as JUSTIFIED (each argument's origin explained), PARTIAL (some arguments unexplained), or UNEXPLAINED (arguments appear without reasoning).

## OUTPUT SCHEMA

Return a JSON object with this exact structure:

{
  "trace_id": "string identifier from input",
  "overall_justification_score": number (1-5 scale where 1=no justification, 5=excellent justification throughout),
  "tool_call_evaluations": [
    {
      "call_index": number (position in trace, 0-based),
      "tool_name": "string",
      "rationale_presence": "PRESENT" | "PARTIAL" | "ABSENT",
      "rationale_tool_alignment": "ALIGNED" | "MISALIGNED" | "UNCLEAR",
      "necessity": "NECESSARY" | "REDUNDANT" | "PREMATURE" | "UNNECESSARY",
      "argument_justification": "JUSTIFIED" | "PARTIAL" | "UNEXPLAINED",
      "flags": ["string descriptions of specific issues found"],
      "justification_excerpt": "string quoting the relevant justification text, or 'No justification found'"
    }
  ],
  "summary_findings": {
    "total_tool_calls": number,
    "missing_rationale_count": number,
    "misaligned_count": number,
    "unnecessary_count": number,
    "critical_flags": ["string descriptions of issues requiring human review"]
  }
}

## SCORING RUBRIC

- **5**: Every tool call has clear, specific justification before invocation. All justifications align with the tool called. No unnecessary calls. All arguments explained.
- **4**: Most tool calls well-justified. Minor issues like slightly vague rationale or one partially explained argument.
- **3**: Mixed quality. Some calls well-justified, others missing rationale or have alignment issues. At least one unnecessary or redundant call.
- **2**: Majority of calls poorly justified. Multiple missing rationales, misalignments, or unnecessary invocations.
- **1**: No meaningful justification present. Tool calls appear arbitrary or completely disconnected from reasoning.

## CONSTRAINTS

- Evaluate justification quality only. Do not judge whether the tool call achieved the right outcome.
- If the trace contains no tool calls, return overall_justification_score as null and empty tool_call_evaluations array.
- Quote justification excerpts verbatim from the trace. Do not paraphrase.
- Flag for human review when: MISALIGNED calls, UNNECESSARY calls that could cause side effects, or any case where the agent's reasoning contradicts the tool call made.
- [ADDITIONAL_CONSTRAINTS]

To adapt this template for your evaluation pipeline, replace [AGENT_REASONING_TRACE] with the actual trace text from your agent runs. Populate [TOOL_DEFINITIONS] with your tool schemas so the judge can verify alignment between stated intent and tool capabilities. The [ADDITIONAL_CONSTRAINTS] placeholder lets you add domain-specific rules, such as requiring justification for write operations but not read operations, or flagging tool calls that access sensitive data without explicit rationale. Wire this prompt into an evaluation harness that parses the JSON output and routes critical flags to a human review queue. For high-stakes agent workflows where unjustified tool calls could cause financial or operational damage, run this evaluation before allowing the agent to execute tool calls in production.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Tool-Use Justification in Reasoning Trace Prompt. Each variable must be populated before the prompt is assembled and sent to the model. Missing or malformed inputs are the most common cause of low-quality justification scores.

PlaceholderPurposeExampleValidation Notes

[REASONING_TRACE]

The full step-by-step reasoning trace to evaluate, including all intermediate thoughts and final conclusion

Step 1: User asks for Q3 revenue. Step 2: I need to call get_financials. Step 3: Calling get_financials('Q3', 2024)...

Must be non-empty string. Minimum 50 characters. Should contain identifiable step boundaries. Reject if only final answer present without reasoning steps.

[TOOL_CALL_LOG]

Structured log of all tool invocations made during the reasoning trace, including function name, arguments, and return values

{"calls": [{"tool": "get_financials", "args": {"quarter": "Q3", "year": 2024}, "result": "$4.2M"}]}

Must be valid JSON array or object. Each call entry requires tool name, args, and result fields. Reject if tool names are missing or args are null without explicit justification.

[AVAILABLE_TOOLS_SCHEMA]

The complete tool manifest showing what tools were available to the model, including descriptions and parameter schemas

{"tools": [{"name": "get_financials", "description": "Retrieve financial data by quarter and year", "parameters": {"quarter": "string", "year": "integer"}}]}

Must be valid JSON matching the tool schema format used in the system prompt. Reject if empty array. Each tool must have name and description fields. Parameter schemas optional but recommended for full evaluation.

[TASK_CONTEXT]

The original user request or task that triggered the reasoning trace and tool calls

What was our Q3 2024 revenue for the North America segment?

Must be non-empty string. Should represent the actual task as received, not a summary. Include any constraints or specific requirements from the user. Reject if paraphrased beyond recognition.

[SYSTEM_INSTRUCTIONS]

The system prompt or behavioral policy active during the reasoning trace, including any tool-use rules or constraints

You are a financial analyst assistant. Always justify tool calls before invoking them. Do not call tools for information already in context.

Must be non-empty string. Critical for evaluating whether tool-use behavior violated explicit instructions. If no system prompt was used, set to empty string and note in evaluation that policy adherence cannot be checked.

[CONTEXT_WINDOW_STATE]

The conversation history and any retrieved context available to the model before the reasoning trace began

Previous turn: User asked about Q2 revenue. Assistant provided $3.8M from get_financials('Q2', 2024). Current context contains Q2 data.

Must be string or structured object. Include prior turns, retrieved documents, or memory state. Reject if context that was actually available is omitted. This is essential for detecting unnecessary tool calls when information already exists in context.

[OUTPUT_SCHEMA]

The expected output format for the justification evaluation, defining score fields, flag types, and required annotations

{"overall_score": "1-5", "flags": ["missing_rationale", "tool_call_mismatch", "unnecessary_invocation"], "per_call_evaluation": [{"tool": "string", "justification_present": "boolean", "justification_quality": "1-5"}]}

Must be valid JSON schema or structured description. Reject if output format is undefined. The evaluator prompt will produce output matching this schema, so field names must be consistent with downstream parsing code.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Tool-Use Justification in Reasoning Trace prompt into an evaluation pipeline with validation, retries, and human review gates.

This prompt is designed to operate as a model-graded evaluation step within a larger agent observability pipeline, not as a standalone chat interaction. The primary integration point is after an agent has produced a reasoning trace that includes one or more tool calls. Your application should extract the full reasoning trace and the list of tool invocations (with their arguments and results) from your agent execution logs or trace store. Feed these into the prompt as [REASONING_TRACE] and [TOOL_CALLS]. The prompt returns a structured JSON justification quality score and a list of per-call flags, which your harness should parse and log alongside the original trace for downstream analysis.

Validation and retry logic is critical because the output schema includes enum fields (justification_quality, flag_severity) and structured arrays. Implement a JSON schema validator in your harness that checks: (1) the top-level justification_quality field is present and matches one of the allowed enum values (adequate, partial, missing, mismatched), (2) the flags array contains objects with all required fields (tool_call_index, flag_type, severity, explanation), and (3) tool_call_index values are integers that correspond to actual tool calls in the input. If validation fails, retry once with the validation error message appended to the prompt as a [PREVIOUS_OUTPUT_ERROR] constraint. If the second attempt also fails validation, log the raw output and escalate to a human review queue rather than silently accepting a malformed evaluation.

Model choice and latency considerations matter here. This evaluation prompt requires careful reading of potentially long reasoning traces and cross-referencing them against tool call arguments. Use a model with strong instruction-following and long-context reasoning capabilities (such as Claude 3.5 Sonnet, GPT-4o, or Gemini 1.5 Pro). Avoid smaller or faster models that may hallucinate flag details or miss subtle justification mismatches. Because this is an offline evaluation step rather than a real-time user-facing interaction, latency tolerance is higher—batch processing of traces is acceptable. However, if you are evaluating traces at high volume, consider implementing a pre-filter that only runs this prompt on traces where tool calls were actually made, skipping traces with zero tool invocations to reduce cost.

Human review integration should be triggered by specific severity thresholds. Configure your harness to automatically escalate any trace where the justification_quality score is missing or mismatched, or where any individual flag has a severity of critical. These cases indicate that the agent either failed to explain why it used a tool or used a tool that contradicts its own reasoning—both are high-risk failure modes that warrant human inspection before the agent's behavior is considered acceptable. For partial scores with only low severity flags, you may choose to aggregate these into a weekly review batch rather than triggering immediate alerts.

Logging and observability should capture the full evaluation payload alongside the original trace. Store the justification quality score, the flag array, the model used for evaluation, the timestamp, and the trace ID in your evaluation database. This enables longitudinal analysis: you can track whether justification quality is improving or degrading across agent versions, identify which tool types most frequently lack justification, and correlate poor justification scores with downstream task failures. Wire these metrics into your existing monitoring dashboards so that justification quality becomes a tracked evaluation dimension alongside accuracy, latency, and cost.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape of the JSON object your evaluation harness should parse. Each field maps to a specific justification quality signal.

Field or ElementType or FormatRequiredValidation Rule

justification_score

integer (1-5)

Must be an integer between 1 and 5 inclusive. Parse check: reject floats or out-of-range values.

justification_quality_label

enum string

Must be one of: 'Excellent', 'Adequate', 'Partial', 'Missing', 'Not Applicable'. Schema check: reject unknown labels.

tool_call_id

string

Must match the exact ID of the tool call being evaluated. Null not allowed. Regex check: non-empty string.

rationale_present

boolean

Must be true or false. True if the trace contains an explicit 'why' statement for the tool call.

rationale_quote

string or null

If rationale_present is true, this must contain the verbatim justification text from the trace. If false, must be null.

tool_call_match

boolean

Must be true if the described tool and parameters match the actual tool call. False if there is a mismatch.

unnecessary_invocation_flag

boolean

Must be true if the evaluator determines the tool call was not needed to answer the user's request. False otherwise.

missing_rationale_flag

boolean

Must be true if a tool was called but no reasoning was provided in the trace. Must be false if rationale_present is true.

PRACTICAL GUARDRAILS

Common Failure Modes

Tool-use justification prompts break in predictable ways. These cards cover the most common failure modes when grading whether an agent's reasoning trace properly justifies its tool calls, along with concrete guardrails to catch each failure before it reaches production.

01

Post-Hoc Rationalization Instead of Genuine Justification

What to watch: The model fabricates plausible-sounding reasons for a tool call after the fact, rather than capturing the actual reasoning that led to the call. The justification reads like a lawyer defending a decision already made. Guardrail: Include explicit instructions to evaluate whether the justification references specific evidence or conditions that existed before the tool call. Flag justifications that use vague retroactive language like 'this was necessary because' without citing prior context.

02

Tool-Call Mismatch Where Justification Describes a Different Action

What to watch: The reasoning trace justifies calling Tool A, but the actual tool call invokes Tool B with arguments that don't match the stated intent. Common in multi-tool agents where the model confuses similar tools. Guardrail: Add a cross-reference check in your evaluation prompt that compares the tool name and arguments in the justification against the actual tool call payload. Require the judge to flag any semantic mismatch, not just syntactic differences.

03

Missing Justification for Critical Tool Calls

What to watch: The reasoning trace skips justification entirely for high-stakes tool calls—database writes, deletions, external API calls with side effects—while providing verbose justifications for low-risk read operations. Guardrail: Define a risk tier for each tool in your evaluation schema. Require the judge to verify that every tool call above a risk threshold has an explicit justification present. Flag silent high-risk calls as critical failures regardless of whether the call itself was correct.

04

Unnecessary Tool Invocation With Circular Justification

What to watch: The agent calls a tool it doesn't need, then justifies the call by claiming the tool's output was necessary—creating a circular logic loop. The justification essentially says 'I called this tool because I needed its result,' without explaining why the result was actually required. Guardrail: Instruct the judge to evaluate whether the justification explains the information gap the tool is meant to fill, not just the tool's purpose. Flag justifications that could apply equally to any tool call as insufficient.

05

Overconfidence in Tool Output Before the Call Completes

What to watch: The justification assumes the tool will return specific data or succeed, then uses that assumed result as part of the reasoning. When the tool fails or returns unexpected data, the entire reasoning chain collapses. Guardrail: Require the judge to check whether justifications treat tool outcomes as certain. Flag language like 'this will return' or 'we will get' when used as a premise for downstream reasoning. Valid justifications should express tool calls as information-gathering steps with uncertain outcomes.

06

Justification Drift Across Multi-Step Tool Sequences

What to watch: In agents that chain multiple tool calls, early justifications are coherent but later justifications lose connection to the original goal. The agent justifies each step in isolation without showing how it advances the overall task. Guardrail: Add a coherence dimension to your evaluation rubric that checks whether each justification references the original task goal or explains how the current step builds on prior tool outputs. Flag sequences where justifications become self-referential and lose task alignment.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test whether the Tool-Use Justification in Reasoning Trace Prompt produces reliable, actionable justification quality scores. Each criterion targets a specific failure mode observed in agent evaluation pipelines. Run these checks against a golden dataset of 20-50 reasoning traces with known tool-call justification quality before shipping the prompt to production.

CriterionPass StandardFailure SignalTest Method

Justification Presence Detection

Prompt correctly identifies missing justifications with recall >= 0.95 on golden dataset

Score assigned to a step with no justification text or empty rationale string

Run against 30 traces where 10 have deliberately removed justification fields; measure false negatives

Tool-Call Mismatch Flagging

Prompt flags mismatches where justification describes a different tool than the one called, with precision >= 0.90

Justification describes a search tool but the actual call is to a calculator; no mismatch flag raised

Inject 8 traces with deliberate tool-call mismatches; verify flag presence and correct mismatch identification

Unnecessary Tool Invocation Detection

Prompt correctly labels unnecessary tool calls with recall >= 0.85 and provides a reason

Tool call that could be answered from context receives a passing justification score

Curate 12 traces where 6 contain unnecessary tool calls (e.g., calling a calculator for known constants); measure detection rate

Justification Quality Score Calibration

Scores correlate with human ratings at Spearman rho >= 0.80 across the 1-5 scale

Prompt assigns score of 5 to a justification that says only 'needed data' with no reasoning

Have 3 human raters score 50 justifications; compare prompt scores to median human scores using rank correlation

Missing Rationale Depth Flag

Prompt flags justifications that state the tool choice but omit why the tool is needed, with recall >= 0.90

Justification 'I will use the API' passes without a depth warning

Create 10 traces with shallow justifications; verify depth flag fires on at least 9

False Positive Control on Valid Justifications

Prompt assigns score >= 4 to clearly valid justifications in >= 95% of cases

A thorough justification explaining tool choice, expected output, and fallback receives score <= 2

Select 15 traces with human-verified high-quality justifications; measure pass rate at score >= 4

Output Schema Compliance

Prompt output matches the defined JSON schema in 100% of test runs, including all required fields

Missing 'justification_quality_score' field or malformed 'flags' array in response

Run prompt 50 times across varied inputs; validate output against JSON Schema using a programmatic validator

Edge Case: No Tool Calls in Trace

Prompt returns appropriate null or empty assessment when reasoning trace contains zero tool calls

Prompt hallucinates tool-call justifications or assigns scores to non-existent calls

Feed 5 traces with no tool calls; verify output indicates no tool-use assessment applicable without fabricated scores

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single frontier model. Remove the [OUTPUT_SCHEMA] block and ask for plain-text justification scores with a simple 1–5 scale. Use a small hand-labeled set of 10–20 reasoning traces to eyeball whether the judge catches obvious missing justifications.

code
Rate each tool call's justification on a 1–5 scale.
1 = no justification
5 = full rationale with tool-call match

Watch for

  • The judge accepting vague rationales like "needed more info" as sufficient
  • No distinction between missing justification and mismatched justification
  • Score inflation on the first few runs before you calibrate
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.