Skip to content
derpx06Notes on systems, models & learning
7. Tools & Agents · lesson 58 of 68 · 1 min · January 10, 2026

Fallbacks & Error Handling

When the agent breaks. Retries, corrections, and graceful exits.

Chains are deterministic logic. Agents are probabilistic logic. Probabilities fail.

  • Tool Error: API is down.
  • Parse Error: Agent output malformed JSON.
  • Loop Error: Agent decides to search for "A" forever.

If you don't build Fallbacks, your agent is a prototype, not a product.

We discussed this in Tool Selection. If delete_user fails, feed the error back. This converts a Crash into an Observation.

Agent: "Action: Delete(User 5)" System: "Error: User 5 not found." Agent: "Thought: Ah, I made a mistake. I will search for the user first."

This is the cheapest form of resilience.

If SearchGoogle API times out, the agent shouldn't die. It should automatically switch to SearchBing or SearchDuckDuckGo.

tool_fallback.py
primary_tool = SearchGoogle()
backup_tool = SearchBing()

final_tool = primary_tool.with_fallbacks([backup_tool])

# If primary raises Exception, backup runs instantly.
# The Agent doesn't even know it failed.

If GPT-4 is overloaded (Rate Limit Error), automatically fallback to GPT-3.5 or Claude. The answer might be dumber, but a dumb answer is better than a 500 Server Error.

Elegance is handling failure without the user noticing. Your agent should be like a cat: It always lands on its feet.

Key Intuition: "The plan A never survives contact with reality."