Inferensys

Prompt

Agent Plan Patching Prompt for New Evidence

A practical prompt playbook for using Agent Plan Patching Prompt for New Evidence in production AI workflows.
Wide-angle shot of a modern WeWork open floor plan with creative walls covered in AI system architecture diagrams, product team collaborating in standing desk area with industrial lighting.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise conditions for using the assumption-invalidation patching prompt and distinguishes it from other replanning triggers.

This prompt is for agent runtimes that discover new evidence mid-execution which contradicts the assumptions the original plan was built on. Use it when a tool returns data that invalidates a prior belief, a retrieved document disproves a planning premise, or an external sensor reading changes the operating context. The core job-to-be-done is surgical plan repair: you need to retract only the steps that depended on the invalidated assumption, preserve all unaffected progress, and re-sequence the remaining work without rebuilding the entire plan from scratch. This matters because full replanning is expensive, discards valid completed work, and introduces unnecessary variance in production agent loops.

This prompt assumes your agent runtime already maintains an explicit plan structure with tracked assumptions, completed steps, and pending dependencies. The plan must include a dependency graph or at minimum a list of steps annotated with the assumptions each step depends on. Without this assumption traceability, the model cannot calculate the impact radius of new evidence and will either over-correct by discarding too much work or under-correct by leaving contradicted steps in the plan. The ideal user is an engineering team building autonomous or semi-autonomous agent loops where static plans fail silently in production—think research agents, code-review agents operating across multiple repositories, or data-processing pipelines where upstream schema changes invalidate downstream transformation logic.

Do not use this prompt for simple step retries, tool-argument fixes, or constraint violations. Those failures have dedicated patching prompts: tool failures need alternative tool selection, unexpected outputs need output-reinterpretation logic, and constraint violations need boundary-aware replanning. This prompt is specifically for the case where the plan's foundational beliefs were wrong—not where execution hit a recoverable error. Also avoid this prompt when the new evidence is merely additive rather than contradictory; if the evidence extends understanding without invalidating prior steps, a plan extension prompt is more appropriate. Finally, if your agent does not track assumptions explicitly, invest in that infrastructure before deploying this prompt, because asking the model to infer what assumptions existed retroactively produces unreliable impact analysis.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Agent Plan Patching Prompt for New Evidence delivers value and where it introduces risk.

01

Good Fit: Mid-Plan Discovery

Use when: An agent discovers new information during execution that contradicts a prior planning assumption. Guardrail: The prompt requires the agent to explicitly list the invalidated assumption and the new evidence before proposing a patch.

02

Good Fit: Incomplete Initial Context

Use when: The agent started with partial information and must revise its plan as it learns. Guardrail: The prompt must preserve completed, unaffected steps to avoid unnecessary rework. Validate that the patch only modifies assumption-dependent plan segments.

03

Bad Fit: Full Goal Replacement

Avoid when: The user or system has changed the entire objective, not just invalidated an assumption. Guardrail: Route to a full plan regeneration prompt instead. Patching a plan for a new goal creates fragile, incoherent execution paths.

04

Bad Fit: No Assumption Tracking

Avoid when: The original plan did not record its assumptions explicitly. Guardrail: Without a traceable assumption log, the agent cannot reliably determine which steps depend on the contradicted belief. Require assumption tracking in the initial planning prompt.

05

Required Inputs

Risk: Missing context causes the agent to patch the wrong plan segment. Guardrail: The prompt requires the current plan with explicit assumptions, the new evidence, and the specific assumption it contradicts. Without all three, refuse to generate a patch.

06

Operational Risk: Cascading Rework

Risk: A single assumption change can invalidate a large downstream dependency chain, causing excessive re-execution. Guardrail: The prompt must calculate and report the impact radius before patching. If rework exceeds a cost threshold, escalate for human approval.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready template for generating a targeted plan patch when new evidence invalidates prior assumptions.

