JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

When Things Go Wrong: Reflection, Recovery, and Humans in the Loop

Real agents fail constantly. The ones you can trust notice their own mistakes, recover from errors, and know when to stop and ask a person.

Why agents fail more than chat models

A chat reply is one shot — if it is slightly off, you reread it and move on. An agent chains dozens of steps, and errors compound: a wrong tool argument in step 2 poisons every step after it, and by step 20 the agent is confidently building on rubble. Worse, a model that hallucinates can invent a tool result or convince itself a failed action succeeded. Long-horizon autonomous task execution therefore needs machinery to catch and correct its own mistakes — robustness is not optional polish, it is the difference between a demo and a product.

P_{\text{fail}} = 1 - p^{\,n}

Why agents fail more than chat models: if each of n steps is right with probability p, the chance at least one step goes wrong is 1 minus p to the n — and it climbs toward certainty as the chain grows.

Self-reflection: the agent grades its own work

Self-reflection adds a critic step: after acting, the agent pauses to evaluate its own output before continuing. "Did that search actually answer the question? Does this code pass the test I expected? Is this draft missing anything the user asked for?" Reflection turns a blind forward march into a check-then-proceed rhythm, and its verdict feeds straight back into the feedback loop as the input to the next decision.

Reflection is most powerful when it is grounded in something objective rather than the model's own opinion. Run the code and read the test result; re-query the tool and compare; check the draft against an explicit checklist. A reflection anchored to a real signal catches genuine mistakes; a reflection that just asks the model "are you sure?" often gets a confident "yes" that means nothing.

Error recovery: failing forward

Tools fail: an API times out, a page won't load, code throws, an argument was malformed. Agent error recovery is the discipline of treating each failure as just another observation to reason about, not a dead end. The model reads the error, diagnoses it, and adapts — retry with a fixed argument, fall back to a different tool, or change approach entirely. This is exactly why returning clear error messages from your tools (Guide 2) pays off: a good error message is a hint the agent can act on.

  1. Catch the failure and feed the error back to the model as an observation, not a crash.
  2. Retry with backoff for transient problems (a timeout, a rate limit) — but cap the attempts.
  3. If retries keep failing, switch strategy or tool rather than hammering the same broken path.
  4. Track a failure budget — after N dead-ends on one sub-goal, stop and escalate rather than loop forever.
t_n = \min\!\left(t_{\max},\; t_0 \cdot 2^{\,n}\right)

Retry with exponential backoff: each successive retry waits twice as long, capped at a ceiling so the agent fails forward instead of hammering a dead tool.

Humans in the loop: knowing when to ask

Full autonomy is not always the goal. A human-in-the-loop agent deliberately pauses at chosen moments to get a person's confirmation, correction, or choice before proceeding. The art is picking those moments: gate the consequential and irreversible actions — spending money, deleting data, sending an external message, anything hard to undo — while letting the cheap, reversible steps run free. The human's decision is then written into memory so the same question isn't asked twice.