# Agent Reliability Playbook

> [View this product on lib-pro](https://lib-pro-3f8437.gitlab.io/libs/agent-reliability-playbook) · Ship agents that work in production. The 7-layer reliability stack.

**Outcome:** Ship AI agents that work in production, not just on demos.

The 7-layer reliability stack for shipping AI agents that work in production. 7 skills covering orchestration, tool design, state management, error recovery, observability, stopping conditions, and the catalog of 15 anti-patterns. Adapters for pi-agent, Claude Code, Cursor, Cline, and any tool that reads a system-prompt file. The same discipline that prevents the $400 OpenAI bill from a runaway loop, the email-to-the-wrong-recipient, and the agent that 'works on demos but fails with users'.

**Price:** £45 — lifetime · **Category:** Production AI Skills · **Tech:** pi-agent, Claude Code, Cursor, Cline, Markdown

| Metric | Value |
|--------|-------|
| Skills | 7 |
| Anti-patterns | 15 |
| Tool adapters | 5 |
| Pre-launch items | 12 |

## Quick start

```bash
tar -xzf agent-reliability-playbook-0.1.0.tgz && cd agent-reliability-playbook-0.1.0
```

- # Pick your agent host
- ls adapters/
- # pi-agent (recommended): cp -r skills/* ~/.pi/agent/skills/
- # Claude Code: cp -r adapters/claude-code/commands/* .claude/commands/
- # See INSTALL.md for Cursor / Cline / Aider

## Code preview

```
# agent-reliability — Master Orchestrator

You have an LLM agent that demos beautifully. Three prompts in, it nails the task. Six prompts in, it hallucinates a tool call. Ten prompts in, it loops until your OpenAI bill explodes.

This is the master playbook. It teaches the 7-layer reliability stack every production agent needs. It routes to six specialist skills based on which layer you're working on.

## The 7-Layer Reliability Stack

Every production agent needs all seven layers. Skip one and the agent breaks in production.

┌─────────────────────────────────────────────────┐
│ 7. Anti-Patterns Catalog   → what NOT to do    │
├─────────────────────────────────────────────────┤
│ 6. Stopping Conditions     → when to stop       │
├─────────────────────────────────────────────────┤
│ 5. Observability           → what's happening   │
├─────────────────────────────────────────────────┤
│ 4. Error Recovery          → what fails         │
├─────────────────────────────────────────────────┤
│ 3. Agent State             → what to remember   │
├─────────────────────────────────────────────────┤
│ 2. Tool Design             → what the agent     │
│                              can call           │
├─────────────────────────────────────────────────┤
│ 1. Orchestration           → how it decides     │
└─────────────────────────────────────────────────┘

The patterns: walk top-down during debug (most bugs are familiar). Walk bottom-up during build (orchestration → tool design → state → error recovery → observability → stopping → anti-patterns review).

## Routing Table

| You see this in prod | Load this skill |
|---|---|
| Agent calls the wrong tool | tool-design |
| Agent loops forever burning tokens | stopping-conditions |
| Agent fails to recover from a tool error | error-recovery |
| Agent loses context after 20 turns | agent-state |
| Agent produces output but you can't debug | agent-observability |
| Familiar failure mode | anti-patterns |

## Pre-Launch Checklist (Bold = non-negotiable)

- Orchestration chosen deliberately
- Tool definitions have descriptions the model can read
- Tool calls validated before execution
- State management strategy defined
- Error recovery policy for every tool call
- Observability is logging
- Stopping conditions in code
- Eval set covers happy path + 3 adversarial cases
- Cost estimate per session
- Latency budget per turn
- Rollback plan
- 5 prod transcripts reviewed end-to-end
```

## Use cases

### 1. Your first production AI agent

You've built an agent prototype. It works on 3 test cases. Now you need to ship it to real users without breaking everything. The 7 layers are the discipline.

**Outcome:** Ship with confidence, not crossed fingers.

### 2. Debugging a familiar failure

Agent booked 38 hotel rooms. Or sent an email to the wrong person. Or forgot the original goal after 20 turns. The anti-patterns skill is the catalog.

**Outcome:** Identify the failure in 5 minutes, not 5 days.

### 3. Training your team on agent design

New engineers joining your AI team. They need to learn the discipline before they ship. The playbook is the onboarding curriculum.

**Outcome:** Faster onboarding, fewer production incidents.

### 4. Pre-launch review for AI features

Every AI feature ships through a review checklist. The pack is the review checklist — 12 items for the orchestrator, 15 for the anti-patterns.

**Outcome:** Catch the obvious mistakes before users do.

## Built for

- AI engineers shipping their first production agent
- Senior engineers who have shipped agents and learned the hard way
- AI engineering managers who need a team-wide discipline
- Indie hackers building AI products who can't afford a production incident
- Consultants selling AI agent work who need defensible quality

## Highlights

### 7 layers, one pack

Orchestration, tool design, state, error recovery, observability, stopping, anti-patterns. Skip one and the agent breaks. The pack teaches all 7.

### Prevents the $400 bill

The runaway loop anti-pattern (AP-01) caught every AI builder. The pack teaches the cost caps, loop detection, and confirmation gates that stop it before users get charged.

### Discipline in code, not prompts

Every 'be efficient' / 'stop when done' / 'be safe' instruction in a prompt is a bug. The pack teaches the code-level patterns that actually enforce the discipline.

## What's in the box

- `7 skills` — one per reliability layer
- `5 tool adapters` — pi-agent, Claude Code, Cursor, Cline, generic
- `2 worked examples` — tool rewrite + runaway loop fix
- `Pre-launch checklist` — 12 items
- `Anti-patterns catalog` — 15 failure modes
- `Cost math per model tier` — know your bounds
- `Routing table` — which skill to load when
- `Decision trees` — workflow vs. agent vs. hybrid

## Adapters included

These skills were authored for pi-agent, but we include drop-in adapters for the major AI coding tools.

| Tool | Adapter location | What you get |
|------|------------------|--------------|
| pi-agent | `adapters/pi-agent/` | SKILL.md drop-in |
| Claude Code | `adapters/claude-code/` | .claude/commands/*.md + CLAUDE.md fragments |
| Cursor | `adapters/cursor/` | .cursorrules rule sets |
| Cline / Continue | `adapters/cline/` | System-prompt rules |
| Aider / generic | `adapters/generic/` | INSTRUCTIONS.md snippets |

**Same playbook, different packaging.** The adapters translate the methodology into the format each tool expects. Install once, swap agents without re-learning the method.

## Features

- agent-reliability skill — master orchestrator + 7-layer reliability stack + pre-launch checklist
- tool-design skill — 8 rules for the agent-computer interface (Anthropic's ACI discipline)
- agent-state skill — context budget, message trim, checkpoint/restore
- error-recovery skill — retry strategies, structured errors, idempotency keys
- agent-observability skill — structured logging, traces, replay, vendor comparison
- stopping-conditions skill — 8 hard caps + loop detection + confirmation gates
- anti-patterns skill — catalog of 15 failure modes with symptoms, cause, fix, detection
- 5 tool adapters — pi-agent, Claude Code, Cursor, Cline, generic
- 2 worked examples — tool rewrite (40%→4% wrong calls), runaway loop fix ($44→$0.35)
- Pre-launch checklist — 12 items, all checked
- Cost math per model tier — know your bounds before shipping
- Routing table — agent loads the right specialist skill for the right problem

## FAQ

### Is this just prompt engineering with extra steps?

No. The pack teaches the discipline of putting it in code, not the prompt. MAX_ITERATIONS in code, not 'be efficient'. Confirmation gates in code, not 'ask before sending'. Idempotency keys in code, not 'be careful with retries'. The patterns are about what your agent code does, not what your agent prompt says.

### Does it work with my framework? (LangChain / LangGraph / CrewAI / raw OpenAI SDK)

Yes. The pack is methodology, not framework code. It works with LangChain, LangGraph, CrewAI, Vellum, raw OpenAI SDK, or anything else. The skills are pure markdown — they teach patterns you apply to whatever you're building on.

### What's the difference vs. LangSmith / Langfuse / Helicone?

Those are observability tools — they help you see what's happening. This pack is the methodology — what to log, what to do when errors happen, when to stop. You can use the pack + an observability vendor together. The pack tells you what to instrument; the vendor helps you view it.

### Will this prevent all my agent bugs?

No. The 7 layers address the most common, expensive, familiar failure modes. They don't address novel bugs, model-specific quirks, or genuinely new patterns. The pack is discipline, not magic. But it catches 80%+ of the bugs that hit production agents.

### I'm building a single-prompt LLM feature, not an agent. Do I need this?

Probably not. The 7 layers are for agents (multi-step, tool-using, stateful). Single-prompt features have their own discipline (prompt engineering, eval, cost control), which is a different skill set. The pack is honest about this — if you don't have tools or state, you don't need the 7 layers.