This template is designed to be injected into an agent's replanning module when a runtime monitor detects that new evidence contradicts a previously held assumption. It instructs the model to act as a plan surgeon: identify the exact steps that depended on the invalidated assumption, retract them, and generate a minimal replacement sequence that incorporates the new evidence. The prompt is structured to prevent full plan regeneration, which is expensive and risks discarding valid, completed work.

text
You are an agent plan patching module. Your task is to revise an in-progress execution plan because new evidence has invalidated a core assumption.

# Original Plan
[ORIGINAL_PLAN]

# Completed Steps (do not modify or re-execute)
[COMPLETED_STEPS]

# Invalidated Assumption
The following assumption was made during planning but is now contradicted by evidence:
[INVALIDATED_ASSUMPTION]

# New Evidence
The following evidence has been observed that contradicts the assumption:
[NEW_EVIDENCE]

# Current Active Step (may be interrupted)
[ACTIVE_STEP]

# Available Tools
[AVAILABLE_TOOLS]

# Constraints
- Preserve all completed steps. Do not suggest re-executing them.
- Minimize the number of new or modified steps.
- If the active step depends on the invalidated assumption, mark it for immediate interruption.
- Do not alter steps that are independent of the invalidated assumption.
- If the new evidence makes the original goal unachievable, explicitly state this and recommend escalation.

# Output Schema
Return a JSON object with the following structure:
{
  "assumption_impact_analysis": "string describing which plan steps depend on the invalidated assumption",
  "interrupted_step": "[ACTIVE_STEP] or null if the active step is unaffected",
  "retracted_steps": ["list of step IDs to remove from the remaining plan"],
  "patched_plan_fragment": [
    {
      "step_id": "unique step identifier",
      "description": "what the step does",
      "tool": "tool name from available tools or null",
      "depends_on": ["list of step IDs this step requires"],
      "expected_output": "description of what success looks like"
    }
  ],
  "goal_still_achievable": true or false,
  "escalation_reason": "string explaining why escalation is needed, or null"
}

To adapt this template, replace the square-bracket placeholders at runtime. [ORIGINAL_PLAN] should contain the full plan object, including step IDs, descriptions, and dependency edges. [COMPLETED_STEPS] must be an accurate list of step IDs that have already executed successfully—errors here cause the agent to either redo work or skip necessary steps. [INVALIDATED_ASSUMPTION] should be a single, specific statement extracted from the planning trace, not a vague observation. [NEW_EVIDENCE] must be the raw observation or tool output that triggered the replanning event. Before deploying, validate that the output JSON strictly conforms to the schema, that retracted step IDs exist in the original plan, and that the patched fragment does not reintroduce dependencies on the invalidated assumption. For high-risk domains, route the generated patch to a human reviewer before resuming execution.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Agent Plan Patching Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Missing or malformed variables are the most common cause of silent patching failures in production.

PlaceholderPurposeExampleValidation Notes

[CURRENT_PLAN]

The active plan being executed, including completed, in-progress, and pending steps with their dependencies and expected outputs.

{"plan_id": "plan-42", "steps": [{"id": "S1", "status": "completed", "output": "..."}, {"id": "S2", "status": "in_progress"}]}

Must be valid JSON with at least one step. Reject if plan_id is missing or steps array is empty. Parse check required before assembly.

[NEW_EVIDENCE]

The discovery, observation, or tool output that contradicts or invalidates prior plan assumptions. This is the trigger for the patch.

Tool 'search_database' returned schema X but step S3 expected schema Y. Evidence: {"actual_schema": "X", "expected_schema": "Y"}

Must be a non-empty string or structured object. Reject null or whitespace-only values. Include source attribution if evidence came from a tool call or user input.

[INVALIDATED_ASSUMPTIONS]

The specific planning assumptions that [NEW_EVIDENCE] contradicts. Extracted from the plan's assumption registry or explicitly stated by the calling system.

["Database returns schema Y", "All records have non-null email field"]

