Flows category icon
Agent Architecture
Intermediate

Error Recovery and Retry Policy for the Agent Loop

Design the retry, backoff, and give-up behavior that separates production agents from demos that loop forever.

4 steps12 verify checks60-90 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/4 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
My agent handles happy paths but degenerates on failure: it retries the same broken call, loses track after errors, or gives up silently. The autonomous-agent literature is a catalog of loop-and-drift failures with known fixes.

GOAL:
Implement a layered recovery policy: transient retries with backoff, model-visible error feedback, loop detection, and honest escalation.

REQUIREMENTS:
- Error taxonomy: transient (retry), corrective (inform model), fatal (escalate)
- Automatic retry with exponential backoff for transient failures only
- Corrective errors returned to the model with cause and suggested next step
- Loop detection on repeated near-identical failing actions
- An escalation path that reports honestly what failed and what was tried

CONSTRAINTS:
- Never auto-retry non-idempotent operations without a guard
- Every retry and escalation must appear in the transcript

DEFINITION OF DONE:
- A transient network failure is retried and succeeds without model involvement
- A corrective error (bad args) leads the model to a fixed second call
- Three near-identical failures trigger the loop breaker with a strategy-change message
- A fatal failure produces an honest escalation summary, not silence or fabrication

COMMON FAILURES TO AVOID:
- Retrying everything including operations that mutate state twice
- Hiding errors from the model so it reasons from a false world
- No loop breaker: the agent burns its budget on one broken idea
- Silent give-up: the run ends with neither success nor an honest report

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More Agent Architecture flows that share ground with this one.

Flows category icon
Agent Architecture

Add a Plan/Todo System to Your Agent

Give your agent the planning discipline of the leading harnesses: an explicit, model-visible todo list that survives long tasks.

01Design the todo data model and tool
02Render the plan into context every turn
03Enforce plan-first and completion gates

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps60-90 minutesIntermediate
Flows category icon
Agent Architecture

Design a Single-Loop Agent

Build the core agent loop the leading coding agents use: one model, one loop, tools in, results folded back into context.

01Define the loop contract
02Build the tool registry
03Implement the loop with result folding

+2 more steps to Done

Best forproduction-grade builds with strict verification

5 steps90-150 minutesAdvanced
Flows category icon
Agent Architecture

Agent-to-Agent Protocols (A2A)

Connect two agents over an explicit protocol - task handoff, acknowledgment, and failure handling - instead of hoping chat works out.

01Define the protocol
02Build the message layer
03Wrap agents as protocol endpoints

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-150 minutesAdvanced

Made with Emergent