Stop guessing why your AI agents fail. Debug systematically.
AI Agents are probabilistic software. Unlike traditional code, they fail in non-deterministic ways:
- Hallucinations: Inventing data that doesn't exist.
- Loops: Getting stuck in "I apologize, let me try again" cycles.
- Context Drift: Forgetting instructions after 10 turns.
- Tool misuse: Calling APIs with valid JSON but invalid logical parameters.
Most developers debug by staring at console logs. This framework provides a systematic approach to agent reliability.
This repository contains the debugging methodology and Python code patterns I use to stabilize production agents.
- Debugging Flowchart: A step-by-step process from symptom to root cause.
- Resiliency Patterns: Wrappers for circuit breakers and retries.
- Testing Strategies: How to unit test non-deterministic outputs.
- Common Failure Modes: A categorized list of things that will go wrong.
ai-agent-debugging-framework/
├── framework.md # The core methodology
├── patterns/
│ ├── circuit-breaker.py # Stop calling tools that are down
│ ├── retry-with-backoff.py # Handle rate limits gracefully
│ ├── observability.py # Wrap LLM calls to capture full context
│ └── idempotency.py # Ensure agents don't double-charge cards
├── examples/
│ ├── broken-agent/ # Example of a fragile implementation
│ └── fixed-agent/ # The same agent, hardened with this framework
└── docs/
├── debugging-checklist.md
└── common-failure-modes.md
- Wrap: Use the
observability.pywrappers around your LLM calls. - Catch: Implement
circuit-breaker.pyon your tools (Search, Database, API). - Trace: Use the structured logs to identify exactly where the context drifted.
I help companies move AI agents from "cool demo" to "production reliable".
MIT License.