Inferensys

Prompt

Preference Selection Prompt for Tool-Use Sequences

A practical prompt playbook for using Preference Selection Prompt for Tool-Use Sequences 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

Understand the core job-to-be-done, the ideal user, and the specific conditions under which this prompt provides reliable value.

This prompt is designed for agent platform teams who need to make a relative quality judgment between two tool-call sequences. The core job-to-be-done is not to assign an absolute score, but to force a preference decision based on concrete, observable criteria: tool selection correctness, argument accuracy, call ordering logic, and appropriate abstention. The ideal user is an ML engineer, an evaluation lead, or a developer running a champion-challenger test, tuning agent behavior, or curating preference data for fine-tuning. You should use this prompt when you have two complete execution traces from different models, configurations, or prompt versions and you need to know which one is better for a specific task.

The prompt is most effective when integrated into a structured comparison harness. For example, you might be comparing a new gpt-4o agent configuration against a production claude-sonnet-4 baseline on a set of 200 customer service tasks. Instead of manually reviewing logs, you feed each pair of tool-call sequences into this prompt. The output is a structured JSON verdict that tells you which sequence won, why it won, and a confidence score. This data can then be aggregated to produce a statistically significant win/loss/tie report. The prompt requires both sequences to be provided with full argument payloads and execution context; it cannot infer what a tool does from its name alone.

Do not use this prompt when you need an absolute quality score for a single sequence, as it is calibrated for relative comparison. It is also unsuitable if only one sequence is available, if the task does not involve tool calls, or if the sequences are incomplete. Avoid using it as a standalone quality gate without human calibration; always validate a sample of preference judgments against human expert ratings to detect judge bias or systematic errors. The next step after reading this section is to review the prompt template and understand the exact input schema required to produce a reliable preference verdict.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Preference Selection Prompt for Tool-Use Sequences delivers reliable signal and where it breaks down. Use these cards to decide if this prompt fits your evaluation pipeline before investing in harness integration.

01

Good Fit: Agent Platform Regression Testing

Use when: You are comparing tool-call sequences from a new model or prompt version against a known-good baseline across a fixed test suite. Why it works: The prompt evaluates structured actions (tool name, arguments, ordering) against a specification, producing repeatable preference labels for CI/CD gates.

02

Bad Fit: Open-Ended Agent Exploration

Avoid when: The agent is exploring an unfamiliar environment where no correct tool sequence exists. Why it fails: The prompt requires a reference expectation or ground-truth action trace. Without a spec, preference becomes subjective and the judge hallucinates correctness criteria.

03

Required Inputs: Execution Trace and Tool Schema

What you must provide: A complete tool-call sequence (function name, arguments, timestamps, results) from each model, plus the tool schema with parameter contracts. Guardrail: Validate traces are complete before evaluation. Missing intermediate calls or truncated arguments produce false preference signals.

04

Operational Risk: Tool Schema Drift

What to watch: Tool APIs change, parameters get renamed, and new tools are added. Guardrail: Version-lock your tool schemas in the evaluation harness and fail closed when the schema version doesn't match the trace. A preference based on stale schemas is worse than no preference at all.

05

Operational Risk: Position Bias in Pairwise Judging

What to watch: LLM judges systematically favor the first or second candidate regardless of quality. Guardrail: Run every comparison twice with swapped positions and require consistent preference before accepting the label. Flag inconsistent pairs for human review.

06

Bad Fit: Single-Model Debugging Sessions

Avoid when: You are interactively debugging why one model chose the wrong tool. Why it fails: Pairwise preference requires two complete traces. For single-model diagnosis, use a tool-use evaluation rubric with absolute scoring instead of relative comparison.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for comparing tool-use sequences and selecting the preferred execution trace based on correctness, ordering, and safety.

This prompt template is designed for agent platform teams who need to evaluate and compare tool-call sequences from different models or configurations. It produces a structured preference verdict based on tool selection correctness, argument accuracy, call ordering, and appropriate abstention. The template uses square-bracket placeholders that you replace with real data before sending it to the judge model. This prompt is particularly useful for champion-challenger testing, RLHF data pipeline generation, and model selection workflows where relative quality of tool-use matters more than absolute scores.

