#236 Enterprise architecture and AI agents 5.3 min
Agent Orchestration Patterns: Supervisor, Pipeline, Swarm
The same three agents solved four tickets, or six, depending on how I organised them.
Read the three numbers
Copy the code folder first. Run python compare.py. For each of the three lines, write down in your own words what the three numbers mean: tickets solved, agent calls and handoffs. Then say which pattern is cheapest in calls and which pattern solved the most tickets. When I ran it the pipeline made 7 calls and solved 4 of 7.
A hint
The pipeline and the supervisor never hand tickets to a peer, so their handoffs are 0.
Remove the flaky failure
In crew.py, change the line that starts FLAKY so the set is empty: FLAKY = set(). Predict how the three lines change, then run python compare.py. When I ran it, the pipeline solved 5 of 7, the supervisor made 10 calls and the swarm made 14 calls with 7 handoffs. Then put the FLAKY line back as it was before the next task.
A hint
The tech agent no longer fails the first time on the crash ticket, so there is nothing to retry.
Shorten the swarm limit
In patterns.py, change the swarm default from limit=4 to limit=2. Predict how many tickets the swarm solves and how many handoffs it makes, then run python compare.py. When I ran it the swarm solved 5 of 7, with 12 calls and 5 handoffs.
A hint
The swarm starts at the account agent, so tickets for other agents need a handoff before they can be solved.
Take away the second chance
In patterns.py, in the supervisor function, change for kind in (best, second, best): to for kind in (best,):. Predict the supervisor line before you run python compare.py. When I ran it the supervisor solved 4 of 7 with 7 calls, the same as the pipeline.
A hint
With only one try per ticket the supervisor works like the pipeline.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
Plain functions with keyword rules, not models; seven made-up tickets, three of them traps I set; the swarm always starts at the same agent; cost is counted in calls, not seconds or money; only a pipeline, a supervisor and a swarm are built.
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
- #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
- #243 Reliability Patterns for AI Agents: Bulkhead, Retry, Cache Enterprise architecture and AI agents