Must be a non-empty array of strings. Each assumption should be traceable to a step in [CURRENT_PLAN]. Reject if no assumptions are listed or if assumptions are vague.

[AFFECTED_STEP_IDS]

The step identifiers in [CURRENT_PLAN] that depend on the invalidated assumptions and must be re-evaluated or retracted.

["S3", "S5", "S7"]

Must be an array of strings matching step IDs in [CURRENT_PLAN]. Reject if any ID does not exist in the plan. Empty array is valid only if no steps are affected, but this should trigger a warning.

[AVAILABLE_TOOLS]

The current tool catalog with schemas, capabilities, and constraints available for replanning. May differ from the original plan's tool set if tools were added or removed.

[{"name": "search_database", "schema": {...}}, {"name": "send_email", "schema": {...}}]

Must be a valid JSON array of tool definitions. Each tool must have a name and schema. Reject if empty when the plan requires tool execution. Validate against tool registry before assembly.

[CONSTRAINTS]

Active constraints that the patched plan must satisfy: budget, time, permissions, safety policies, and operational boundaries.

{"max_steps": 10, "timeout_seconds": 300, "require_human_approval_for": ["send_email"]}

Must be a valid JSON object. Reject if missing required constraint keys defined by the agent runtime. At minimum, include max_steps and timeout. Null allowed for optional constraints.

[COMPLETED_STATE]

The accumulated state from completed steps, including outputs, side effects, and any resources created or modified. Used to avoid re-executing completed work.

{"S1": {"output": "user_list.csv", "side_effects": ["file_created"]}, "S2": {"output": {...}}}

Must be a valid JSON object keyed by step ID. Values must include output field. Reject if a completed step ID from [CURRENT_PLAN] is missing its state entry. Null allowed if no steps completed.

[PATCH_STRATEGY]

The preferred approach for generating the patch: minimal (change only affected steps), conservative (revalidate adjacent steps), or full (replan from scratch).

"minimal"

Must be one of: 'minimal', 'conservative', 'full'. Reject any other value. Default to 'minimal' if not specified but log the default choice for traceability.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the plan patching prompt into an agent runtime with validation, retries, and safe execution guards.

The plan patching prompt is not a standalone chat interaction—it is a component inside an agent orchestration loop. The runtime should invoke it only when a monitoring module detects a specific trigger condition: new evidence that contradicts a tracked planning assumption. Before calling the prompt, the harness must assemble the current plan state, the contradictory evidence, the list of explicit assumptions the plan depends on, and the completed step history. This context assembly is the most common failure point in production because incomplete or stale state causes the patching prompt to propose revisions that conflict with already-completed work.

Wire the prompt into a structured decision node within the agent's execution loop. The runtime flow should be: (1) the evidence monitor flags a contradiction and emits a structured trigger payload containing the assumption that was invalidated and the new evidence; (2) the harness collects the current plan, completed steps with their outputs, pending steps, and the full assumption register; (3) the patching prompt is called with these inputs; (4) the output is parsed as a structured patch object containing affected_steps, replacement_steps, retracted_assumptions, and new_assumptions; (5) a validator checks that every affected_step exists in the current plan, that no replacement_step duplicates a completed step, and that all new_assumptions are explicit and testable; (6) if validation fails, the harness retries once with the validation errors appended as feedback, then escalates to a human operator if the second attempt also fails. Use a model with strong structured output support (GPT-4o, Claude 3.5 Sonnet, or equivalent) and enforce the output schema with function calling or structured output mode rather than relying on free-text parsing.

Log every patch invocation with the trigger reason, the assumption that was invalidated, the evidence that caused it, the patch diff, and the validation result. This audit trail is essential for debugging agent behavior and for post-execution reviews. Avoid applying patches automatically when the patch proposes changes to more than 30% of remaining steps or when it retracts an assumption that was used to justify a completed irreversible action—in these cases, escalate for human review. The harness should also enforce a maximum patch depth (no more than three nested replanning events per session) to prevent infinite replanning loops where each patch introduces new assumptions that are immediately invalidated.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the plan patch JSON object. Use this contract to validate the model's output before applying it to the agent's execution state.