text
You are an expert evaluator of AI agent tool-use sequences. Your task is to compare two tool-call traces and select the preferred one based on correctness, efficiency, and safety.

## Evaluation Criteria (in priority order)
1. **Tool Selection Correctness**: Did the agent choose the right tools for the task? Incorrect tool selection is a critical failure.
2. **Argument Accuracy**: Are the arguments passed to each tool correct, complete, and well-typed? Missing required arguments or hallucinated values are serious errors.
3. **Call Ordering**: Is the sequence of tool calls logical and efficient? Unnecessary calls, redundant operations, or incorrect ordering reduce preference.
4. **Appropriate Abstention**: Did the agent correctly abstain from calling tools when it lacked sufficient information or when no tool was appropriate? Unnecessary tool calls are worse than correct abstention.
5. **Error Handling**: If errors occurred, did the agent handle them gracefully with retries, fallbacks, or appropriate escalation?

## Inputs
**User Request**: [USER_REQUEST]

**Available Tools** (name, description, parameters):
[AVAILABLE_TOOLS]

**Execution Context** (system state, previous turns, constraints):
[EXECUTION_CONTEXT]

**Trace A** (model: [MODEL_A_ID]):
[TRACE_A]

**Trace B** (model: [MODEL_B_ID]):
[TRACE_B]

## Output Format
Return a JSON object with the following structure:
{
  "preferred_trace": "A" | "B" | "TIE",
  "confidence": 0.0-1.0,
  "justification": {
    "tool_selection": "Explanation of which trace had better tool selection",
    "argument_accuracy": "Explanation of argument quality differences",
    "call_ordering": "Explanation of sequence efficiency differences",
    "abstention_handling": "Explanation of abstention appropriateness",
    "error_handling": "Explanation of error recovery quality"
  },
  "key_differentiators": ["List of 1-3 specific factors that determined the preference"],
  "critical_failures": {
    "trace_a": ["List of critical failures in Trace A, if any"],
    "trace_b": ["List of critical failures in Trace B, if any"]
  }
}

## Constraints
- If both traces have critical failures, you may still express a preference based on severity, but confidence should be low.
- If both traces are functionally identical, return "TIE" with confidence reflecting your certainty about the tie.
- Do not let trace length or verbosity influence your judgment; focus on correctness and efficiency.
- If one trace correctly abstains and the other makes incorrect tool calls, strongly prefer the abstaining trace.
- Ignore model identity; evaluate only the traces as presented.

## Evaluation
Compare the two traces against the user request, available tools, and execution context. Provide your structured assessment.

To adapt this template for your evaluation pipeline, replace each square-bracket placeholder with real data before sending it to the judge model. The [USER_REQUEST] should contain the original task or query that triggered the tool-use sequence. The [AVAILABLE_TOOLS] placeholder expects a structured description of each tool's name, purpose, and parameter schema—this is critical for the judge to assess whether the correct tools were selected. The [EXECUTION_CONTEXT] should include any relevant system state, conversation history, or environmental constraints that affect tool selection decisions. For the traces, include the complete sequence of tool calls with arguments and return values for each model being compared. The [MODEL_A_ID] and [MODEL_B_ID] placeholders help with logging but should not influence the judge's decision. After adapting the template, validate that your tool descriptions are complete enough for the judge to make accurate assessments—missing parameter documentation will lead to unreliable preference labels. For high-stakes evaluation pipelines, run this prompt with multiple judge models and compare agreement rates before trusting the output.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Preference Selection Prompt for Tool-Use Sequences. Each placeholder must be populated before the prompt is assembled. Validation notes describe how to verify the input is well-formed before sending it to the model.

PlaceholderPurposeExampleValidation Notes

[TOOL_CATALOG]

Defines the set of available tools with their schemas, descriptions, and parameter contracts

