This prompt is designed for a specific, high-risk moment in an agent loop: the transition between planning and execution. After an agent has decomposed a task into sub-goals and selected a sequence of tool calls, but before it commits to executing them, this prompt acts as a structured verification gate. Its primary job is to detect and flag hallucinated capabilities, fabricated observations, and unsupported planning premises that the agent may have invented during its reasoning process. The ideal user is an AI safety engineer, an agent framework developer, or a platform engineer responsible for preventing cascading failures in multi-step autonomous workflows.
Prompt
Hallucination Detection in Agent Planning Steps Prompt Template

When to Use This Prompt
A guardrail for agent orchestration and safety teams to verify that an agent's planned actions and state assumptions are grounded in actual task context and tool outputs before execution.
You should not use this prompt as a general-purpose hallucination detector for final user-facing text. It is specifically tuned for the structural artifacts of agent planning: action schemas, tool arguments, state variables, and dependency graphs. It is also not a replacement for proper tool definition and API contracts. If your agent is hallucinating tool names because the tool registry is poorly defined, fix the registry first. This prompt is most effective when inserted between a planner module and an executor module, receiving the original task context, the agent's proposed plan, and any tool outputs from prior steps as inputs. In high-risk domains such as healthcare or finance, the output of this verification step should be logged and, for critical actions, routed to a human reviewer before execution proceeds.
To integrate this prompt into your agent architecture, treat its output as a binary gate with a structured report. A pass result allows execution to continue. A fail result should halt the agent, log the flagged hallucinations, and either escalate to a human or trigger a replanning step with corrected context. Common failure modes include the verifier itself hallucinating when the plan is long and complex, so break large plans into smaller verification chunks. Also, ensure that the [TOOL_REGISTRY] and [OBSERVATION_LOG] placeholders are populated with the exact, unsummarized outputs from previous tool calls—summarization before verification often hides the very discrepancies this prompt is designed to catch.
Use Case Fit
Where this prompt works, where it fails, and what you must have in place before deploying it in an agent pipeline.
Good Fit: Multi-Step Agent Orchestration
Use when: an agent generates a plan with sub-goals, tool calls, and state assumptions before execution. This prompt catches fabricated observations and unsupported planning premises before they cause loops. Guardrail: run the check after plan generation but before tool dispatch.
Bad Fit: Single-Step Tool Calls
Avoid when: the agent makes one tool call with no intermediate planning or state tracking. The overhead of hallucination detection on a single argument set is better handled by a simpler tool-use argument validator. Guardrail: use the Tool-Use Arguments Detection prompt instead.
Required Input: Task Context and Tool Outputs
What to watch: the prompt cannot detect hallucinated state if it cannot see the actual tool outputs and task context. Running it on the plan alone produces false confidence. Guardrail: always pass the full task context, tool schemas, and actual tool outputs alongside the generated plan.
Required Input: Agent Capability Manifest
What to watch: the model cannot flag hallucinated capabilities unless it knows what tools and actions are actually available. Guardrail: include a structured capability manifest listing available tools, their real parameters, and known limitations in the prompt context.
Operational Risk: Latency in Hot Paths
Risk: running a full hallucination check on every planning step adds latency to agent execution loops. In user-facing applications, this can degrade experience. Guardrail: use this prompt as an async guardrail or sample plans probabilistically in high-throughput systems. Consider streaming interrupt variants for real-time use.
Operational Risk: False Positives on Creative Planning
Risk: the detector may flag novel but valid plans that combine tool capabilities in unanticipated ways. Over-blocking stifles agent autonomy. Guardrail: route flagged plans to a human review queue instead of auto-rejecting. Track false-positive rates and tune the severity threshold before enabling auto-blocking.
Copy-Ready Prompt Template
Paste this template into your agent's planning verification step to detect hallucinated actions, fabricated observations, and unsupported planning premises before execution.
This template is designed to sit between an agent's planning step and its execution step. It takes the agent's proposed plan, the original task context, and any tool outputs the agent claims to have observed, then systematically checks whether each planned action, sub-goal, and state assumption is grounded in actual evidence. The prompt flags three categories of hallucination: fabricated capabilities (the agent assumes it has tools or permissions it doesn't), fabricated observations (the agent references tool outputs or state that never occurred), and unsupported planning premises (the agent builds a plan on assumptions not present in the task context). Use this before the agent acts on its plan to prevent cascading errors and infinite loops driven by invented state.
textYou are a planning auditor for an AI agent system. Your job is to examine the agent's proposed plan and flag any hallucinated actions, fabricated observations, or unsupported planning premises before execution occurs. ## TASK CONTEXT [ORIGINAL_TASK] ## AVAILABLE TOOLS AND CAPABILITIES [TOOL_LIST_WITH_DESCRIPTIONS] ## OBSERVED TOOL OUTPUTS (from previous steps, if any) [TOOL_OUTPUTS] ## AGENT'S PROPOSED PLAN [AGENT_PLAN] ## INSTRUCTIONS 1. Extract every planned action, sub-goal, and stated assumption from the agent's plan. 2. For each item, determine whether it is grounded in the task context, available tools, or observed tool outputs. 3. Flag items that fall into these categories: - **FABRICATED_CAPABILITY**: The plan references a tool, function, or permission not listed in available tools. - **FABRICATED_OBSERVATION**: The plan references a tool output, state value, or observation that does not appear in the observed tool outputs. - **UNSUPPORTED_PREMISE**: The plan relies on an assumption about the task, environment, or state that is not supported by the task context or observed outputs. - **MISSING_DEPENDENCY**: The plan references an output from a previous step that was never executed or whose output is unavailable. 4. For each flagged item, provide: - The exact text from the plan that is problematic. - The hallucination category. - A brief explanation of why it is not grounded. - A severity rating: BLOCKING (would cause execution failure), RISKY (likely to cause errors), or MINOR (cosmetic or low-impact). 5. Produce a final verdict: - **APPROVED**: No hallucinations detected. Plan is safe to execute. - **REQUIRES_REVISION**: Hallucinations detected. Plan must be regenerated with corrections. - **REQUIRES_HUMAN_REVIEW**: Blocking hallucinations detected in a high-risk context. ## OUTPUT SCHEMA ```json { "plan_summary": "string summarizing the agent's plan", "extracted_items": [ { "item_text": "exact text from plan", "item_type": "action | sub_goal | assumption | state_reference", "grounding_source": "task_context | tool_list | tool_outputs | none", "grounded": true, "hallucination_flag": null } ], "flagged_items": [ { "item_text": "exact problematic text", "category": "FABRICATED_CAPABILITY | FABRICATED_OBSERVATION | UNSUPPORTED_PREMISE | MISSING_DEPENDENCY", "explanation": "why this is not grounded", "severity": "BLOCKING | RISKY | MINOR" } ], "verdict": "APPROVED | REQUIRES_REVISION | REQUIRES_HUMAN_REVIEW", "verdict_reasoning": "brief explanation of the verdict" }
CONSTRAINTS
- Do not flag items that are reasonable inferences from the task context unless they contradict available evidence.
- If the agent's plan includes a step to call a tool and use its output, but that tool hasn't been called yet, flag it as MISSING_DEPENDENCY only if the plan treats the output as already available.
- When in doubt about severity, prefer RISKY over MINOR to avoid under-flagging.
- For [RISK_LEVEL] = HIGH, any BLOCKING flag must result in REQUIRES_HUMAN_REVIEW.
Adaptation guidance: Replace [ORIGINAL_TASK] with the full user request or task description the agent received. Replace [TOOL_LIST_WITH_DESCRIPTIONS] with the actual tool schemas, function definitions, or capability descriptions available to the agent—include parameter signatures and permissions. Replace [TOOL_OUTPUTS] with the actual outputs from any tools the agent has already executed in prior steps; leave empty if this is the first planning step. Replace [AGENT_PLAN] with the raw plan text the agent produced. The [RISK_LEVEL] placeholder should be set to HIGH, MEDIUM, or LOW based on your application's tolerance for planning errors—this controls whether blocking flags escalate to human review. For production use, wire the output JSON into a plan validation gate: if the verdict is REQUIRES_REVISION, send the flagged items back to the agent with a correction prompt; if REQUIRES_HUMAN_REVIEW, pause execution and queue for approval. Test this template against known hallucination patterns in your agent's planning behavior before relying on it in production.
Prompt Variables
Inputs the Hallucination Detection in Agent Planning Steps prompt needs to work reliably. Each variable must be populated before the prompt is assembled. Missing or malformed inputs are the most common cause of false negatives in planning hallucination detection.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[AGENT_ROLE] | Defines the agent's intended capability boundary and authorized actions for the current task | research_agent with access to web_search and document_retrieval tools only | Must match an entry in the authorized agent registry. Reject unknown roles. Null not allowed. |
[TASK_CONTEXT] | The original user request, goal specification, and any constraints provided to the agent before planning began | Analyze Q3 earnings reports for ACME Corp and produce a 2-page executive summary with cited sources | Must be non-empty string. Check for truncation if context exceeds model context window. Log if shorter than 50 characters. |
[PLANNING_STEPS] | The agent's proposed plan containing sub-goals, action sequences, tool selections, and state assumptions to be audited for hallucination | Step 1: Search for ACME Corp Q3 2024 earnings. Step 2: Retrieve SEC filing from EDGAR. Step 3: Calculate YoY revenue growth. Step 4: Draft summary. | Must be parseable as a list of discrete steps. Reject if empty or single-element. Validate step count matches expected planning depth for task complexity. |
[TOOL_CATALOG] | The definitive list of tools, APIs, and capabilities actually available to the agent with their input/output contracts | web_search(query: str) -> SearchResults, document_retrieve(source_id: str) -> Document, calculator(expression: str) -> float | Must be a valid JSON array of tool definitions with name, parameters, and return types. Compare against production tool registry. Reject if catalog is stale (last updated > 24 hours). |
[OBSERVATION_LOG] | Record of actual tool outputs, retrieved data, and environment state observed during prior execution steps | Step 1 returned: 3 search results with URLs. Step 2 returned: ACME 10-Q filing dated 2024-11-01 with revenue data. | Must be parseable as step-indexed observations. Allow null for pre-execution planning audit. Validate observation timestamps are sequential. Flag if observation references a step not in [PLANNING_STEPS]. |
[HALLUCINATION_CATEGORIES] | Taxonomy of hallucination types to detect in planning: fabricated capabilities, invented observations, unsupported state assumptions, tool misuse, and capability overreach | ["fabricated_tool", "invented_observation", "unsupported_assumption", "capability_overreach", "state_fabrication"] | Must be a valid JSON array of strings from the approved category taxonomy. Reject unknown categories. Minimum 1 category required. Default to full taxonomy if not specified. |
[OUTPUT_SCHEMA] | Expected structure for the hallucination detection report including flagged steps, severity, evidence gap, and recommended action | JSON with fields: flagged_steps[], hallucination_type, evidence_gap_description, severity, recommended_action, confidence | Must be a valid JSON Schema. Validate that required fields include flagged_steps, severity, and confidence. Reject schemas missing severity field. Test parse before prompt assembly. |
[ESCALATION_POLICY] | Rules for when to block execution, request human review, or allow continuation based on detection results | Block execution if any step has severity critical or confidence below 0.7. Request human review for high-severity findings. Allow continuation only if all steps pass with confidence above 0.9. | Must be a non-empty string with explicit threshold values. Validate that thresholds reference fields present in [OUTPUT_SCHEMA]. Reject if policy references undefined severity levels. Log policy version for audit trail. |
Implementation Harness Notes
How to wire the hallucination detection prompt into an agent planning loop with validation, retries, and escalation.
This prompt operates as a synchronous guardrail inside an agent's planning step. After the agent generates a proposed plan (a list of actions, sub-goals, or state assumptions), the harness sends that plan plus the original task context and any prior tool outputs to this prompt. The prompt returns a structured hallucination report. The harness must parse this report and decide whether to allow execution, request a re-plan, or escalate to a human reviewer. Do not treat this as an asynchronous audit—it must block the agent from acting on fabricated state.
Wire the prompt into your agent framework as a pre-execution validator. The typical call sequence is: (1) Agent receives task and context. (2) Agent generates a planning step output (JSON with actions, assumptions, and sub_goals). (3) Harness calls this hallucination detection prompt with [PLAN_OUTPUT], [TASK_CONTEXT], and [TOOL_OUTPUTS]. (4) Parse the response into a structured object with fields: flagged_items[], severity, grounding_status, and recommended_action. (5) Implement a decision switch: if recommended_action is proceed, allow execution; if replan, inject the hallucination report as feedback into the agent's next planning attempt (max 2 retries); if block or any severity is critical, halt the agent and route to a human review queue. Log every validation result with the plan, the report, and the harness decision for observability.
For production reliability, add schema validation on the prompt's output before acting on it. Use a JSON Schema that requires flagged_items as an array, each with claim, grounding_evidence, and hallucination_type fields. If the model returns malformed JSON, retry once with a repair prompt that includes the raw output and the schema. If repair fails, treat it as a block decision. Choose a model with strong instruction-following and low latency for this guardrail—GPT-4o or Claude 3.5 Sonnet are good defaults. Avoid using a smaller, faster model here because false negatives (missed hallucinations) are more dangerous than false positives (over-flagging) in agent execution loops. If your agent operates in a regulated domain (healthcare, legal, finance), always require human review for any severity: critical flag and maintain an audit trail of every validation decision.
Expected Output Contract
Fields, format, and validation rules for the JSON response returned by the Hallucination Detection in Agent Planning Steps prompt. Use this contract to build a parser and validator before integrating the prompt into an agent safety harness.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
planning_steps | array of objects | Must be a non-empty array. Each element must contain the fields defined in this contract. Schema validation must reject missing or empty arrays. | |
planning_steps[].step_id | string | Must match the step identifier from the input planning trace. Must be non-empty. Parse check: reject null, empty string, or missing field. | |
planning_steps[].hallucination_flag | boolean | Must be exactly true or false. Parse check: reject string 'true'/'false', 1/0, or null. If true, the hallucination_details field must be present and non-null. | |
planning_steps[].hallucination_type | string (enum) | Required when hallucination_flag is true. Must be one of: 'fabricated_capability', 'fabricated_observation', 'unsupported_premise', 'invented_state', 'other'. Null allowed when flag is false. Enum check: reject unknown values. | |
planning_steps[].hallucination_details | object | Required when hallucination_flag is true. Must contain 'claim' (string, non-empty), 'evidence_gap' (string, non-empty), and 'severity' (string enum: 'critical', 'high', 'medium', 'low'). Null allowed when flag is false. Schema check: reject missing sub-fields when present. | |
planning_steps[].grounding_source | string or null | Must be one of: 'task_context', 'tool_output', 'prior_step', 'system_state', 'none'. If 'none', hallucination_flag must be true. Citation check: reject values not in the allowed set. | |
planning_steps[].confidence_score | number (0.0-1.0) | Must be a float between 0.0 and 1.0 inclusive. Represents the model's self-assessed grounding confidence for this step. Parse check: reject values outside range, strings, or null. Confidence below 0.5 must correlate with hallucination_flag true or grounding_source 'none'. | |
overall_assessment | object | Must contain 'total_steps' (integer, must equal length of planning_steps array), 'flagged_steps' (integer, count of steps with hallucination_flag true), and 'assessment_summary' (string, non-empty). Schema check: reject if counts mismatch or summary is empty. |
Common Failure Modes
Agent planning steps are uniquely vulnerable to hallucination because errors compound across multi-step execution. A single fabricated observation or unsupported capability assumption can send an agent into a loop, trigger invalid tool calls, or produce a final answer built entirely on invented state. These cards cover the most frequent failure modes and how to guard against them.
Fabricated Tool Outputs
What to watch: The model invents a tool result or observation that was never returned by an actual tool call, then uses that fabricated data in subsequent planning steps. This is the most dangerous failure mode because it silently corrupts the agent's world model. Guardrail: Require the planning step to quote or reference the exact tool output it is reasoning from. Validate that every referenced observation exists in the actual tool call history before allowing the next action.
Hallucinated Agent Capabilities
What to watch: The model assumes it has access to tools, APIs, or abilities that are not in its tool manifest—such as 'search the web,' 'query the database directly,' or 'execute code.' The plan then includes steps that cannot be executed, causing runtime failures or silent fallback to guesswork. Guardrail: Include the full tool manifest in the planning prompt and instruct the model to only plan actions using explicitly listed tools. Validate planned tool names against the manifest before execution.
Unsupported State Assumptions
What to watch: The model assumes facts about the current state that are not grounded in prior observations—such as 'the file has already been downloaded,' 'the user is authenticated,' or 'the previous step succeeded.' These assumptions become premises for downstream decisions without evidence. Guardrail: Require the planning prompt to distinguish between 'known state' (from tool outputs) and 'assumed state' (explicitly flagged). Reject plans that treat assumptions as facts without verification steps.
Goal Drift from Fabricated Sub-Goals
What to watch: The model invents sub-goals or intermediate objectives that were not part of the original task, often because it hallucinated a requirement or constraint. The agent then pursues these phantom goals, consuming steps and potentially producing irrelevant or harmful side effects. Guardrail: Anchor every sub-goal to an explicit requirement from the original task context. Include a 'goal traceability check' that maps each planned step back to a user-specified objective before execution.
Looping on Invented State
What to watch: The agent enters a retry loop because it believes a previous action succeeded or produced a specific result that never occurred. Each iteration builds on the hallucinated state, and the agent never escapes because its termination condition depends on the fabricated observation. Guardrail: Implement a step counter with a hard limit and a state-diff check that compares the agent's believed state against actual tool output history. Force re-grounding from raw observations when a loop is detected.
Confabulated Justifications for Actions
What to watch: The model generates plausible-sounding but false reasons for choosing a particular action—citing evidence that doesn't exist, referencing prior steps incorrectly, or inventing constraints. This makes debugging difficult because the reasoning appears coherent but is entirely ungrounded. Guardrail: Require the planning step to cite specific evidence spans from the task context or tool outputs when justifying an action. Run a post-hoc verification that each cited span actually exists and supports the claimed justification.
Evaluation Rubric
Test output quality before shipping this guardrail. Each criterion targets a specific failure mode in agent planning hallucination detection. Run these checks against a golden dataset of agent plans with known grounded and hallucinated steps.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Hallucinated capability flagging | All steps referencing tools or actions not in [AVAILABLE_TOOLS] are flagged with severity HIGH | A fabricated tool call or capability claim receives severity LOW or MEDIUM | Inject 10 plans with hallucinated tool names; verify 100% flagged as HIGH |
Fabricated observation detection | All steps citing observations not present in [OBSERVATION_LOG] are flagged with the fabricated span quoted | A step that invents a file path or API response passes without a quoted fabricated span | Create 15 plans with invented observations; check that each flagged entry includes the exact fabricated text |
Unsupported premise identification | All planning premises lacking support in [TASK_CONTEXT] or [OBSERVATION_LOG] are listed with a missing-evidence note | A step assumes state not in context and the output omits it from the unsupported premises list | Feed 12 plans with unsupported assumptions; verify recall >= 0.95 on unsupported premise detection |
False negative rate on grounded steps | No grounded step is incorrectly flagged as hallucinated | A step fully supported by [OBSERVATION_LOG] appears in the hallucination report | Run 20 fully grounded plans; assert zero hallucination flags in output |
Severity classification accuracy | Fabricated capabilities and observations are severity HIGH; unsupported premises are MEDIUM; minor inference gaps are LOW | A fabricated tool call receives severity LOW or MEDIUM | Classify 30 known hallucination examples across severity levels; verify accuracy >= 0.90 against human labels |
Output schema compliance | Output matches [OUTPUT_SCHEMA] exactly: flagged_steps array, each with step_id, hallucination_type, severity, quoted_span, evidence_gap | Missing required fields, wrong types, or extra fields in output | Validate 50 outputs against JSON Schema; require 100% structural compliance |
Confidence score calibration | Confidence scores on hallucination flags correlate with actual detection accuracy; low-confidence flags should be rare on clear fabrications | A clear fabrication receives confidence below 0.7 | Bin 100 flagged outputs by confidence; measure precision per bin; require precision >= 0.9 for confidence >= 0.8 |
Empty input handling | When [OBSERVATION_LOG] is empty and [TASK_CONTEXT] is minimal, all planning steps that assert state are flagged as unsupported premises | Output returns empty flagged_steps array when agent plan contains unsupported assertions | Test 8 plans with empty observation logs; verify all unsupported assertions are flagged |
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
Use the base prompt with a single planning step and a small set of known tool outputs. Remove severity classification and root cause analysis. Focus on binary grounded/ungrounded detection per step.
Simplify the output schema to a flat list:
json{ "planning_steps": [ { "step_id": "[STEP_ID]", "grounded": true, "issue": null } ] }
Watch for
- False positives on reasonable inferences from tool outputs
- Missing detection when the agent paraphrases tool results correctly but the prompt expects exact string match
- Over-flagging when the agent states its own internal reasoning (which is not grounded in tool outputs by design)

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