This prompt is designed for agent developers and AI reliability engineers who need to isolate the root cause of a production agent failure when the automated evaluation score is below the threshold and the primary suspect is a planning error. The core job-to-be-done is to move beyond the surface-level eval score and pinpoint the exact planning step where the agent's internal task decomposition diverged from the required workflow. You should use this prompt when you have access to a structured execution trace that includes the agent's initial plan, its step-by-step actions, and the final output that was evaluated against a known rubric.
Prompt
Agent Planning Step Failure Eval Prompt

When to Use This Prompt
Diagnose eval failures caused by incorrect agent task decomposition or planning by analyzing the plan-vs-execution trace.
To use this effectively, you must provide the full evaluation rubric that defined the failure, the agent's complete execution trace (including its initial plan and any plan revisions), and the failing output. The prompt works by forcing a step-by-step comparison between the 'required plan' implied by the rubric and the 'executed plan' captured in the trace. It will produce a structured analysis that identifies the first point of divergence, explains the causal chain from that divergence to the final output failure, and recommends a specific corrective action, such as modifying a planning instruction in the system prompt or adding a verification step. Do not use this prompt if the execution trace is unavailable or incomplete, as the analysis will be speculative. It is also the wrong tool if the failure is clearly a simple tool-call argument error or if you suspect the LLM judge itself is misconfigured; for those scenarios, use the Tool-Call Error Correlation with Eval Failure Prompt or the LLM Judge Score Inconsistency Investigation Prompt instead.
Before running this analysis, verify that the trace contains step-level detail. A trace that only shows final input and output is insufficient. The prompt requires the agent's stated plan or reasoning before each action. If your agent framework does not log this, you will need to add that observability before this playbook becomes useful. The output of this prompt is a diagnostic artifact, not an automatic fix. The recommended corrective action should be treated as a strong hypothesis to be tested in a staging environment with a regression test suite before being deployed to production. For high-stakes agent workflows, always require a human to review the trace analysis and approve the corrective action before any prompt or code change is merged.
Use Case Fit
This prompt diagnoses why an agent's planning step failed an evaluation. It works best when you have a structured trace and a clear rubric. It is not a general debugging tool.
Good Fit: Structured Agent Traces
Use when: you have a complete trace showing the agent's initial plan, each execution step, and the final output. The prompt needs the plan and the reality side-by-side to produce a useful divergence analysis. Avoid when: you only have the final output and no intermediate planning trace.
Bad Fit: Uninstrumented Agents
Risk: the prompt cannot reconstruct planning decisions if the agent's internal reasoning was not logged. Guardrail: instrument your agent to emit a structured plan object before execution begins. Without this, the prompt will produce speculation, not diagnosis.
Required Inputs
What you must provide: the agent's original plan (step list with intents), the execution trace (tool calls, observations), the final output, and the eval rubric that failed. Guardrail: validate that all four inputs are present before invoking the prompt. Missing inputs produce unreliable root-cause hypotheses.
Operational Risk: Blast Radius
Risk: a single planning failure pattern may affect many sessions. Guardrail: after diagnosing one trace, run the same prompt across a sample of recent failures to determine if the root cause is systemic. Use the output to decide between a prompt fix, a planning constraint, or a tool contract change.
Not a Replacement for Execution Debugging
What to watch: this prompt isolates planning divergence, not tool-call errors, retrieval gaps, or format drift. Guardrail: if the plan was correct but execution failed, route the trace to the Tool-Call Error Correlation prompt instead. Use this prompt only when the plan itself was wrong or incomplete.
Human Review Threshold
Risk: the prompt may attribute failure to the wrong planning step if the trace is ambiguous. Guardrail: require human confirmation before applying a fix based on a single trace diagnosis. For high-severity eval failures, have a second reviewer validate the plan-vs-execution diff before accepting the root cause.
Copy-Ready Prompt Template
A copy-ready prompt for diagnosing why an agent's planning step failed an evaluation, producing a structured plan-vs-execution trace analysis.
This prompt template is designed to be pasted directly into your investigation workflow. It instructs the model to act as a diagnostic engine, comparing the agent's intended plan against its actual execution trace to pinpoint the root cause of an evaluation failure. The goal is to produce a structured, evidence-backed analysis that connects a planning divergence to a specific eval rubric violation, moving beyond surface-level output critique.
textYou are an AI reliability engineer diagnosing an agent evaluation failure. Your task is to analyze the provided trace data and determine why the agent's planning step caused the final output to fail its evaluation. [CONTEXT] - Task Description: [TASK_DESCRIPTION] - Eval Rubric: [EVAL_RUBRIC] - Eval Failure Reason: [EVAL_FAILURE_REASON] [TRACE_DATA] - Agent's Initial Plan (from planning step): [INITIAL_PLAN] - Agent's Execution Trace (tool calls, observations, plan revisions): [EXECUTION_TRACE] - Agent's Final Output: [FINAL_OUTPUT] [OUTPUT_SCHEMA] Produce a JSON object with the following structure: { "plan_vs_execution_summary": "A one-sentence summary of the core divergence.", "root_cause_analysis": { "divergence_point": "The exact step in the execution trace where the agent deviated from the required plan.", "missing_or_incorrect_step": "The specific planned step that was skipped, hallucinated, or executed incorrectly.", "causal_link_to_eval_failure": "A clear explanation of how this divergence directly caused the eval failure described in the context.", "evidence_from_trace": "A direct quote or log line from the execution trace that proves the divergence." }, "severity_assessment": "Critical | High | Medium | Low", "recommended_remediation": "A concrete suggestion for a prompt, tool, or policy change to prevent this failure in the future." } [CONSTRAINTS] - Base your analysis strictly on the provided trace data. Do not invent facts. - If the trace data is insufficient to determine a root cause, set the root_cause_analysis to null and explain why in the plan_vs_execution_summary. - The causal_link_to_eval_failure must explicitly reference the eval rubric and failure reason.
To adapt this template, replace the square-bracket placeholders with data from your production trace and evaluation systems. The [EVAL_RUBRIC] and [EVAL_FAILURE_REASON] fields are critical for grounding the analysis. If your trace format differs, adjust the [TRACE_DATA] section to match your logging schema. For high-stakes applications, always pair this automated analysis with a human review of the root_cause_analysis before implementing the recommended_remediation.
Prompt Variables
Required inputs for the Agent Planning Step Failure Eval Prompt. Each placeholder must be populated from production trace data before the prompt is assembled. Missing or malformed variables will cause the eval to produce unreliable root-cause hypotheses.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[PLAN_TRACE] | The agent's planned steps as recorded in the trace, including step descriptions, ordering, and dependencies | Step 1: Fetch customer account. Step 2: Check recent orders. Step 3: Calculate refund eligibility. Step 4: Draft response. | Must be a non-empty array or ordered list. Validate that each step has a description and that step count matches the trace metadata. Reject if plan is truncated or missing steps. |
[EXECUTION_TRACE] | The actual execution log showing which steps ran, their outcomes, tool calls, and any deviations from the plan | Step 1 completed. Step 2 tool call to orders_api returned empty. Step 3 skipped. Step 4 generated without refund calculation. | Must contain step-level events with timestamps and status fields. Validate that execution events can be mapped to plan steps. Reject if execution log is empty or contains only final output without intermediate steps. |
[EVAL_RUBRIC] | The evaluation rubric that the final output failed, including the specific criteria, thresholds, and failure dimensions | Criterion: Refund accuracy. Threshold: Must cite refund policy and calculate amount. Failure: Response stated refund was available but did not calculate amount or cite policy. | Must include at least one failed criterion with its pass standard and observed failure. Validate that rubric fields are structured and that failure dimensions are explicitly linked to output requirements. Reject if rubric is generic or lacks specific failure conditions. |
[FINAL_OUTPUT] | The agent's final response that failed evaluation, exactly as delivered to the user or downstream system | Your refund has been approved. A credit of $47.50 will be applied to your account within 3-5 business days. | Must be the exact output string from the trace. Validate that the output matches the trace's final response event. Reject if output has been post-processed or truncated before analysis. |
[EXPECTED_OUTPUT] | The expected correct output or golden answer that would have passed the eval rubric | Based on order #88214 for Widget Pro returned on 2025-01-12, your refund is $47.50 per our 30-day return policy. Credit will appear in 3-5 business days. | Must be a complete expected response. Validate that the expected output satisfies all eval rubric criteria. Reject if expected output is missing required fields or citations that the rubric demands. |
[TOOL_CALL_LOG] | Complete log of all tool calls made during execution, including function names, arguments, responses, and error codes | Tool: get_order_details. Args: {order_id: 88214}. Response: {status: returned, date: 2025-01-12, amount: 47.50}. Tool: get_refund_policy. Error: timeout after 2000ms. | Must include all tool calls with full argument and response payloads. Validate that tool call count matches execution trace. Reject if tool responses are redacted or if error codes are missing for failed calls. |
[CONTEXT_WINDOW_SNAPSHOT] | The full context window contents at the point where the planning or execution divergence occurred | System prompt (truncated at 800 tokens), user message, retrieved policy doc (partial), order details, conversation history (last 3 turns) | Must capture the exact context state at the divergence point. Validate that snapshot includes system prompt, retrieved context, and conversation history. Reject if snapshot is from a different trace step or if context was reconstructed rather than captured. |
[MODEL_CONFIG] | The model name, version, temperature, and any sampling parameters active during the failed execution | Model: claude-sonnet-4-20250514. Temperature: 0.3. Max tokens: 4096. Top-p: 0.9. | Must include model identifier and key sampling parameters. Validate that model config matches the trace metadata. Reject if config is from a different request or if model version is unspecified. |
Implementation Harness Notes
How to wire the Agent Planning Step Failure Eval Prompt into an automated investigation pipeline with validation, retries, and human review gates.
This prompt is designed to be the analytical core of an automated eval failure investigation workflow, not a one-off debugging tool. The harness should receive a structured input payload containing the failed eval rubric, the agent's final output, and the full execution trace. The prompt's output—a plan-vs-execution divergence report—should be parsed as structured JSON and fed into downstream systems: ticketing, alerting, or a human review queue. Because this analysis is used to decide whether to roll back a prompt version or update agent planning logic, the harness must enforce strict validation on both the input and output schemas before any action is taken.
Wire the prompt into an application by building a dedicated investigation service. This service should: (1) Accept a webhook or queue message containing an eval failure event with a trace ID. (2) Fetch the full trace, eval rubric, and model output from your observability store. (3) Assemble the prompt with the [TRACE_JSON], [EVAL_RUBRIC], [FINAL_OUTPUT], and [PLANNING_INSTRUCTIONS] placeholders. (4) Call a capable reasoning model (e.g., Claude 3.5 Sonnet or GPT-4o) with response_format set to a JSON schema matching the expected output. (5) Validate the returned JSON against the schema. If validation fails, retry once with a repair prompt that includes the validation error. If it fails again, escalate to a human analyst with the raw trace. (6) On success, write the structured divergence report to your investigation database and check the divergence_severity field: critical or high findings should automatically create a ticket and notify the agent development team. medium findings can be batched for weekly review. low or none findings should be logged for trend analysis but require no immediate action.
The highest-risk failure mode in this harness is acting on an incorrect analysis. A hallucinated divergence report could trigger an unnecessary prompt rollback or, worse, mask a real planning defect. Mitigate this by requiring human review for any critical severity finding before a rollback is executed. Additionally, log the raw prompt, model response, and validation result for every investigation. This audit trail is essential for debugging the investigation pipeline itself and for demonstrating due diligence during incident postmortems. Do not use a cheap or fast model for this task; the reasoning required to correlate plan steps with trace events demands a frontier model. Finally, ensure your trace data includes step-level timestamps and tool-call arguments—without this granularity, the prompt cannot produce a reliable divergence analysis.
Expected Output Contract
Fields, types, and validation rules for the plan-vs-execution trace analysis output. Use this contract to parse, validate, and store the structured diagnosis before routing to a human reviewer or downstream system.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
plan_steps | Array of objects | Must contain at least 1 step. Each object must have 'step_id', 'intended_action', and 'expected_outcome' fields. | |
execution_trace | Array of objects | Must contain at least 1 trace event. Each object must have 'event_id', 'action_taken', 'actual_outcome', and 'timestamp' fields. | |
divergence_points | Array of objects | Each object must include 'step_id', 'trace_event_id', 'divergence_type' (enum: skipped, reordered, substituted, added, malformed), and 'description'. | |
eval_failure_mapping | Array of objects | Each object must map a divergence to an eval dimension using 'divergence_index', 'eval_dimension', and 'failure_contribution' (enum: primary, contributing, incidental). | |
root_cause_classification | String | Must be one of: planning_error, tool_error, context_error, instruction_ambiguity, model_capability_gap, unknown. If unknown, 'confidence' must be below 0.6. | |
confidence | Number | Float between 0.0 and 1.0. If below 0.7, the 'requires_human_review' field must be true. | |
requires_human_review | Boolean | Must be true if confidence < 0.7, root_cause is unknown, or any divergence_type is malformed. | |
evidence_citations | Array of strings | Each citation must reference a specific trace event ID or log line. Null or empty array triggers a validation failure. |
Common Failure Modes
When diagnosing agent planning failures, these failure modes surface most often. Each card identifies a specific breakage pattern and the guardrail that catches it before it reaches production.
Plan Skips Required Step
What to watch: The agent's plan omits a mandatory step defined in the task specification, causing downstream eval failure. This often happens when the model optimizes for brevity or misjudges step necessity. Guardrail: Compare the generated plan against a required-step checklist extracted from the task definition. Flag any plan missing a required step before execution begins.
Step Ordering Breaks Dependencies
What to watch: The agent sequences steps in an order that violates data or logical dependencies, such as summarizing before retrieving or validating after acting. Guardrail: Parse the plan into a dependency graph and check that each step's prerequisites appear earlier in the sequence. Reject plans with circular or reversed dependencies.
Plan Ignores Tool Availability
What to watch: The agent plans to use a tool that does not exist in the current environment, or assumes capabilities beyond what the tool contract provides. Guardrail: Validate every tool reference in the plan against the active tool manifest. Substitute missing tools with available alternatives or escalate before execution.
Ambiguous Step Definitions Cause Drift
What to watch: Vague plan steps like 'analyze the data' or 'handle the error' give the executor too much latitude, leading to outputs that diverge from eval expectations. Guardrail: Require each plan step to specify the action, input source, expected output shape, and success condition. Reject plans with unverifiable steps.
Plan Fails to Recover from Mid-Execution Errors
What to watch: The plan assumes every step succeeds and provides no fallback or retry logic. When a tool call fails or returns unexpected data, the agent either halts or continues with corrupted state. Guardrail: Require plans to include error-handling branches for each fallible step. Validate that the plan specifies what to do on timeout, empty result, or permission denial.
Context Window Overflow Mid-Plan
What to watch: The plan accumulates intermediate results that exceed the context window, causing silent truncation of earlier evidence or instructions before the final output is generated. Guardrail: Estimate token consumption per step and enforce a context budget. Insert summarization or evidence-pruning steps before the budget is exhausted.
Evaluation Rubric
Use this rubric to test the quality of the Agent Planning Step Failure Eval Prompt's output before relying on it in production. Each criterion maps to a concrete pass standard, failure signal, and test method.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Plan Step Identification | All agent-planned steps are extracted and numbered from the trace | Missing steps or steps listed out of execution order | Parse output for step count vs. trace tool-call log; verify sequence matches timestamps |
Required Step Mapping | Each required step from [EXPECTED_PLAN] is mapped to an executed step or flagged as missing | Required step present in plan but absent from mapping without a MISSING flag | Diff [EXPECTED_PLAN] list against mapped steps; confirm every required step appears in mapping or MISSING column |
Divergence Point Detection | First step where executed plan diverges from required plan is identified with trace event ID | Divergence point attributed to wrong step or no trace event ID provided | Cross-reference divergence step number with trace event log; verify event ID exists in source trace |
Root-Cause Classification | Divergence is classified into one of: TOOL_ERROR, PLANNING_HALLUCINATION, CONTEXT_LOSS, PREMATURE_COMPLETION, or OTHER | Classification missing, ambiguous, or uses category not in allowed set | Validate classification field against allowed enum; reject if classification rationale contradicts trace evidence |
Downstream Impact Chain | Each subsequent eval failure dimension is linked to the divergence point with causal explanation | Eval failures listed without trace linkage or causation asserted without evidence | Trace each linked failure back to divergence event; confirm causal chain is supported by trace state changes |
Eval Dimension Attribution | Output maps each failed eval dimension to the specific plan step that caused it | Eval dimensions attributed to wrong step or attribution missing for failed dimensions | Cross-reference [FAILED_EVAL_DIMENSIONS] input against attribution map; verify all failed dimensions have a step attribution |
Evidence Citation | Every claim about plan behavior includes a trace event ID or log line reference | Claims about agent behavior lack trace references or cite events not in provided trace | Regex-check output for event ID patterns; validate each cited ID exists in [TRACE_DATA] input |
Recovery Recommendation | Output includes one actionable recommendation per divergence point with expected impact on eval score | Recommendations are generic, missing, or lack connection to specific divergence | Human review: verify each recommendation addresses the classified root cause and includes a testable expected outcome |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

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

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Add a strict JSON output schema, require step-by-step trace-to-eval mapping, include confidence scores per finding, and log the analysis for regression comparison. Wire the prompt into an automated investigation pipeline triggered by eval score drops.
Prompt snippet
codeAnalyze the agent trace and eval failure. For each required step in [PLAN_SCHEMA], compare the planned action against the executed action in [TRACE_JSON]. Flag any divergence and link it to the specific eval dimension it violated in [EVAL_RUBRIC]. Return JSON matching [OUTPUT_SCHEMA] with fields: step_id, planned_action, executed_action, divergence_type, impacted_eval_dimension, evidence_trace_segment, confidence_score.
Watch for
- Silent format drift in JSON output under high trace volumes
- Missing human review for severity=critical findings
- Confidence scores that are consistently overconfident

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