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-05-07Advanced

Implementing the Transactional Outbox Pattern with Claude Agent SDK — Eliminating Lost Side Effects in Production

Stop the 'the row was inserted but the email never went out' class of bugs in Claude Agent SDK apps. A production-grade walkthrough of the Transactional Outbox pattern using Postgres and Cloudflare Queues.

claude-agent-sdk6transactional-outboxproduction111reliability17postgresqueues

Premium Article

If you have shipped anything serious with Claude Agent SDK, you have probably seen the bug at least once. The order row exists. The user never got an email. Or worse, you charged the card but never wrote the receipt to your database. Retries help with the inverse failure (running the same side effect twice), but they cannot conjure a side effect that never started.

I learned this running membership flows for four sites on top of Claude Agent SDK and Stripe. In the first three months I caused three near-incidents because a tool function did db.insert(...) immediately followed by sendEmail(...), and a SDK timeout between those two lines was enough to silently drop the email forever. Idempotency keys do not save you here — you cannot deduplicate a call that was never made.

The structural fix for this is the Transactional Outbox pattern. It is well-known in microservices literature, but most write-ups assume a long-running Java service, not a Claude agent loop where a tool call is the unit of work. This guide is the version I wish I had: a concrete, copy-pasteable Postgres + Cloudflare Queues setup that drops into a Claude Agent SDK app and turns "the side effect must run" from a wish into an invariant.

Why Agent SDK apps lose side effects

A few failure modes show up over and over once an agent is in production.

A tool body crashes between two awaits. The DB write to orders succeeded; the call to mailer.send was about to start when the worker hit its CPU limit or timed out. The DB now claims an order exists that no human has been notified about.

A model response gets corrupted and the agent loop restarts. From the model's perspective, the previous tool already returned a result, so it never asks for it again. The side effect that never ran is now invisible to the LLM as well.

A long-running agent is paused and resumed the next day. Claude Agent SDK happily restores conversation state, but any "I will send this email when convenient" intent that was only living in process memory is gone.

Idempotency keys (covered in Designing idempotency for Claude Agent SDK) ensure a side effect runs at most once. The Outbox ensures it runs at least once. You need both, but the Outbox is the harder of the two to retrofit, so it deserves its own treatment.

What the pattern actually is

In one sentence: instead of performing a side effect directly, write a request for that side effect into an outbox table inside the same database transaction as your business write. A separate dispatcher reads the outbox and forwards the request to a queue. Consumers do the real work.

[Agent tool]
    │
    ├─ BEGIN
    ├─ INSERT INTO orders ...
    ├─ INSERT INTO outbox (topic, payload) VALUES ('mail.send', ...)
    └─ COMMIT
              │
              ▼
[Outbox dispatcher]
    │
    ├─ SELECT pending rows
    ├─ Publish to Cloudflare Queues / SNS / Kafka
    └─ UPDATE outbox SET dispatched_at = now()
              │
              ▼
[Consumer]
    └─ Sends email, charges card, posts to Slack, etc.

Because the business row and the side-effect intent are committed atomically, "if the row exists, the intent exists" is now a database invariant. The dispatcher only has to deliver the intent at-least-once. Combined with idempotent consumers, you get effectively-once semantics without a distributed transaction.

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
You will be able to architect Claude Agent SDK apps so that crashes mid-tool no longer leave you with 'the order was saved but Stripe was never called' inconsistencies
You will walk away with a copy-paste-ready Postgres outbox table, a Cloudflare Queues dispatcher, and a consumer skeleton you can drop into any TypeScript project today
You will know how to monitor outbox lag, choose partition keys, and migrate existing tools incrementally without a big-bang rewrite
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-06-14
Making Claude Agent SDK Tools Idempotent — Stopping Double Execution with Deterministic Keys and an Outbox
An implementation log for stopping a Claude Agent SDK retry or session resume from processing the same payment twice. Three patterns — deterministic idempotency keys, an outbox, and a lightweight wrapper — with runnable code and production metrics.
API & SDK2026-06-27
When Claude API Streaming Stops Without an Error: Detecting Silent Stalls and Resuming Mid-Stream
How to catch the 'silent stall' where Claude API streaming stops with no exception at all, using a content-level watchdog that times the gap between tokens, plus a resume path that carries received text forward as an assistant prefill, and a four-layer timeout budget for long-running automation.
API & SDK2026-05-08
Implementing the Saga Pattern in Claude Agent SDK — Compensating Transactions and Idempotency
A practical guide to building safe multi-step Claude Agent SDK workflows. We cover compensating transactions, idempotency keys, and partial-failure state recovery, all from patterns that have run in production.
📚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 →