Skip to content
Courses/Production agents with LangGraph and n8n/Error Recovery and 503 Failures

Error Recovery and 503 Failures

A production agent cannot go into crisis because an API returns 503 for ten seconds. It must distinguish transient errors, recoverable errors, human errors, and permanent failures.

  • Classify errors before retrying.
  • Design retries with backoff, jitter, and limits.
  • Escalate to human review without losing state.

Classify Before Acting

  • Transient: 429, 503, timeout, broken connection. Retry with backoff.
  • LLM-recoverable: invalid JSON format, missing field. Retry with explicit correction.
  • User-recoverable: missing data, permission, or approval. Ask or pause.
  • Permanent: invalid credential, resource does not exist, policy blocked. Stop and report.
Terminal
type AgentError =
  | { kind: "transient"; code: 429 | 503 | "timeout"; retryAfterMs?: number }
  | { kind: "model_format"; message: string }
  | { kind: "needs_human"; reason: string }
  | { kind: "fatal"; reason: string };

const retryPolicy = {
  maxAttempts: 4,
  initialDelayMs: 1000,
  backoff: 2,
  jitter: true,
};

Minimum State to Avoid a Spiral

Terminal
{
  "task_id": "research-2026-07-05-001",
  "step": "fetch_sources",
  "attempts": 2,
  "last_error": "503 from search API",
  "next_retry_at": "2026-07-05T10:31:00Z",
  "fallback": "use cached sources",
  "human_review": false
}

Recommended Recovery Pattern

  • Execute the tool with a timeout.
  • If it fails, classify the error in code, not in free text.
  • If transient, wait with backoff and log the attempt.
  • If attempts are exhausted, switch to fallback or escalate to a human.
  • Summarize the state, not the full history, to continue.

Official Sources

  • LangGraph persistence
  • LangGraph: Thinking in LangGraph
  • LangChain/LangGraph human-in-the-loop
Complete Aulafy mapSee how this lesson fits without leaving your path.

Complete Aulafy map

How all courses connect

This is not a checklist. Start with the foundation, choose an outcome, and go deeper only when your project needs more control.

  1. 1Understand
  2. 2Apply or build
  3. 3Operate with confidence
01

Choose an application

Turn the foundation into a visible outcome: a website, a business improvement, media, or an interactive experience.

Continue into the technical branch when you need to maintain code, data, or infrastructure.

02

Build with code

Prepare your environment, work with coding agents, and run models while keeping control of your projects.

This branch prepares you to design and operate reliable AI systems.

03

Take systems to production

Combine retrieval, agents, evaluation, security, deployment, and model adaptation when the problem requires it.

You do not need every course: choose the component your system needs and return as it grows.

View full catalogue