Production-ready implementations of 8 AI orchestration patterns β from deterministic workflows to autonomous multi-agent systems.
Each pattern uses the same use case (tennis court booking) to highlight architectural differences, not domain complexity.
This repo implements the patterns described in my blog post:
AI Orchestration Deep Dive: From No-Agent to Multi-Agent and Beyond
Read the blog first for architecture diagrams, trade-offs, and decision guides.
| Pattern | Style | Runtime | Status |
|---|---|---|---|
| A - AI as Service | No agent, LLM parses only | Shared | β Done |
| B - Workflow (Single-Process) | Fixed sequence | Single-Process | β Done |
| C - Workflow (Multi-Process) | Fixed sequence | Multi-Process | β Done |
| D - Function Calling | LLM suggests, you control loop | Shared | β Done |
| E - Single Agent | Agent controls the loop | Shared | β Done |
| F - Multi-Agent (Single-Process) | Manager routes dynamically | Single-Process | β Done |
| G - Multi-Agent (Multi-Process) | Manager routes dynamically | Multi-Process | β Done |
| H - Bedrock Agent | AWS-managed agent | Managed | β Done |
β
Local Patterns: A β B β C β D β E β F β G β H (all done!)
βοΈ AWS Deployed: A β B β C β D β E β F β G β H (live on Lambda)
Control ββββββββββββββββββββββββββββββββββββββββββββ Autonomy
A B C D E F G H
β β β β β β β β
No Workflow Workflow Function Single Multi Multi Bedrock
Agent (Single) (Multi) Calling Agent Agent Agent (Managed)
β β β β β β β β
You Fixed Fixed LLM Agent Manager Manager AWS
control steps steps suggests controls routes routes manages
all (single) (multi) you loop
control
Try the deployed patterns (AWS Lambda + API Gateway):
| Pattern | Health Check | Chat Endpoint |
|---|---|---|
| A - AI as Service | Health | curl -X POST https://7jtqo8ncu4.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
| B - Workflow (Single) | Health | curl -X POST https://jwmoovw1se.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
| C - Workflow (Multi) | Health | curl -X POST https://1ywzwz1hog.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
| D - Function Calling | Health | curl -X POST https://3sd40p0zz4.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
| E - Single Agent | Health | curl -X POST https://ok1ro2wdf1.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
| F - Multi-Agent (Single) | Health | curl -X POST https://seymcwtuh9.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
| G - Multi-Agent (Multi) | Health | curl -X POST https://nwnh1ys1u8.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
| H - Bedrock Agent | Health | curl -X POST https://dck1pppjal.execute-api.us-east-1.amazonaws.com/chat -H "Content-Type: application/json" -d '{"message": "Book tomorrow at 3pm"}' |
- Language: Python
- Package Manager: UV
- AI Providers: OpenAI, Anthropic Claude, AWS Bedrock
- Agent Framework: OpenAI Agents SDK
- API: FastAPI
- Infrastructure: AWS Lambda, Terraform
All patterns implement a tennis court booking system:
check_availability(date, time) β returns available slots
book(slot_id, user_id) β reserves a slot
The difference: who decides which function to call and when.
The repository is organized into three main areas:
pattern-*/folders - Each contains a complete implementation of one orchestration pattern with source code, dependencies, and sequence diagramsterraform/folder - AWS infrastructure (Lambda + API Gateway) to deploy each pattern. One subfolder per pattern.shared/folder - Common booking service logic reused across all patterns to keep the focus on orchestration differences, not business logic
ai-orchestration-patterns/
βββ README.md
βββ pattern-a-ai-as-service/
βββ pattern-b-workflow-single-process/
βββ pattern-c-workflow-multi-process/
βββ pattern-d-function-calling/
βββ pattern-e-single-agent/
βββ pattern-f-multi-agent-single-process/
βββ pattern-g-multi-agent-multi-process/
βββ pattern-h-bedrock-agent/
βββ scripts/
β βββ package_lambda.py # Build tool for patterns A-F
β βββ requirements-lambda.txt
βββ shared/
β βββ booking_service.py # Mock booking service (all patterns)
βββ terraform/ # Infrastructure (Lambda + API Gateway)
βββ pattern_a/
βββ pattern_b/
βββ ...
βββ pattern_h/
Required:
- Python 3.12+
- UV (package manager)
- Docker (for AWS Lambda builds)
For AWS deployment:
- AWS CLI configured
- Terraform 1.5+
- OpenAI API key (patterns A-G)
- AWS account with Bedrock access (pattern H)
Run patterns locally without AWS:
# Install dependencies
cd pattern-d-function-calling
uv sync
# Run demo
uv run src/demo.py# Create .env file (gitignored)
cat > .env << EOF
OPENAI_API_KEY=sk-...
EOFFor Patterns A-F (single Lambda):
python scripts/package_lambda.py pattern-a-ai-as-serviceFor Pattern G (3 Lambdas - manager, availability, booking):
cd pattern-g-multi-agent-multi-process
./build.shFor Pattern H (2 Lambdas - action, invoker):
cd pattern-h-bedrock-agent
./build.shcd terraform/pattern_a
# First time: copy example config
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars:
# - Add your OpenAI API key
# - (Pattern H only) Choose foundation model
# Deploy
terraform init
terraform apply# Get endpoint
terraform output api_endpoint
# Test health
curl $(terraform output -raw api_endpoint)/health
# Test chat
curl -X POST $(terraform output -raw api_endpoint)/chat \
-H "Content-Type: application/json" \
-d '{"message": "Book tomorrow at 3pm"}'Pattern H (Bedrock Agent):
- Uses AWS Nova Pro by default (no agreement required)
- Alternative models require Bedrock model access:
- AWS Console β Bedrock β Model access
- Enable desired model (e.g., Claude Haiku 4.5)
- Update
foundation_modelin terraform.tfvars
- Real infrastructure β not just pseudocode
- Clear progression β deterministic β controlled β autonomous
- Trade-off analysis β when to use each pattern
- Production patterns β what actually works in enterprise
Moss Gu
MIT