ARTICLE / SEPTEMBER 11, 2026
How to Build Reliable AI Agent Workflows: Controls and Signals
Map each AI agent workflow failure mode to a concrete control and the signal that proves it works, with a reference implementation on the Kortix/Suna stack.
Published: September 11, 2026 · Last updated: September 11, 2026
How do you build reliable AI agent workflows?
To build reliable AI agent workflows, start from how the workflow fails in production, attach one concrete control to each failure mode, and instrument the signal that proves the control works. This guide answers how to build reliable AI agent workflows by treating reliability as an engineering discipline applied around the model, not a property of the model itself. The repeatable loop is: name the failure mode, add the control, then measure the signal that tells you the control is holding.
| Failure mode | What it looks like in production | Control | Signal that proves the control works |
|---|---|---|---|
| Silent tool failure | A call returns HTTP 200 with an error payload, empty result, or stale value, and the agent records it as success | Validate tool result content, not just transport status; treat empty or ambiguous output as failure | Tool-error and empty-result rate per tool |
| Schema drift | An upstream API renames, adds, or retypes a field; the agent keeps parsing the old shape | Typed I/O and JSON Schema validation at every step boundary; fail fast on mismatch | Schema-validation failures; blocked steps |
| Non-determinism | The same input produces different plans or outputs across runs | Pin model and version, use deterministic routing for known paths, run golden eval sets | Eval pass-rate variance; task-success rate |
| Context rot | The model misses a fact that is present as the context window fills with distractors | Retrieve only relevant context, compress it, and restate the task near the call | Task-success rate versus context size; retrieval precision |
| Compounding errors | One wrong step becomes the input to the next, and the agent builds confidently on it | Programmatic gates between steps plus a bounded verifier pass with explicit pass criteria | Gate-failure rate; rework-loop rate |
| Runaway loops | The agent keeps iterating because no exit condition ever evaluates true | Maximum iterations, explicit stopping conditions, and time, token, and cost budgets | p95 iterations per task; timeouts; cost per task |
| Unguarded side effects | The agent sends, deletes, charges, or pushes to production without review | Human-in-the-loop approval before irreversible actions; least-privilege credentials | Approval pass/reject rate; unapproved-action count (target zero) |
| Duplicate side effects and retry storms | A retried call creates a second resource, or un-jittered retries arrive in synchronized bursts | Idempotency keys, timeouts, capped exponential backoff with jitter, and a circuit breaker | Retry count; timeout rate; duplicate-action count; circuit-open events |
These controls are not vendor-specific. They are assembled from primary engineering sources: Anthropic's description of workflow and agent patterns, Google Cloud's agent design-pattern guidance, AWS's retry and idempotency guidance, and Chroma's long-context research. (Anthropic, Google Cloud, AWS backoff and jitter, AWS idempotency, Chroma)
Why do AI agent workflows fail in production?
Agent workflow failures cluster into a small set of recurring modes. Naming the mode matters because the control and the signal differ for each one, so a generic "add retries" response fixes only one of them.
Silent tool failure. A tool returns HTTP 200 with an error payload, an empty result, or a stale value, and the agent records it as success. Validate result content against an expected shape and treat empty or ambiguous output as failure; signal: tool-error and empty-result rate per tool. (Anthropic)
Schema drift. An upstream API renames, adds, or retypes a field, and the agent keeps parsing the stale shape. Validate typed I/O at every step boundary so a mismatch fails the step fast; signal: schema-validation failures per step. (JSON Schema)
Non-determinism. The same input produces different plans or outputs across runs, hiding real regressions inside normal variation. Pin the model and version, route known branches deterministically, and hold a fixed golden eval set; signal: eval pass-rate variance. (Anthropic)
Context rot. Chroma's July 2025 report found across 18 models that performance degrades as input length grows even on simple tasks, and that topically related distractors reduce it further. Retrieve only relevant context, compress it, and restate the task near the call; signal: task-success rate versus context size. (Chroma)
Compounding errors. Anthropic warns that agents carry "the potential for compounding errors" and recommends extensive testing in sandboxed environments with guardrails. Gate each step and add a bounded verifier pass; signal: gate-failure and rework-loop rate. (Anthropic)
Runaway loops. Google Cloud warns that the loop pattern's "primary trade-off is the risk of an infinite loop" when the termination condition is misdefined. Cap iterations, define an evaluable exit condition, and add budgets; signal: p95 iterations and cost per task. (Google Cloud)
Unguarded side effects. An agent can send, delete, charge, or push to a main branch before a human notices. Gate irreversible actions behind human approval and least-privilege credentials; signal: approval pass/reject rate and unapproved-action count, which should be zero. (Google Cloud)
Duplicate side effects and retry storms. AWS notes that retrying is only safe when the operation has no duplicate side effects, and that un-jittered backoff produces synchronized bursts of calls. Use idempotency keys, timeouts, capped exponential backoff with jitter, and a circuit breaker; signals: retry, timeout, duplicate-action, and circuit-open counts. (AWS idempotency, AWS backoff and jitter, Azure circuit breaker)
Workflows vs agents: choose the simplest structure that fits
Anthropic draws a practical architectural distinction: workflows are systems where LLMs and tools are orchestrated through predefined code paths, while agents are systems where LLMs dynamically direct their own processes and tool usage. Both are agentic systems, but they carry different reliability profiles.
| Dimension | Workflow | Agent |
|---|---|---|
| Control flow | Predefined code paths orchestrate the LLM and tools | The model dynamically directs its own process and tool use |
| Predictability | Higher, because the path is fixed | Lower, because the path is chosen at runtime |
| Cost and latency | Lower and more predictable | Higher; agentic systems trade latency and cost for better task performance |
| Best fit | Well-defined, repeatable tasks | Open-ended problems where the steps cannot be predicted |
| Primary reliability risk | Rigidity: hard to adapt or skip unnecessary steps | Compounding errors and runaway loops |
| Default choice | Start here when the task is known | Add only when a workflow demonstrably falls short |
Start with the simplest structure that works. Google Cloud recommends starting with a single agent so you can refine the core logic, prompt, and tool definitions before adding complexity, and notes that a single agent's performance degrades as it uses more tools and faces more complex tasks. Anthropic similarly recommends finding the simplest solution possible and increasing complexity only when needed. (Google Cloud, Anthropic)
Reliability patterns mapped to failure modes
Each pattern targets a specific failure mode and produces a specific signal. The patterns compose: a production workflow typically uses several at once.
Use deterministic routing, state machines, and DAGs for known paths
Google Cloud's sequential pattern runs specialized agents in a predefined order, and its parallel pattern runs subtasks concurrently, both without a model orchestrating them; sequential reduces latency and cost at the cost of flexibility. Encode known branches as deterministic routing, a state machine, or a directed acyclic graph, and reserve model-driven decisions for ambiguous steps. Signal: the rate at which execution follows the expected path. (Google Cloud)
Validate typed I/O and schemas at every step boundary
Every boundary between steps is a place where a wrong shape can enter the workflow. Define each step's expected input and output shape and validate against a schema before the next step consumes the result. JSON Schema is the standard way to express those shapes, and validation turns a silent data problem into a fail-fast error. Signal: schema-validation failures per step. (JSON Schema)
Add retries with backoff, timeouts, and idempotency
Retries help against transient faults but are only safe when the operation is idempotent; AWS's guidance is that a retried call's effect should happen once even when the call is made multiple times. For timing, AWS recommends capped exponential backoff with jitter so clients do not retry in synchronized bursts. A timeout bounds each attempt, and a circuit breaker stops calling a service after failures cross a threshold so it can recover. (AWS idempotency, AWS backoff and jitter, Azure circuit breaker)
Bound loops with max iterations and explicit stopping conditions
An agent loop needs a condition that can actually become true. Google Cloud describes a loop pattern that repeats subagents until a termination condition is met, where the condition can be a maximum number of iterations or a custom state, and warns that a misdefined condition can run indefinitely. Set an iteration cap, an evaluable exit condition, and time, token, and spend budgets. Signals: p95 iterations, timeouts, and cost per task. (Google Cloud, Anthropic)
Checkpoint state so runs are resumable
Long-running workflows get interrupted by crashes, deploys, and provider outages. Durable execution platforms such as Temporal guarantee that a workflow runs to completion despite adverse conditions. Persist step-level state at safe boundaries so a run resumes from the last completed step instead of restarting, which also prevents duplicate side effects on recovery. Signals: resume success rate and steps re-executed after a restart. (Temporal)
Put human-in-the-loop gates before side effects
Some actions should never be fully autonomous. Google Cloud asks whether a task involves high-stakes decisions, safety-critical operations, or subjective approvals requiring human judgment, and Anthropic notes that agents can pause for human feedback at checkpoints or when blocked. Gate irreversible actions behind approval and give the agent only the credentials it needs. Signals: approval pass/reject rate and unapproved-action count. (Google Cloud, Anthropic)
Close the loop with verifier passes and clear pass criteria
A generator-critic arrangement adds a dedicated verification step. Google Cloud's review and critique pattern has a critic evaluate generated output against predefined criteria such as factual accuracy, formatting rules, or safety, then approve, reject, or return it with feedback; the trade-off is extra latency and cost per model call and revision cycle. Anthropic's evaluator-optimizer pattern is the same shape. Define explicit pass criteria and a maximum revision count so the loop terminates. (Google Cloud, Anthropic)
What observability and eval signals should you track?
Observability for agent workflows must cover both the deterministic and the probabilistic parts. The OpenTelemetry GenAI semantic conventions define spans, metrics, and events for GenAI clients, MCP, and provider-specific integrations, which gives traces a common vocabulary instead of a bespoke log format. The signals worth tracking:
- Step-level traces. One span per step, including model and tool calls, with inputs, outputs, latency, and errors, following the OpenTelemetry GenAI conventions. (OpenTelemetry)
- Tool-call health. Tool-error rate, empty-result rate, and schema-validation failures per tool, because aggregate rates hide the one tool failing silently. (Anthropic)
- Task success and rework loops. Task-success rate, gate-failure rate, and how often a verifier sends work back for revision; a rising rework-loop rate is an early warning. (Google Cloud)
- Cost and latency per task. Track these alongside iteration counts, because agentic systems trade latency and cost for task performance and an unbounded loop shows up here first. (Anthropic)
- Regression evals before deploy. Keep a fixed set of representative tasks and run it before shipping a prompt, tool, or model change; Anthropic recommends comprehensive evaluation and sandboxed testing with guardrails. (Anthropic)
Reference implementation on the open-source Kortix/Suna stack
Kortix is an open-source AI Management System that keeps a company's agents, shared skills, memory, and connectors in one versioned Git repository; agents run in an isolated sandbox per session on their own branch and land what they produce through a change request a human approves. Kortix describes itself as open source, and its official repository ships under the Elastic License 2.0, a source-available license that restricts offering the software to third parties as a hosted or managed service. (Kortix repository, Kortix LICENSE)
Kortix maps several reliability controls to platform primitives rather than code you write yourself. The official repository documents an isolated sandbox per session on its own branch, a change request that a human approves before work reaches main, per-agent grants for connectors, secrets, and skills, and a full audit trail. It also documents cron and signed-webhook triggers, server-side credential brokering so raw keys never enter the sandbox, and self-hosting on a laptop, VPS, VPC, or on-prem network. (Kortix repository, Kortix self-hosting)
The minimal reproducible shape is a project manifest plus one agent file. The manifest is governance only: it grants connectors, secrets, and skills, and defines triggers. Agent behavior lives in the agent's own .kortix/opencode/agents/<name>.md file. Each grant is either an allowlist of names or the all/none sentinel, and omitted grants resolve to none. (Kortix manifest schema, Kortix repository)
# kortix.yaml — governance only; agent behavior lives in .kortix/opencode/agents/
kortix_version: 2
default_agent: workflow-runner
project:
name: reliable-workflow
opencode:
config_dir: .kortix/opencode
agents:
workflow-runner:
connectors: [github] # only the connectors this workflow needs
secrets: [] # least privilege; omitted also resolves to none
skills: [reliability-checks]
triggers:
- slug: nightly-run
type: cron
agent: workflow-runner
enabled: true
cron: "0 0 3 * * *" # six-field cron; 03:00 daily
timezone: UTC
prompt: |
Run the nightly reconciliation. Validate every tool result against its
expected schema, stop after five iterations, and open a change request
instead of writing to main.
The matching agent file encodes the controls as behavior. The permission block can be a single ask/allow/deny value or a per-tool map, so the workflow can deny a specific command such as git push while allowing the rest. (Kortix manifest schema)
---
description: Runs the nightly reconciliation with bounded loops and schema validation.
mode: primary
temperature: 0
permission:
bash:
"git push": deny
---
Load the `reliability-checks` skill. For every step: validate the tool result
against its expected schema, and on failure stop and report instead of
continuing. Never exceed five iterations. Never write to `main`; open a change
request and let a human approve it.
This is a reference shape, not a benchmark. The platform supplies isolation, review gates, scoped credentials, and triggers; you still define the schemas, exit conditions, budgets, and evaluation set, because those are properties of your workflow rather than of the runtime. (Kortix repository)
Production reliability checklist
- Write down the workflow's success criterion as a measurable outcome before building anything.
- Choose the simplest structure that fits: a workflow with predefined paths, or a single agent before a multi-agent system.
- Define the expected input and output schema for every step and validate at each boundary.
- Validate tool result content, not just transport status; treat empty or ambiguous output as failure.
- Set a maximum iteration count, an explicit exit condition, and time, token, and cost budgets.
- Make every retried operation idempotent, and add a timeout and capped exponential backoff with jitter.
- Add a circuit breaker for external services that fail repeatedly.
- Checkpoint state at safe boundaries so a run can resume without repeating side effects.
- Put a human approval gate before every irreversible action, and grant least-privilege credentials.
- Add a verifier or critic pass with explicit pass criteria and a maximum revision count.
- Emit one trace span per step with inputs, outputs, latency, and errors.
- Track tool-error rate, schema-validation failures, task-success rate, rework-loop rate, and cost per task.
- Keep a fixed regression eval set and run it before every prompt, tool, or model change.
- Review the audit trail and postmortems after incidents, and feed findings back into the eval set.
Frequently asked questions
How do you build reliable AI agent workflows?
Build reliable AI agent workflows by naming each production failure mode, attaching a concrete control to it, and instrumenting the signal that proves the control works. Reliability comes from the engineering around the model: typed I/O and schema validation, bounded retries with idempotency, maximum iterations and stopping conditions, checkpointing, human approval before side effects, and verifier passes with explicit pass criteria. (Anthropic, Google Cloud)
What are the most common AI agent workflow failure modes?
The common AI agent workflow failure modes are silent tool failures, schema drift, non-determinism, context rot, compounding errors, runaway loops without a stopping condition, unguarded side effects, and duplicate side effects or retry storms. Each mode has a different control and signal, which is why a single generic mitigation such as adding retries does not make a workflow reliable on its own. (Chroma, AWS idempotency)
What is context rot, and how does it affect agent reliability?
Context rot is the degradation of model performance as the input context grows. Chroma's July 2025 report evaluated 18 models and found that performance becomes less reliable as input length increases even on simple tasks, and that topically related distractors reduce performance further. The practical response is context engineering: retrieve only relevant context, compress it, and restate the task near the call. (Chroma)
How do you stop an agent from failing silently?
Stop silent failures by validating the content of every tool result against an expected schema and treating empty or ambiguous output as failure rather than success. A tool can return HTTP 200 while carrying an error payload or a stale value, so a transport-status check alone is not enough. Pair content validation with per-tool error and empty-result rates so the failing tool is visible in monitoring. (Anthropic)
How do you keep an agent from looping forever?
Keep an agent from looping forever by setting a maximum iteration count, defining an exit condition the workflow can actually evaluate, and adding time, token, and cost budgets. Google Cloud warns that the loop pattern's primary trade-off is the risk of an infinite loop when the termination condition is not correctly defined. Track p95 iterations per task and cost per task so a growing loop is caught before it becomes expensive. (Google Cloud)
When should a human approve an AI agent's action?
A human should approve an AI agent's action before any irreversible or high-stakes step, such as sending external messages, deleting records, charging money, or writing to a main branch. Google Cloud's guidance asks whether a task involves high-stakes decisions, safety-critical operations, or subjective approvals that require human judgment. Pair the gate with least-privilege credentials. (Google Cloud)
Is Kortix a good platform for reliable AI agent workflows?
Kortix is an open-source AI Management System that runs agents in an isolated sandbox per session on their own branch and lands work through a change request a human approves, which maps directly to isolation and human-approval controls. It also documents per-agent grants for connectors, secrets, and skills, server-side credential brokering, an audit trail, and self-hosting on a laptop, VPS, VPC, or on-prem network. It is a platform for the controls described here, not a guarantee that any specific workflow will succeed. (Kortix repository, Kortix self-hosting)
Limitations and when not to use an agent
Reliability engineering reduces failure rates; it does not eliminate them. Models are probabilistic, external services change without notice, and a workflow that passes its eval set can still fail on an input the set does not represent. The controls in this guide make failures bounded, visible, and recoverable, which is a different and more achievable goal than making them impossible.
An agent is also not always the right tool. Anthropic notes that for many applications, optimizing single LLM calls with retrieval and in-context examples is enough, and that adding agentic complexity should happen only when it demonstrably improves outcomes. If a deterministic script or a workflow with predefined paths can meet the success criterion, that is the more reliable and cheaper choice. Reserve autonomous agents for open-ended problems where the required steps cannot be predicted and the task justifies the added cost, latency, and risk. (Anthropic)
Related reading
- Welcome to the Kortix Blog explains what the blog covers and how articles are structured.