search_database(query: str, filters: dict), send_email(to: str, subject: str, body: str)

Schema parse check: each tool must have a name, description, and typed parameter list. Reject if any tool lacks required fields or has duplicate names.

[SEQUENCE_A]

First tool-call sequence to compare, produced by model or configuration A

[{tool: search_database, args: {query: active users, filters: {status: active}}, timestamp: 0}, {tool: send_email, args: {to: admin@corp.com, subject: Report, body: Found 42 users}}, timestamp: 1}]

Schema parse check: each step must have tool, args, and timestamp fields. Tool name must exist in [TOOL_CATALOG]. Args must match the tool's parameter schema. Reject if sequence is empty or contains undefined tools.

[SEQUENCE_B]

Second tool-call sequence to compare, produced by model or configuration B

[{tool: send_email, args: {to: admin@corp.com, subject: Report, body: Querying users...}, timestamp: 0}, {tool: search_database, args: {query: active users, filters: {}}, timestamp: 1}]

Schema parse check: same validation as [SEQUENCE_A]. Reject if sequence is empty. Both sequences must be valid before comparison begins.

[USER_GOAL]

Natural language description of what the user or system intended to accomplish

Find all active users in the database and email a summary report to admin@corp.com

Non-empty string check. Must describe a concrete task, not a vague intent. Reject if under 10 characters or purely generic like 'do something useful'.

[EXECUTION_CONTEXT]

Optional runtime constraints, environment state, or policy rules that affect tool-use validity

JSON parse check. Null allowed if no context constraints exist. If provided, must be a valid object. Check that allowed_recipients is an array if present.

[PREFERENCE_CRITERIA]

Weighted dimensions for judging preference: tool_selection, argument_accuracy, call_ordering, abstention_appropriateness, efficiency

{tool_selection: 0.35, argument_accuracy: 0.30, call_ordering: 0.20, abstention_appropriateness: 0.10, efficiency: 0.05}

Schema check: must be a JSON object with numeric weights summing to 1.0 within 0.01 tolerance. All five keys must be present. Reject if any weight is negative or exceeds 1.0.

[OUTPUT_SCHEMA]

Expected JSON structure for the preference verdict

{preferred_sequence: A|B|tie, confidence: 0.0-1.0, justification: {tool_selection: str, argument_accuracy: str, call_ordering: str, abstention: str, efficiency: str}, key_differentiators: [str]}

Schema parse check: must be valid JSON schema. Reject if preferred_sequence enum is missing A, B, or tie. Confidence must be a number field with minimum 0 and maximum 1.

[POSITION_BIAS_MITIGATION]

Flag indicating whether to swap sequence positions and re-evaluate to detect position bias

Boolean check: must be true or false. If true, the harness must run two evaluations with swapped positions and flag disagreements. If false, accept single evaluation but log the risk.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the preference selection prompt into an agent evaluation pipeline with validation, retries, and execution-trace checks.

This prompt is designed to sit inside an automated evaluation harness that compares tool-use sequences from two different agent configurations. The harness must supply the full execution trace—including tool names, arguments, call order, and any error responses—for both sequences. Before calling the LLM judge, validate that both traces are parseable and contain at least one tool call. If either trace is empty or malformed, skip the comparison and log a data-quality failure. The prompt expects structured input fields for [TRACE_A] and [TRACE_B], each containing a JSON array of tool-call objects with tool_name, arguments, timestamp, and result keys. Position bias is a known failure mode in pairwise comparison, so randomize whether Trace A or Trace B appears first in the prompt on each evaluation run and record the assignment for later analysis.

Wire the prompt into your evaluation pipeline as a post-execution step. After both agent configurations have completed the same task, capture their full tool-call sequences and pass them to this prompt. Parse the JSON output to extract the preferred_trace field (A, B, or tie), the confidence score, and the structured reasons object. Implement a validation layer that rejects malformed JSON, missing required fields, or confidence scores outside the 0-1 range. For high-stakes comparisons—such as champion-challenger model testing or RLHF data generation—add a second-pass verification: if confidence is below 0.7 or the verdict is tie, route the pair to a human reviewer or a more capable judge model. Log every comparison result with the randomized position assignment, both traces, the judge's verdict, and the confidence score. This log becomes your audit trail for detecting judge drift, position bias, or systematic preference patterns over time.

