An AI agent can run ten times in a row on a developer's laptop and still fail on Monday morning, because a provider hit its rate limit or a tool call came back as malformed JSON. Neither of those is a prompt problem.
The model is the easy part
I run assistants on Anthropic, OpenAI and Gemini in production, and switching between them changes less than people expect. Whether a multi-step run finishes depends on the layer around the model.
What that layer does
- Retries that depend on the error. A timeout is retried, a validation error goes back to the model with the reason, and a permission error stops the run.
- Strict tool schemas. Every tool call is validated before it touches anything, so a malformed call never reaches the database.
- Scoped access. The agent acts with the permissions of the person who started it, through tokens that can be revoked.
- A confidence threshold. When the agent isn't sure, the step goes to a human review queue instead of guessing.
Why healthcare taught me this
I spent six years on regulated healthcare software, where a bad write corrupts someone's case or billing record. I still keep the habits that work gave me, like audit trails, idempotent writes and least-privilege access. AI agents need them just as much, and most demos skip them because nothing has gone wrong yet.
The test I use
Before an agent goes to production I ask one question: if this step fails halfway, what state does it leave behind, and who finds out? If the answer is "nobody, until a customer calls", it isn't ready.