# 11 patterns for AI systems that survive production. Source: https://customlabs.io/patterns/ Updated: 2026-10-29 Patterns This is the companion to the failure-mode field guide. That guide shows what breaks. This library shows how to build so it does not. Each pattern has trade-offs and signals to measure. Failure mode → pattern that prevents it If you have this failure mode Build with this pattern [Stale index serves deleted content](https://customlabs.io/failure-modes/stale-index-serves-deleted-content/) [Change-data-capture ingest](https://customlabs.io/patterns/change-data-capture-ingest/) [Chunk boundary splits the answer](https://customlabs.io/failure-modes/chunk-boundary-splits-the-answer/) [Structure-aware chunking](https://customlabs.io/patterns/structure-aware-chunking/) [Similarity is not relevance](https://customlabs.io/failure-modes/similarity-is-not-relevance/) [Retrieve-then-rerank](https://customlabs.io/patterns/retrieve-then-rerank/) [Unbounded agent loop](https://customlabs.io/failure-modes/unbounded-agent-loop/) [Bounded agent loop](https://customlabs.io/patterns/bounded-agent-loop/) [Tool argument hallucination](https://customlabs.io/failure-modes/tool-argument-hallucination/) [Typed tool contract](https://customlabs.io/patterns/typed-tool-contract/) [Silent tool failure](https://customlabs.io/failure-modes/silent-tool-failure/) [Typed tool contract](https://customlabs.io/patterns/typed-tool-contract/) , [Trace-first observability](https://customlabs.io/patterns/trace-first-observability/) [Context overflow drops the task](https://customlabs.io/failure-modes/context-overflow-drops-the-task/) [Intent router to specialists](https://customlabs.io/patterns/intent-router-to-specialists/) [Vibes-based prompt regression](https://customlabs.io/failure-modes/vibes-based-prompt-regression/) [Golden-set gate in CI](https://customlabs.io/patterns/golden-set-gate-in-ci/) [Judge prefers its own output](https://customlabs.io/failure-modes/judge-prefers-its-own-output/) [Golden-set gate in CI](https://customlabs.io/patterns/golden-set-gate-in-ci/) [Retry-amplified spend](https://customlabs.io/failure-modes/retry-amplified-spend/) [Bounded agent loop](https://customlabs.io/patterns/bounded-agent-loop/) , [Model cascade](https://customlabs.io/patterns/model-cascade/) [Prompt cache never hits](https://customlabs.io/failure-modes/prompt-cache-never-hits/) [Stable-prefix prompt caching](https://customlabs.io/patterns/stable-prefix-prompt-caching/) [Injection via retrieved content](https://customlabs.io/failure-modes/injection-via-retrieved-content/) [Human checkpoint before irreversible actions](https://customlabs.io/patterns/human-checkpoint-before-irreversible/) ## Agent control flow Agent control flow · 5 min read ### [Intent router to specialists](https://customlabs.io/patterns/intent-router-to-specialists/) A fast, cheap classifier routes each request to one narrow specialist agent. [Read the pattern →](https://customlabs.io/patterns/intent-router-to-specialists/) Agent control flow · 5 min read ### [Bounded agent loop](https://customlabs.io/patterns/bounded-agent-loop/) A bounded agent loop runs under an explicit step budget and token ceiling. [Read the pattern →](https://customlabs.io/patterns/bounded-agent-loop/) ## Retrieval Retrieval · 5 min read ### [Structure-aware chunking](https://customlabs.io/patterns/structure-aware-chunking/) Chunk boundaries follow the document's own structure, such as headings and table rows. [Read the pattern →](https://customlabs.io/patterns/structure-aware-chunking/) Retrieval · 5 min read ### [Retrieve-then-rerank](https://customlabs.io/patterns/retrieve-then-rerank/) A cheap first pass pulls 50 to 100 candidate documents. [Read the pattern →](https://customlabs.io/patterns/retrieve-then-rerank/) Retrieval · 5 min read ### [Change-data-capture ingest](https://customlabs.io/patterns/change-data-capture-ingest/) The ingest pipeline subscribes to change events from the source system. [Read the pattern →](https://customlabs.io/patterns/change-data-capture-ingest/) ## Reliability & guardrails Reliability & guardrails · 5 min read ### [Typed tool contract](https://customlabs.io/patterns/typed-tool-contract/) A strict JSON schema defines every tool argument. [Read the pattern →](https://customlabs.io/patterns/typed-tool-contract/) Reliability & guardrails · 5 min read ### [Human checkpoint before irreversible actions](https://customlabs.io/patterns/human-checkpoint-before-irreversible/) Each tool gets the narrowest permission its task needs. [Read the pattern →](https://customlabs.io/patterns/human-checkpoint-before-irreversible/) ## Evals & observability Evals & observability · 5 min read ### [Golden-set gate in CI](https://customlabs.io/patterns/golden-set-gate-in-ci/) A fixed set of human-labelled real cases runs in CI on every prompt or model change. [Read the pattern →](https://customlabs.io/patterns/golden-set-gate-in-ci/) Evals & observability · 5 min read ### [Trace-first observability](https://customlabs.io/patterns/trace-first-observability/) One trace ID follows a single request across every hop, from retrieval to each model call and tool call. [Read the pattern →](https://customlabs.io/patterns/trace-first-observability/) ## Cost & routing Cost & routing · 5 min read ### [Model cascade](https://customlabs.io/patterns/model-cascade/) A cheap, fast model tries every request first. [Read the pattern →](https://customlabs.io/patterns/model-cascade/) Cost & routing · 5 min read ### [Stable-prefix prompt caching](https://customlabs.io/patterns/stable-prefix-prompt-caching/) Put invariant content first in the prompt and per-request content last, so the shared prefix stays byte-identical and the cache hits. [Read the pattern →](https://customlabs.io/patterns/stable-prefix-prompt-caching/) No patterns match that filter yet. Questions ## Which of these do you need? The questions that come up before a team decides which patterns to adopt and which to skip. 01 How is this different from the failure-mode field guide? The failure-mode field guide is diagnostic. It starts from a symptom you already have and works backward to a root cause and a fix. This library is prescriptive. It starts from an architectural decision you make before anything breaks. The cross-reference table above links the two. Every failure mode traces to at least one pattern that prevents it. 02 Do I need all of these? No. Most systems need three or four of these patterns. Every entry has an explicit "don't use it when" section for this reason. A pattern your system does not need adds complexity debt. Start from the failure mode you are most exposed to and work from there. 03 Are these specific to one model provider? No. Every pattern here is an architectural decision, such as a routing layer or a schema. A caching order or a CI gate qualifies too. These decisions hold up whether the model behind them is a frontier API or a self-hosted open-weight model. See our take on staying model-agnostic by design. Next step A Ship Audit tells you which of these patterns your system lacks. It ranks them by what is most likely to break first. [Book a Ship Audit →](https://customlabs.io/diagnostic/ship-audit/)