Model choice matters for this workflow. Use a model with strong instruction-following and structured output capabilities—GPT-4o, Claude 3.5 Sonnet, or equivalent. Avoid smaller models that may struggle with the multi-dimensional reasoning required to compare tool-call sequences across correctness, argument accuracy, ordering, and abstention simultaneously. Set temperature=0 for deterministic verdicts in automated pipelines. If you need calibrated confidence scores, run a calibration study comparing the judge's confidence against human preference agreement on at least 50 labeled pairs before trusting the scores in production. Implement a retry strategy for transient failures: if the output fails JSON parsing, retry once with the same input. If it fails twice, log the failure and escalate. Never silently accept an unparseable preference verdict—downstream systems that consume these labels will propagate the error into training data or model selection decisions.

IMPLEMENTATION TABLE

Expected Output Contract

Defines the required fields, types, and validation rules for the preference selection output. Use this contract to parse, validate, and store the model's response before passing it downstream.

Field or ElementType or FormatRequiredValidation Rule

preference_verdict

string enum: ["A", "B", "tie"]

Must be exactly one of the three allowed values. Reject any other string.

justification

string

Must be non-empty and contain at least one specific reference to a tool call, argument, or sequence step from the trace. Reject generic justifications.

confidence_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive. Reject if out of range or not parseable as a number.

key_differentiators

array of strings

Must contain 1-3 items. Each string must be non-empty and reference a concrete difference in tool selection, argument accuracy, or call ordering.

tool_selection_accuracy

object

Must contain 'A' and 'B' keys with boolean values. Reject if keys are missing or values are not true/false.

argument_accuracy

object

Must contain 'A' and 'B' keys with values between 0.0 and 1.0. Reject if out of range or missing keys.

call_ordering_valid

object

Must contain 'A' and 'B' keys with boolean values. Reject if keys are missing or values are not true/false.

abstention_appropriate

object

Must contain 'A' and 'B' keys with string enum values: ["correct", "incorrect", "not_applicable"]. Reject any other value.

PRACTICAL GUARDRAILS

Common Failure Modes

When evaluating tool-use sequences, these failures break production pipelines first. Each card pairs a common failure with a concrete guardrail you can implement before shipping.

01

Position Bias Skews Preference

What to watch: The judge consistently prefers the first tool-call sequence presented, regardless of actual quality. This is especially common when sequences are long or differences are subtle. Guardrail: Randomize sequence order for every comparison pair and run each pair twice with swapped positions. Flag comparisons where the preference flips as low-confidence and escalate to human review.

02

Argument Hallucination in Tool Calls

What to watch: The judge fails to detect that a tool-call argument was fabricated—such as an order ID that doesn't exist or a date range pulled from thin air. The preference verdict rewards confident hallucination over cautious abstention. Guardrail: Cross-reference tool-call arguments against the provided execution trace or ground-truth context before scoring. Add a dedicated hallucination check that overrides the preference if fabricated arguments are detected.

03

Call Ordering Errors Go Unnoticed

What to watch: The judge evaluates individual tool calls in isolation and misses that the sequence calls cancel_order before create_order, or queries a resource before it exists. The preference verdict looks correct per-call but wrong per-sequence. Guardrail: Include explicit ordering constraints in the evaluation rubric. Require the judge to produce a dependency graph check before assigning preference, and flag any sequence with violated preconditions.

04

Abstention Penalty Drives Over-Confidence

What to watch: The judge penalizes sequences that correctly abstain from calling a tool when information is missing, and rewards sequences that guess. This trains models toward dangerous over-confidence in production. Guardrail: Add an abstention-appropriateness dimension to the rubric with positive scoring for correct abstention. Weight abstention correctness higher than task completion in safety-critical tool categories.

