Band III · Control · “unreliable, unmeasured”
Why does my AI agent keep failing?
Short answer
Agents usually fail at the seams rather than in the model: a tool call times out, a step is retried without being idempotent, or a long run dies with the process that hosted it. Trace every step, validate tool inputs and outputs against schemas, and run the loop on a durable host so steps survive crashes. Narrow the agent's tools before adding instructions.
By Lattice editorial · Tool facts verified · method
Check in this order
- 01
Trace every step and tool call
Layer 09 · Evaluation & Observability
An agent failure is a sequence. Without the trace you are debugging the last message, not the step that went wrong.
- 02
Validate tool inputs and outputs against a schema
Layer 08 · Prompt Engineering
A malformed tool call that is silently accepted fails three steps later, where it is hard to see.
- Instructor
- Use when
- Schema-validated extraction with typed retry and partial streaming.
- Skip when
- You need a hard token-level guarantee rather than validation.
- Instructor
- 03
Move the loop onto a durable host
Layer 06 · Workflow Orchestration
Long runs need checkpoints, retries and timeouts that survive a deploy. A web request is not a place to run a ten-minute agent.
- Temporal
- Use when
- Work spanning minutes or hours that must survive restarts and retries.
- Skip when
- You need it live in a day — the adoption cost is real.
- Inngest
- Use when
- Durable step functions in TypeScript, without running the engine.
- Skip when
- You are not working in TypeScript.
- Restate
- Use when
- Durable execution with a genuinely low-latency stateful API surface.
- Skip when
- You need the largest ecosystem around the engine.
- Temporal
- 04
Put guardrails at the tool boundary
Layer 07 · Guardrails & Safety
The dangerous moment is an action, not a sentence. Check what the agent is about to do, not only what it says.
- Guardrails AI
- Use when
- Validators that check output against a schema you define.
- Skip when
- You need free-form moderation rather than structural checks.
- NeMo Guardrails
- Use when
- Constraining conversational flow with programmable rails.
- Skip when
- You need deep semantic moderation — it is not a classifier.
- Guardrails AI
- 05
Give it fewer tools and a narrower job
Layer 05 · Agent Frameworks
Every extra tool is another way to choose wrongly. A narrow agent with three tools beats a general one with twenty.
- Pydantic AI
- Use when
- Type-safe agents where schema correctness is the priority.
- Skip when
- You want a batteries-included ecosystem.
- OpenAI Agents SDK
- Use when
- A small, legible set of primitives for handoffs and guardrails.
- Skip when
- You need multi-provider abstraction at every layer.
- Pydantic AI
Looks like a fix, is not
- Adding another paragraph to the system prompt for each new failure.
- Giving the agent more tools when it already misuses the ones it has.
- Running long agent loops inside a web request with no checkpointing.
Quick answers
- What should I check first?
- Trace every step and tool call. An agent failure is a sequence. Without the trace you are debugging the last message, not the step that went wrong.
- What looks like a fix but is not?
- Adding another paragraph to the system prompt for each new failure. Giving the agent more tools when it already misuses the ones it has. Running long agent loops inside a web request with no checkpointing.