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-30Advanced

Building a Production Claude API Pipeline on Cloudflare Queues: Fault Tolerance, Backpressure, and Cost Control

A practical, code-first walkthrough for routing Claude API calls through Cloudflare Queues — covering producer/consumer code, retry-vs-DLQ branching, priority lanes, and token budgeting for production workloads.

claude-api81cloudflare-queuescloudflare-workers5async2production111rate-limit7observability20

Premium Article

"All I want is to summarize 100 uploaded PDFs with Claude — but the Worker dies after 10 seconds." That was a real production incident I worked through, and the cause was painfully simple: a Cloudflare Worker's CPU budget collided with Claude's response latency. Some users sat watching a spinner that would never resolve.

This article is the cleaned-up version of the lesson I took from that incident: never call Claude API directly from a request handler. Cloudflare Queues, used carefully, gives you a place to absorb the impedance mismatch between user-facing latency and model latency. We'll build the pipeline end-to-end with copy-pasteable code, and we'll cover the parts that usually go wrong — retry logic, dead-letter handling, priority lanes, and token budgeting.

Why a request handler is the wrong place to call Claude

Cloudflare Workers cap CPU time at 50ms (free) or up to 30 seconds (paid). That's CPU time, not wall-clock, but for a single Claude API call you're realistically waiting 20–60 seconds of wall time on long outputs. Calling the API synchronously from a handler causes three failures at once:

  • The Worker exits with Exceeded CPU limit: the user gets a 502, no charge to you, but the work is also gone.
  • Client retries cascade: browsers and SDK retries kick in, and one logical job becomes 3–4 billable Claude calls.
  • 429s and 529s pile on: bursty retries hit the rate limit, and now unrelated users in the same org start failing too.

The fix is structurally simple. The handler queues a job and returns immediately. A separate consumer Worker picks the job up and calls Claude. User-perceived latency and model latency are now decoupled. If your workload is purely batch and you don't need user-facing immediacy, the Claude API Messages Batches endpoint is a fine alternative — but for any pipeline where individual user actions need to be tracked, Queues is the better fit.

Pipeline shape

The architecture has three layers:

  • Producer: receives the user request, writes the job to D1, drops a message onto a queue, returns 202 immediately.
  • Consumer: pulls messages off the queue, calls Claude, persists results to R2, updates D1.
  • Observability: failed jobs go to a dead-letter queue (DLQ), and we ship metrics to Logpush so we can alert when failure rates climb.

To keep interactive workloads from being starved by bulk imports, we run two queues: claude-jobs-high (chat-style, foreground work) and claude-jobs-bulk (background batches, uploads). Both feed the same consumer codebase but with different max_concurrency settings.

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 struggled to fan out hundreds of Claude API calls without melting your Worker, you'll have a working pipeline by the end of the day
You'll learn the exact ack vs retry vs DLQ branching for 429s, 529s, and timeouts — copy-pasteable, with the reasoning baked in
By combining priority lanes with a Durable Object token budget, you'll be able to absorb traffic spikes and bulk uploads without trampling your interactive users
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-06-18
When Your Claude API Response Cache Returns Stale Answers and Near-Miss Wrong Ones — Field Notes on Freshness and False-Hit Suppression
A Claude API response cache improves latency and cost immediately, but the problems that hurt in production are not average hit rate — they are stale hits and semantic false hits. Here is the key design, freshness management, false-hit suppression, and observability that keep a cache honest.
API & SDK2026-06-16
PII Masking for Claude API Lives or Dies on the Ledger — Restore, Encrypt, Measure
The hard part of masking PII before Claude API isn't detection — it's operating the token ledger you restore from. Encrypted storage, multi-instance sharing, and a daily leak-rate loop, with working code.
📚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 →