Field or ElementType or FormatRequiredValidation Rule

patch_id

string (UUID v4)

Must be a valid UUID v4 string. Reject if missing or malformed.

patch_reason

string (enum)

Must match one of: 'new_evidence', 'tool_failure', 'unexpected_output', 'constraint_violation', 'human_override', 'partial_completion', 'assumption_invalidation'. Reject if value is outside this enum.

evidence_summary

string

Must contain a non-empty string that references the specific new evidence. Must include a source citation or observation ID if available. Reject if empty or if it restates the original plan without referencing new information.

invalidated_steps

array of strings

Each element must be a valid step_id from the original plan. Array must not be empty. Reject if any step_id does not exist in the original plan or if the array is empty.

retracted_assumptions

array of objects

Each object must contain 'assumption' (string) and 'reason' (string). 'assumption' must match a tracked assumption from the original plan. 'reason' must explain why it is now invalid. Reject if any assumption is not traceable to the original plan's assumption log.

patched_plan

array of objects

Each object must contain 'step_id' (string), 'action' (string), 'depends_on' (array of strings), and 'status' (enum: 'pending', 'in_progress', 'completed', 'skipped'). Completed steps from the original plan must be preserved with status 'completed'. Reject if dependency graph contains cycles or references non-existent step_ids.

new_dependencies

array of objects

Each object must contain 'step_id' (string) and 'depends_on' (array of strings). Use only when adding dependencies not present in the original plan. Reject if any referenced step_id is not in the patched_plan array.

confidence_score

number (0.0 to 1.0)

Must be a float between 0.0 and 1.0 inclusive. Represents the model's confidence in the patch correctness. If below 0.7, flag for human review before applying. Reject if out of range or not a number.

PRACTICAL GUARDRAILS

Common Failure Modes

When an agent patches its plan in response to new evidence, the most dangerous failures are silent ones—the plan changes but the reasoning is wrong, the evidence is hallucinated, or the patch breaks downstream dependencies. These cards cover the failure modes that hit first in production and how to guard against them.

01

Evidence Fabrication Under Pressure

What to watch: The model invents evidence to justify a plan change rather than admitting uncertainty. This is most common when the prompt demands a patch but the provided evidence is ambiguous or insufficient. Guardrail: Require the patch to quote or reference the specific evidence that triggered each change. Add a validator that rejects patches where changed steps lack a source citation from the provided evidence block.

02

Over-Patching Unaffected Steps

What to watch: A single invalidated assumption causes the model to rewrite the entire plan, discarding completed work and valid steps that were never dependent on the contradicted assumption. Guardrail: Require the model to explicitly list which steps are assumption-dependent before patching. Add a diff constraint—only steps with a traced dependency on the invalidated assumption may be modified. Validate that completed steps remain unchanged unless their dependency is proven.

03

Silent Dependency Chain Breakage

What to watch: The patch modifies an upstream step but fails to update downstream steps that consume its output. The plan looks coherent but will fail at runtime when a later step receives unexpected input. Guardrail: Require the patch to include a forward-impact analysis listing every downstream step affected by each changed step. Add a schema check that verifies the output contract of each modified step still satisfies the input requirements of its dependents.

04

Patch Loop Instability

What to watch: The patched plan introduces new assumptions that are immediately contradicted by the same evidence, triggering another patch cycle. The agent oscillates between plan versions without converging. Guardrail: Before accepting a patch, run a stability check—does the new plan contain any assumption that the provided evidence already contradicts? Add a maximum patch depth counter and escalate to human review if the same step is patched more than twice.

05

Evidence Misattribution and Scope Creep

What to watch: The model correctly identifies that new evidence exists but applies it to the wrong part of the plan or draws conclusions that exceed what the evidence supports. A narrow finding about one tool's output gets treated as a global constraint. Guardrail: Require the model to state the scope of each piece of evidence before applying it. Add an eval that checks whether each patched step's justification stays within the stated scope. Flag patches where evidence scope and change scope don't match.

