◉CLAUDE LABJP
●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…●2.1.301 — Adds the vim % motion, LaTeX math rendering in the VS Code panel, and a retry-watchdog limit for usage-limit waits (10/15)●2.1.299 — Conversations over 200K tokens left idle about 54 minutes get compacted; MCP allow rules now match only the server they name●SONNET 4.5 — Retires on the Claude API on 11/30, 45 days left. Migrate to Sonnet 5.5●WINDOWS — Reports say hooks break silently only on Japanese-locale Windows; check the character encoding first●FAST MODE — Opus 5.5 fast mode is out of research preview and no longer needs the beta header (10/15)●NEW — I Put a Ten-Line Promise File at the To…
Articles/API & SDK
⬡ API & SDK/2026-04-28Advanced

Claude API × Inngest — Durable AI Workflows with Retries, Idempotency, and Human Approval

A production-grade pattern for combining Claude API with Inngest. Build TypeScript-first durable AI workflows that retry safely, stay idempotent, gate dangerous calls behind human approval, and run on Vercel or Cloudflare Workers.

claude-api83inngestdurable-executionworkflow41production111anthropic-api3

✦ Premium Article

"That overnight AI batch died at 3am again." If you've shipped Claude API to production for any length of time, you know that feeling. I run four AI-focused blog sites that each generate and update articles via Claude API on a schedule, and the first few months were a string of 5xx errors, mid-stream timeouts, and tool calls that double-charged Stripe because retries weren't safe.

The lesson I keep relearning is that production AI workflows need to resume safely from the middle. Wrapping the whole thing in try/catch, building a job table by hand, splitting work across queues — I tried all of these. They each work for about a week and then collapse under their own weight.

This article shows how to combine Inngest, a TypeScript-first durable execution engine, with the Claude API to build production-grade AI workflows. Everything sits inside a single Next.js app, so you don't need to spin up extra infrastructure on Vercel, Cloudflare Workers, or wherever your code already lives.

If you're a Python shop or you want the heaviest possible workflow engine, Claude Agent SDK × Temporal.io: Building Resilient Long-Running AI Workflows covers that path. This one is deliberately lighter — aimed at TypeScript web developers who want to stay in the stack they already know.

Why a plain Promise loop won't survive production

Almost every Claude agent starts life looking like this:

// The naive version. Works for demos, breaks in production.
async function runAgent(userInput: string) {
  const messages = [{ role: "user", content: userInput }];
  while (true) {
    const res = await anthropic.messages.create({
      model: "claude-sonnet-4-6",
      max_tokens: 1024,
      tools,
      messages,
    });
    messages.push({ role: "assistant", content: res.content });
    if (res.stop_reason === "end_turn") return res;
    if (res.stop_reason === "tool_use") {
      const toolResult = await runTool(res); // ← side-effecting external API
      messages.push({ role: "user", content: toolResult });
    }
  }
}

A one-shot demo runs fine. Ship it and you start hitting:

  • Function timeouts. Vercel serverless functions cap at 5 minutes, Cloudflare Workers at ~30 seconds of CPU. A three-turn tool-use loop can blow through that.
  • Double-billed retries. A timeout, a user retry, and now Stripe has been charged twice. I've done this. It's awful.
  • Opaque progress. You can't tell from logs which message in the array was the last one Claude actually saw.
  • No clean way to pause for human approval. The moment a security-conscious teammate asks for an approval gate, the whole loop has to be rewritten.

These aren't bugs you can patch independently. They all stem from the same missing capability: resuming a long-running process safely after a crash. I tried Redis checkpoints, Postgres job tables, custom retry decorators. After enough nights, I realized I was writing a workflow engine, badly.

Inngest in five minutes

Inngest is a durable execution engine designed for TypeScript and JavaScript. It shares the "Durable Execution" mindset of Temporal, but the developer experience collapses into a single Next.js API route.

Four concepts are enough to start:

  • Function: a handler that runs in response to an event, defined with inngest.createFunction().
  • Step: a unit inside a Function that says "if you crash, please remember the result so far." step.run() is the workhorse — its return value is persisted, and reruns skip past it.
  • Event: the trigger. Send one with inngest.send({ name, data }).
  • Sleep / WaitForEvent: primitives that pause the function. The function literally exits and Inngest wakes it up later.

The crucial intuition: step boundaries are resume points. If a step succeeds, its result is durable; the function can crash arbitrarily and rerun, and that step won't fire its body again.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦If you've ever watched a long-running Claude job die mid-flight and dreaded the rerun, you'll learn how to wrap it in Inngest's step.run so retries skip work already done — in the TypeScript stack you already know.
✦You'll get working code for tool-use agent loops, idempotency keys, retry classification, human-approval gates, and fan-out/fan-in batches — copy-paste ready into a Next.js app.
✦You'll come away with a serverless durable workflow you can deploy to Vercel or Cloudflare Workers without standing up Temporal, Airflow, or your own queue infrastructure.
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ API & SDK2026-05-26
Stabilizing Claude API Structured Responses in Production — Notes on tool_use, JSON Schema, and Layered Validation
Getting Claude to return JSON takes a few lines. Keeping that JSON usable in production is a different problem. Here is the layered design I landed on after running a wallpaper classification pipeline through Claude API, built around tool_use, JSON Schema, and domain validation.
⬡ API & SDK2026-05-22
Why tool_result could not be submitted Keeps Coming Back, and How to Build a Recovery Handler That Actually Holds
Run a Claude agent long enough and one day it starts: 'tool_result could not be submitted', back to back, and retries change nothing. The error message hides four completely different root causes. Here is what I learned debugging it on the always-on agent jobs I run as an indie developer, with the TypeScript recovery handler I now ship in production.
⬡ API & SDK2026-05-19
Hierarchical Chat History Summarization with Claude API: A 3-Tier Design That Cut Tokens by 70%
Working TypeScript design for compressing long in-app chat histories into three tiers — recent turns kept verbatim, mid-range episodes summarized with Haiku 4.5, and long-range memory distilled to JSON by Sonnet 4.6. Includes seven weeks of production data showing input tokens down 70% and monthly API cost down from $480 to $145.