#243 Enterprise architecture and AI agents 5.6 min
Reliability Patterns for AI Agents: Bulkhead, Retry, Cache
In a simulation, one busy agent left the support agent with one call served out of twenty.
Read the price of each pattern
Copy the code folder first. Run python compare.py. For each of the four patterns, write down one number that shows what it gained and one number that shows what it cost. For example, retry gained answers but made more calls.
A hint
Look at the answered and calls made values for retry, and at calls and stale answers for the cache.
Fewer retry attempts
In compare.py, change the retry test from ("up to 3 attempts", 3) to ("up to 2 attempts", 2). Predict the answered count and the number of calls, then run python compare.py. When I ran it I got 5 of 10 answered and 15 calls made. Say why 2 attempts did not help.
A hint
Five of the requests fail on their first two attempts, so they need a third.
Change the breaker dials
In compare.py, change Breaker() to Breaker(limit=2, pause=10). Predict whether the number of calls that hit the dead downstream goes up or down, then run python compare.py. When I ran it the breaker line showed 6 calls, down from 14.
A hint
A lower limit opens the breaker sooner, and a longer pause keeps it open longer.
Make the shared pool bigger
In compare.py, change Pool(4 if shared else 2) to Pool(8 if shared else 2). The printed label still says a shared pool of 4 because it is fixed text. Predict how many support calls are served with the shared pool, then run python compare.py. When I ran it I got 3 of 20 for the shared pool and 20 of 20 for the bulkhead. Say what this shows about adding slots versus separating them.
A hint
The reporting agent uses two slots a second for 5 seconds each.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
Simulated faults on a counted clock with settings I chose; in the shared pool the reporting agent always asks first; the retry has no delay or backoff; the breaker has no half-open state and its pause is counted in calls; the cache counts requests, not time.
Up next in Enterprise architecture and AI agents
More in Enterprise architecture and AI agents
- #229 A Reference Architecture for Enterprise AI Agents, as Code
- #230 Agent Gateway: One Front Door for Models, Tools, Agents
- #231 MCP Gateway: Per-Tool Policy for Agent Tools (Python)
- #232 Give Every AI Agent Its Own Identity
- #233 Delegated Authority: Let an AI Agent Act for a User, Safely
- #234 Authorisation for AI Agents With Policy as Code (Cedar)
Related videos
- #236 Agent Orchestration Patterns: Supervisor, Pipeline, Swarm Enterprise architecture and AI agents
- #237 Where Should AI Agent State and Memory Live? A Crash Test Enterprise architecture and AI agents
- #238 Event-Driven AI Agents: Queues, Crashes and Duplicates Enterprise architecture and AI agents
- #239 Async AI Agents: Design for Timeouts With Job Polling Enterprise architecture and AI agents
