Run it

From a clone of stackunseen/examples (on Windows, type python where it says python3):

bash
git clone https://github.com/stackunseen/examples
cd examples
cd multi-agent-orchestration-python
python3 -m pip install openai
export OPENAI_API_KEY=...
python3 supervisor.py

How it works

The supervisor is a loop your code owns. Each turn, the model either calls a tool or answers; the code runs the tool, appends the result and asks again, and stops after eight turns. The two specialists are tools backed by their own model calls with their own instructions: research picks the relevant passages with their source IDs, and analysis turns them into a short answer that cites them. Because they are tools rather than a conversation handed over, control comes back to the supervisor after every step.

The code, not the model, decides what runs. A tool name the code does not know, or arguments that do not parse, come back to the model as an error instead of running anything.

Running it

The Python version uses the OpenAI Python SDK and switches to Azure OpenAI when AZURE_OPENAI_ENDPOINT is set (then MODEL is your deployment name). The TypeScript version calls the Chat Completions REST API directly with fetch, which is the start of an execution layer you own: set CHAT_COMPLETIONS_URL and AZURE_OPENAI_API_KEY to point it at Azure, and run it with npx tsx supervisor.ts. The search step is a stub, so the example needs no backend.

Taking it to production

Replace the stub with a real retrieval call, put a span around every model and tool call, add an idempotency key and an approval step to any tool that writes, and persist the message list so a run survives a restart. That list is most of what an orchestration framework would give you; the decision note We built our own TypeScript orchestrator covers when building it yourself pays off. To write a turn budget and an approval gate yourself, with tests that check them, try the practice exercise Keep a supervisor in control.