How do we build reliable workflows with AI agents?

Jonathan Galis9 min read

A reliable AI-agent workflow constrains what the agent may observe and change, records explicit state at every boundary, and provides deterministic checks, approvals and recovery for failure.

An agent demo usually begins with a prompt and a broad tool. Production begins by removing ambiguity: one outcome, a small action surface, known state transitions and a clear owner when the system cannot continue.

Write the workflow contract first

  • Trigger: the event that starts work and the identity on whose behalf it runs.
  • Inputs: the exact data classes and sources the workflow may read.
  • Outcome: the observable result that counts as complete.
  • Actions: the smallest versioned tools the agent may invoke.
  • Invariants: conditions that must remain true even when the model is wrong.
  • Escalation: when the workflow pauses and who is allowed to decide.
  • Recovery: how retries, partial work and rollback are handled.

Put a deterministic shell around probabilistic work

Use the model where judgement or language is useful, but use ordinary software for identity, permissions, schema validation, totals, deadlines, idempotency and state transitions. The model can propose an invoice classification; code should verify the allowed category, record version and permitted next action.

Fail closed at consequential boundaries

When identity, policy, evidence storage or an exact dependency is unavailable, stop before the first external effect. A fallback that silently changes model, tool or policy is not graceful degradation; it is a different workflow with different risk.

Test the failures users will actually see

FailureExpected behaviourEvidence
Model timeoutRetry only when the step is safe and idempotentAttempt count and final state
Tool returns partial successReconcile before any retryExternal identifier and reconciliation result
Approval expiresPause without executingApprover, policy and expiry metadata
Input changes mid-runRevalidate or restart from a known checkpointInput version and checkpoint
Policy service unavailableStop before tool executionDenied decision with availability reason

Observe outcomes, not only model output

Track completion, human correction, rollback, policy denial, latency and cost at the workflow level. Keep content out of general logs. For quality review, use an explicitly governed evaluation set with its own retention and access policy.

Use a small release loop

  1. Run the workflow on synthetic and approved evaluation cases.
  2. Shadow the real process without external actions.
  3. Allow actions only with human approval.
  4. Expand autonomy for narrow, reversible cases with strong evidence.
  5. Review exceptions and corrections before expanding scope again.

Reliability is a property of the whole workflow—identity, tools, state, policy, evidence and recovery—not a personality trait of the model.

Common questions

Can prompting alone make an AI agent reliable?
No. Better instructions help, but they cannot enforce permissions, schemas, idempotency or recovery. Those properties need deterministic controls around the model.
When should an agent retry a failed action?
Only when the action is known to be safe to repeat or when the workflow can reconcile the external state first. Blind retries can duplicate messages, payments or record changes.
What should be logged for an agent workflow?
Log metadata such as actor, workflow version, policy decision, tool version, state transition, timing and cryptographic hashes. Do not put prompts, responses, files, credentials or tool payloads in general logs.

Related notes