CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
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-api81inngestdurable-executionworkflow37production111anthropic-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-07-13
Coalescing Concurrent Claude API Calls: Single-Flight Against Duplicate Inference and Cache Stampede
A design for collapsing identical prompts that fire at the same instant into a single upstream Claude call, using single-flight (request coalescing). In-process and distributed implementations, jittered retries, and negative caching, with measured results.
API & SDK2026-07-03
How Many Concurrent Claude API Requests Can You Actually Hold? Sizing Production Infrastructure with Little's Law and Measured Memory
Concurrency, queue depth, and memory are numbers you can derive, not guess. A working method for sizing Claude API production deployments with Little's Law, a memory probe, and a 30-minute load check — learned the hard way from an OOM crash.
API & SDK2026-06-28
A Silent Drop to a Weaker Model Is Scarier Than an Error: Designing a Capability Floor for Claude API Fallback
When a model becomes unavailable in an unattended pipeline, automatically dropping to a weaker model is dangerous. Drawing on years of running automated indie pipelines, this is how to use per-task capability contracts and a degradation budget to decide where to stop.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →