Agent Patterns: Multi-Agent Orchestration in Python

Compare four multi-agent orchestration patterns in Python and run a local FastAPI demo with step limits, tracing, and human approval.Python,

Python FastAPI OpenTelemetry AWS Bedrock LangGraph
Four diagrams show supervisor routing, hierarchical delegation, peer handoffs, and a human approval gate.

When several AI agents work on the same task, who decides what happens next? I built Agent Patterns to compare four approaches to multi-agent orchestration in Python. They share the same agent and message interfaces, so you can focus on how each pattern routes work and what can go wrong.

Four multi-agent orchestration patterns

Supervisor. One dispatcher can route a request to a worker and aggregate the response. Central routing makes the decision path easy to follow, but adds model calls.

Hierarchical. A supervisor delegates to team supervisors, which can route work to their own workers. Each level adds latency and draws from the same step budget.

Swarm. Peers hand off work directly based on capability. This makes routing flexible. The shared step budget caps handoff loops.

Human-in-the-loop. An agent proposes an action and pauses. A person can approve or reject it using a resume token. The default approval store is in memory, so a restart clears pending approvals.

Every pattern enforces a step budget and a timeout for each agent call. It also emits an OpenTelemetry span per step, so you can trace how work moves through the system.

How to run Agent Patterns locally

You’ll need Git and Python 3.11 or newer. The FastAPI service uses demo agents, so you can try it without AWS credentials.

1. Clone the repository and install the service.

git clone https://github.com/shasha1589/agent-patterns.git
cd agent-patterns
python -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[serve]"

In Windows PowerShell, activate the environment with .\.venv\Scripts\Activate.ps1 in place of source.

2. Start the local API. Keep this terminal open.

uvicorn serve.app:app --reload

3. Try Supervisor routing. In a second terminal, run this example in Bash.

curl -X POST http://localhost:8000/patterns/supervisor/run \
  -H "Content-Type: application/json" \
  -d '{"message":"I was billed twice"}'

4. Try the approval flow. Send a request that triggers a proposed action.

curl -X POST http://localhost:8000/patterns/human_in_the_loop/run \
  -H "Content-Type: application/json" \
  -d '{"message":"please email the team"}'

The demo returns pending_approval and a resume_token. Replace the placeholder below with that token. Use false to try rejecting the proposal.

curl -X POST http://localhost:8000/patterns/human_in_the_loop/resume \
  -H "Content-Type: application/json" \
  -d '{"token":"REPLACE_WITH_RESUME_TOKEN","approved":true}'

Try a live model with AWS Bedrock

The repo also includes a Supervisor research assistant that uses web search and a Bedrock summarizer. With AWS Bedrock access configured, run python -m examples.research_assistant from the repository root. An optional LangGraph adapter lets you run the same agents as graph nodes.

Explore the Agent Patterns source code and pattern guides on GitHub.