---
title: "Agent Reliability Lifecycle: Code, Test, Contain, Observe"
description: "The agent reliability lifecycle: code (build), test (evaluate), contain (deploy safely), observe (monitor) and a learning loop, and what each catches."
url: https://reliableagents.org/agent-reliability-lifecycle/
updated: 2026-11-26
publisher: Trustabl (https://trustabl.ai)
---

# The agent reliability lifecycle

Reliability isn't one tool. It is four stages, **Code, Test, Contain and Observe** (which many teams call build, test, deploy and monitor), joined by a **Learn** loop that turns production failures into fixes. Teams that rely on a single stage, usually observability, find problems late and fix them slowly.

| Stage | Question | What it covers | When |
|---|---|---|---|
| **1. Code** (build) | Is the agent written to be reliable? | Tool definitions, timeouts, loop limits, reliability rules for coding agents | While writing code |
| **2. Test** (evaluate) | Does the code have gaps, and does the agent behave correctly every time? | Static analysis, repeated-run evals, scenario and fault-injection tests | Every pull request |
| **3. Contain** (deploy safely) | If it goes wrong, how much damage can it do? | Sandboxes, least privilege, budgets, external policy, guardrails, approval gates | Before release and at runtime |
| **4. Observe** (monitor) | What did it do, why, and under whose authority? | OpenTelemetry traces, reliability labels and rules, kill switches | In production |
| ↻ **Learn** | How does production make the next version more reliable? | Failures become new rules, evals and code fixes | Continuously |

## Where reliability comes from

> **Reliability is built in and tested. Containment limits the damage when an agent fails anyway. Observability shows what to fix next.**

| Dimension | Code / Test | Contain | Observe / Learn |
|---|---|---|---|
| Consistency (same result every run) | **Creates it** | Helps: fewer paths to wander down | Measures it in production |
| Robustness (handles bad inputs and tool faults) | **Creates it** | — | Finds new failure cases |
| Predictability (knows when it's done or stuck) | **Creates it** | — | Checks calibration against real outcomes |
| Safety (failures are bounded) | Helps | **Creates it** | Detects failures; enables the kill switch |

Containment helps only when the agent can still reach every app and data source its task needs. A sandbox that blocks required access causes failures, so base least privilege on observed needs.

## Shift reliability left

The earlier a stage, the cheaper the fix. A missing timeout found in **Code** or **Test** is a one-line change in a pull request. The same gap found in **Observe** is an incident, a trace investigation and a hotfix. Start with Code and Test, then add Contain and Observe as the agent gains autonomy.

## Production controls by stage

Twelve production controls map onto the stages.

| Stage | Controls |
|---|---|
| Code | Tool contracts, explicit authority, distinct agent identity |
| Test | Continuous evaluation, an independent verification step |
| Contain | Least privilege, runtime budgets and timeouts, external policy enforcement, approval gates |
| Observe | Reconstructible traces, recovery and kill switches, authority lineage and continuous governance |

## Matching stages to autonomy

Agents should earn authority in steps, with each step backed by evidence from the stages before it.

| Autonomy | What the agent may do | Minimum stages |
|---|---|---|
| Observe | Actions are logged, not carried out | Code, Observe |
| Draft | Prepares actions for a human to execute | + Test |
| Act with approval | Executes after explicit sign-off | + Contain (approval gates) |
| Act within scope | Acts alone inside a narrow, verified boundary | + Contain (sandbox, least privilege) |
| Expanded authority | Scope widens as evidence builds | All four stages and the Learn loop |

## Further reading

- [The Agent Development Lifecycle](https://langchain.com/blog/the-agent-development-lifecycle) (LangChain)
- [Agentic Secure Development Lifecycle](https://labs.cloudsecurityalliance.org/agentic/agentic-secure-development-lifecycle-v1/) (Cloud Security Alliance)
- [What Production Controls Do Reliable Agents Need?](https://www.trustabl.ai/blog/production-controls-for-reliable-agents/) (Trustabl)
- [What Is Progressive Autonomy?](https://www.trustabl.ai/blog/progressive-autonomy-reliable-agents-earn-authority/) (Trustabl)
- [Agent Reliability guide](https://www.trustabl.ai/agent-reliability/) (Trustabl)

**Tools for each stage:** [Code](https://reliableagents.org/tools/agent-coding/) · [Test](https://reliableagents.org/tools/agent-testing/) · [Contain](https://reliableagents.org/tools/agent-sandboxes/) · [Observe](https://reliableagents.org/tools/agent-observability/) · [Learn](https://reliableagents.org/tools/agent-feedback-loop/)

**Next:** [Agent reliability checklist](https://reliableagents.org/agent-reliability-checklist/)
