Six Bugs That Taught Me How to Build an AI Agent That Doesn't Fall Over
Description and use
The author explains how to fix blocking OAuth, duplicate tool calls, and shared API key quota starvation by creating the kevlar-agent library, which adds timeouts, dedupe, and per‑feature budgeting.
Problem
Unattended AI assistants can silently fail due to blocking OAuth flows, duplicate tool calls, and shared API key quota starvation.
Outcome
The agent now runs unattended for months without silent failures, thanks to timeout handling, dedupe, and per‑feature quota management.
Workflow
- Identify failure modes during real‑world operation
- Implement cross‑platform timeout for OAuth calls
- Add time‑windowed dedupe for tool calls
- Track per‑feature API usage and enforce budget ceilings
- Package solutions into kevlar-agent library
- Integrate library into existing agent stack
- Run 24 tests to validate behavior
Evidence
The OAuth helper that hung for hours… just… waited. For hours. No error, no timeout, no log line saying anything was wrong
Two duplicate tool calls… two near‑simultaneous calls to a "launch session" tool spun up two concurrent audio sessions
Two unrelated features shared a single provider API key… silently ate into the quota the other feature needed
- Record date: 2026-09-19T21:30:41.018Z