Loading...

PATTERN LIBRARY

Architecture patterns for agent systems that need controls, not just prompts

Reference patterns for governance, workflow control, rollback, approvals, and production system design.

[ 01 ]
LIBRARY

PATTERN

Agent Loop Termination Pattern: Stop Conditions That Work (2026)

How to define 'done' for an agent loop: verifier done-checks, iteration caps, token/time budgets, and no-progress detection - plus the real framework defaults (LangGraph recursion_limit's 25-vs-1000 doc discrepancy, OpenAI Agents SDK max_turns=10, CrewAI max_iter=20) and how to size them so agents exit before the ceiling instead of crashing into it.

UPDATED 2026-07-26Open Pattern

PATTERN

Checkpoint and Resume Pattern for Long-Running Agents (2026)

A production architecture pattern for agents that run hours or days: checkpoint granularity, sync vs async vs exit durability, idempotent resume after interrupts, and choosing Postgres vs Redis vs object storage as the checkpoint backend - before you commit to a framework checkpointer or a durable-execution engine.

UPDATED 2026-07-26Open Pattern

PATTERN

Context Compaction Pattern for Long-Running Agents (2026)

When to compact an agent's context, what must stay verbatim, and why observation masking beat LLM summarization in JetBrains' SWE-bench runs (52% cost cut, +2.6% solve rate). Trigger thresholds, keep-zones, and the failure modes of naive summarization.

UPDATED 2026-07-26Open Pattern

PATTERN

Context Offloading Pattern for Agents (2026)

Where durable working state lives between agent loop iterations: filesystem scratchpad vs vector store vs structured memory store - a decision table by state type, grounded in Anthropic's measured 39% eval lift and 84% token reduction from memory + context editing, Claude Code's memory files, LangMem, and the Manus filesystem-as-context playbook.

UPDATED 2026-07-26Open Pattern

PATTERN

Token Cost Attribution Pattern for Multi-Tenant Agents (2026)

An architecture pattern for attributing LLM token spend to tenant, user, and feature: OTEL gen_ai semconv normalization across renamed attribute generations, streaming usage capture, cache-hit accounting at 0.1x pricing, and where Langfuse, Helicone, and LiteLLM fit.

UPDATED 2026-07-26Open Pattern

PATTERN

Cost Guardrail Pattern for Agent Platforms (2026)

A production architecture pattern for enforcing budget ceilings on AI agent platforms: per-run token caps, gateway budgets, provider spend limits, and kill switches - with real runaway-bill numbers and the exact layer each control belongs to.

UPDATED 2026-07-25Open Pattern

PATTERN

Idempotent Retry Pattern for Agent Tool Calls (2026)

How to retry failed agent tool calls without double-charging, double-emailing, or double-ticketing. Covers idempotency keys, effect journals, at-most-once vs at-least-once per tool class, and how Inngest step memoization and Temporal's activity-retry model implement the pattern.

UPDATED 2026-07-25Open Pattern

PATTERN

Model Routing Cascade Pattern for Agents (2026)

Where to set routing thresholds in a cheap-model-first cascade: which agent turns escalate to frontier models, which confidence signals to trust, and per-route cost accounting. Grounded in a real $4,660 API bill cut 70% with routing, plus RouteLLM and FrugalGPT numbers.

UPDATED 2026-07-25Open Pattern

PATTERN

Runtime Rollback Pattern for Agent Tasks (2026)

A production architecture pattern for containing damage when multi-step agent workflows fail mid-execution. Covers saga-style compensation, LangGraph checkpoints, Temporal durable execution, and EU AI Act audit requirements.

UPDATED 2026-03-13Open Pattern