Prompt LibraryAgents

Agent Replanning & Error Recovery Prompt

Decide when an agent should replan vs. retry vs. escalate.

The prompt

An agent executed the following plan step and got this result. Decide the next action:
- RETRY (same step, same args) — only if the failure is transient and idempotent.
- REPLAN (rewrite remaining steps) — if the environment changed or assumptions broke.
- ESCALATE (ask a human) — if the step is irreversible or confidence is below threshold.

Output a JSON object: { action, reason, revised_steps (if replan), confidence_0_to_1 }.

Step attempted: {{step}}
Result / error: {{result}}
Remaining plan: {{remaining}}

Replace the {{fields}} with your own context and tighten the rules to match your domain.

Share this prompt