Part 4: Production
Reliability: loops, limits and humans
Put a harness around the loop so one bad run costs you minutes and cents, not a weekend and a budget review
In short
Reliability comes from a harness that enforces limits in code on every step and hands off instead of crashing.
Key ideas
- Four hard limits (iteration cap, cost budget, timeout, kill switch) at three scopes; a trip hands off, never crashes
- Pick a HITL pattern per tool and watch for approval fatigue
- Every change climbs the ladder by run counts; rollback is a flag flip
A summary only. The reasoning, examples, checklist and what to do on Monday are in the chapter. Read it in the book
10
steps: a sane day-one iteration cap
300
clean runs bound a failure rate at about 1%
Inside the chapter
- 1Why reliability is a design problem, not a model problem
- 2Failure modes catalog
- 3Harness controls
- 4Retries, idempotency and compensation
- 5Humans in the loop
- 6Graceful degradation and fallbacks
- 7Rollout: the ladder
- 8Putting it together: a reliability review
Try it: which limit trips first?
A run loops on the same call. Set the limits and see where it stops.
Steps before stop
10
Spend at stop
$0.40
Exit reason
step_limit
The step cap trips first, after 10 steps
Without either limit, this loop runs until someone notices the bill. Keep limits at run, conversation and tenant scope.
Illustrative: flat cost per step. Real steps cost more as context grows.
Go further: free on this site
Questions readers asked about this chapter, a 5-question self-check with explanations, and every source it cites.
Questions readers ask (3)
3 questions. Open one to read the answer.
I build on a canvas. What do Chapter 13's platform settings leave out?
The failure path. Ch 13, The harness on a canvas maps each limit to a setting; add an error workflow that notifies a human instead of retrying forever, and treat a tripped step cap as a handoff with a reason, so the queue shows why the run stopped.
I work alone and cannot be on call at 3 a.m. What is the minimum safe setup?
Chapter 13's Solo minimum harness box has the caps and the phone kill switch. What it leaves out is the user side: end every handoff in an honest message ("we will reply by 10:00") and a queue you clear in the morning, and keep writes in draft mode until a few weeks show no surprises. A slow answer at 9 a.m. beats a confident wrong one at 3 a.m.
What if the model provider itself is down or rate limiting me?
Treat it as one more dependency with a circuit breaker. Retry rate limits and timeouts with backoff inside the run's remaining time and budget, and cap retries: a 429 is not always your own limit (the false 429s in Ch 8). If the breaker opens, move down the fallback chain. A second model from the same vendor may share its failure (the Vertex Gemini outage in Ch 8), so the fallback is a second vendor or a non-LLM path.
Answered in the book, not repeated here: See Chapter 8, HITL patterns; See Chapter 8, Rollout: the ladder; See Chapter 7, Choosing an engine
Self-check (5)
Score: 0 / 5 (0 answered)
Question 1 of 5
Your system prompt says "never issue refunds above EUR 100". Why is that not enough?
Show the answer
Answer: C.
Prompts are suggestions; a rule that must always hold needs a deterministic check in code, such as an amount limit in the refund tool. Models do follow system prompts, which is exactly why the rare failure is so easy to miss.
Question 2 of 5
An agent had a step cap, yet one weekend cost as much as a normal month. What most likely let it through?
Show the answer
Answer: A.
A per-run cap cannot stop a conversation that keeps starting runs; limits must exist at run, conversation and tenant scope with counters outside the process. A tighter run cap or a timeout would still reset on each new run.
Question 3 of 5
Approvals on the send-email tool show a 99.6% approval rate and a median time to approve of 3 seconds. What does that tell you?
Show the answer
Answer: B.
Near-total approval in seconds means humans click without reading, so you pay for oversight without getting it. A second approver usually makes fatigue worse, not better.
Question 4 of 5
Which tool error should the harness retry automatically, with backoff?
Show the answer
Answer: D.
Transient errors (rate limits, network failures, timeouts) are worth retrying within the remaining budget. Validation errors and business refusals go back to the model as tool errors so it can correct itself; retrying them only repeats the failure.
Question 5 of 5
A canary ran 300 times with zero severe failures. What can you claim?
Show the answer
Answer: C.
By the rule of three, zero failures in n runs bounds the rate at about 3/n, so 3/300 = 1%. Claiming zero confuses "not observed" with "impossible", and a 0.1% bound would need about 3,000 clean runs.
Sources
Sources cited
- Arize AI (Aryan Kargwal), Why AI Agents Break: A Field Analysis of Production Failures, January 2026. arize.com
- AI SDK docs, Building Agents (v7), accessed November 2026. ai-sdk.dev
- Vercel, AI SDK 6, December 2025. vercel.com
- n8n docs, Tools Agent, accessed November 2026. docs.n8n.io
- CrewAI docs, Changelog, accessed November 2026 (October 2026 entry). docs.crewai.com
- OpenAI Developer Community, My Codex session hit its subscription limit, then wrote its own metered API runner (user report), August 2026. community.openai.com
- OpenAI status, Elevated error rates on Codex, ChatGPT and Responses API (incident write-up), June 2026. status.openai.com
- DBOS, DBOS (product site and FAQ), accessed November 2026. dbos.dev
- Vercel, AI SDK 7 is now available, June 2026. vercel.com
- LangChain docs, Prebuilt middleware, accessed November 2026. docs.langchain.com
- Claude Code docs, Hooks reference, accessed November 2026. code.claude.com
- Inngest, Durable Agents (docs), accessed November 2026. inngest.com
- LangChain docs, Interrupts (LangGraph), accessed November 2026. docs.langchain.com
- Temporal docs, Workflow message passing - Python SDK, accessed November 2026. docs.temporal.io
- OpenAI, Developer mode (API docs), accessed November 2026. developers.openai.com
- Anthropic, How we contain Claude across products, May 2026. anthropic.com
- Anthropic, How we built Claude Code auto mode, March 2026. anthropic.com
- OpenAI status, Elevated error rates (incident write-up, 2026-07-25), July 2026. status.openai.com
- OpenAI status, Elevated error rates (incident write-up, 2026-07-23), July 2026. status.openai.com
- Anthropic, Claude Fable 5.2 and Mythos 5.2, November 2026. anthropic.com
- Google Cloud Service Health, Vertex Gemini API incident 41E5S3mkTGDfkZuJZH5k (incident report), March 2026. status.cloud.google.com
- AWS, Release notes for Amazon Bedrock AgentCore, accessed November 2026. docs.aws.amazon.com
- Wikipedia, Rule of three (statistics), accessed November 2026. en.wikipedia.org
- Anthropic, An update on recent Claude Code quality reports, April 2026. anthropic.com
Further reading
- Google, Site Reliability Engineering, chapter 22, Addressing Cascading Failures. sre.google
- Martin Fowler, Circuit Breaker, March 2014. martinfowler.com
- Brandur Leach (Stripe), Designing robust and predictable APIs with idempotency, February 2017. stripe.com
- Microsoft Azure Architecture Center, Saga distributed transactions pattern, accessed November 2026. learn.microsoft.com