06

Abandoning Ground Truth for Convenience

What to watch: When new evidence conflicts with previously verified facts, the model sometimes discards the verified facts instead of reconciling the conflict. The patch looks consistent but loses information that was already confirmed. Guardrail: Maintain a verified-facts register across plan execution. Require the patch to explicitly reconcile conflicts between new evidence and the register. Reject patches that silently drop verified facts without explanation. Escalate irreconcilable conflicts to human review.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to test whether the Agent Plan Patching Prompt for New Evidence produces safe, grounded, and executable plan revisions before deploying into an agent runtime. Each criterion includes a pass standard, a failure signal, and a test method that can be automated or run manually against a golden set of plan-and-evidence pairs.

CriterionPass StandardFailure SignalTest Method

Evidence Grounding

Every added or modified step cites the specific new evidence that justifies the change.

A step is added or altered without any reference to the new evidence provided in [NEW_EVIDENCE].

Parse the output for step-level evidence citations. Flag any step in the patch that lacks a link to a specific evidence item from the input.

Contradiction Retraction

All steps in [ORIGINAL_PLAN] that are contradicted by [NEW_EVIDENCE] are explicitly marked as retracted or removed.

A contradicted step remains active in the revised plan without modification or retraction marker.

Diff the step IDs between [ORIGINAL_PLAN] and the patched plan. For each contradiction identified in [NEW_EVIDENCE], verify the corresponding step is retracted.

Assumption Traceability

The output identifies which planning assumptions were invalidated and lists all steps that depended on those assumptions.

The patch modifies steps without explaining which assumption changed or why downstream steps are affected.

Check for an explicit 'Invalidated Assumptions' section in the output. Verify that each listed assumption maps to at least one modified or retracted step.

Step Re-Sequencing Correctness

Remaining steps are re-sequenced to respect dependencies after retractions and insertions.

A step appears before its declared prerequisite or after a step that should logically follow it.

Build a dependency graph from the patched plan's step order and declared prerequisites. Flag any topological ordering violations.

No Phantom Steps

The patched plan contains only steps from [ORIGINAL_PLAN] that are retained, plus new steps justified by [NEW_EVIDENCE].

The output introduces a step that is neither in the original plan nor traceable to the new evidence.

Extract all step IDs. Flag any step not present in [ORIGINAL_PLAN] and not accompanied by a citation to [NEW_EVIDENCE].

Output Schema Compliance

The output is valid JSON matching the [OUTPUT_SCHEMA] with all required fields present.

The output is missing required fields, uses incorrect types, or is not parseable JSON.

Validate the output against the declared JSON schema. Reject on parse errors, missing required fields, or type mismatches.

Idempotency Risk Flagging

Steps that have already produced side effects and cannot be safely re-executed are flagged with an idempotency warning.

A step that previously mutated external state is re-sequenced for re-execution without any warning or compensation note.

Check for an 'idempotency_risk' or equivalent flag on steps that appear in both the original plan's completed section and the patched plan's pending section.

Uncertainty Disclosure

The output includes a confidence assessment for the patch and flags any steps that rely on low-confidence inferences from [NEW_EVIDENCE].

The patch presents all changes with equal confidence, even when the new evidence is ambiguous or incomplete.

Parse the output for a confidence field or per-step uncertainty markers. Flag if no uncertainty information is present when [NEW_EVIDENCE] contains hedged or probabilistic language.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and minimal validation. Focus on getting the plan patch structure right before adding production harness. Keep [EVIDENCE] and [CURRENT_PLAN] as raw text blocks. Accept that some patches may miss subtle dependency impacts.

Watch for

  • Patches that contradict themselves without detection
  • Missing assumption traceability in the revision
  • Overly broad patches that rewrite more of the plan than necessary
  • No validation that the patched plan is still executable with available tools
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.