05

Tool Selection Confusion Under Similar Names

What to watch: The judge cannot distinguish between get_user_by_email and get_user_by_id when both are available, or between update_record and patch_record. Preference is assigned based on output similarity rather than tool contract correctness. Guardrail: Require the judge to extract and compare the exact tool name, not just the functional outcome. Include a tool-signature match check that validates the selected tool against the available tool list before scoring.

06

Execution Trace Mismatch with Preference

What to watch: The judge assigns a preference verdict that contradicts the execution trace—preferring a sequence that produced errors, timeouts, or empty results over one that executed cleanly. The judge prioritizes fluent reasoning over ground-truth outcomes. Guardrail: Anchor the preference decision to execution-trace outcomes first, reasoning second. Implement a trace-verdict consistency check that flags any preference where the winning sequence had worse execution results than the losing sequence.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test whether the preference selection prompt reliably identifies the better tool-use sequence. Each criterion targets a specific failure mode in agent tool-call evaluation. Run these checks against a calibration set of 20-50 labeled pairs before shipping.

CriterionPass StandardFailure SignalTest Method

Tool Selection Correctness

Preference matches ground-truth label for which sequence chose the correct tools in >=90% of calibration pairs

Judge prefers a sequence that used a wrong or hallucinated tool over one that selected the correct tool

Run against 50 labeled pairs where one sequence has a known tool-selection error; measure agreement rate

Argument Accuracy

Judge correctly penalizes incorrect parameter values even when tool choice is correct in >=85% of pairs

Judge prefers a sequence with correct tool but wrong arguments over a sequence with correct tool and correct arguments

Inject 20 pairs with deliberate argument errors (wrong IDs, missing required fields); verify judge detects the error

Call Ordering Correctness

Judge identifies correct dependency ordering (e.g., create before update) in >=90% of sequential tool-use pairs

Judge prefers a sequence that calls tools in wrong order over one with correct ordering, or marks tie when ordering difference is material

Test with 15 pairs where ordering is the only difference; confirm judge's preference aligns with execution dependency graph

Appropriate Abstention

Judge prefers a sequence that correctly abstains from calling a tool when preconditions are not met in >=85% of pairs

Judge penalizes correct abstention or prefers a sequence that makes an unsafe tool call over one that correctly abstains

Use 10 pairs where one sequence correctly returns no tool call; verify judge does not penalize valid abstention

Position Bias Resistance

Preference distribution remains within 5% of baseline when winning sequence position is swapped

Judge shows >10% preference shift toward first or second position regardless of actual quality

Run same 30 pairs with positions swapped; measure preference flip rate; flag if >15% of verdicts change

Confidence Calibration

Judge assigns confidence >=0.7 for clear wins and <=0.5 for genuine ties or ambiguous cases

Judge assigns high confidence (>0.8) to incorrect preferences or low confidence (<0.3) to obvious wins

Compare judge confidence scores against human agreement rates on 25 pairs; compute expected calibration error

Execution Trace Consistency

Judge's preference aligns with actual execution success when both sequences are run in a sandbox

Judge prefers a sequence that fails at runtime (timeout, auth error, invalid response) over one that executes successfully

Execute both sequences in sandbox for 15 pairs; compare judge preference to execution outcome; flag mismatches

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base preference prompt and a small set of tool-call traces. Use a single frontier model as judge. Skip position bias mitigation initially. Focus on getting the preference verdict and justification structure right before adding calibration harness.

Simplify the output schema to: preferred_trace, reasoning, and confidence (low/medium/high). Don't require execution-trace validation yet.

Prompt modification

Remove [EXECUTION_VALIDATION_HARNESS] and [POSITION_BIAS_CONTROLS] placeholders. Replace [CALIBRATION_PAIRS] with a note: "No calibration pairs used in prototype."

Watch for

  • Position bias skewing results toward first trace
  • Judge overconfidence on ambiguous tool sequences
  • Missing justification when both traces are equally valid
  • No baseline human agreement rate to calibrate against
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.