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 practice-supervisor-control
python3 -m unittest -v

What you build

A supervisor asks the model what to do next, hands the work to a specialist and feeds the result back until the model answers. Getting that loop to run is the easy part. You write the three things that make it safe to leave running:

  • Hand-offs that come back. Call the specialist the model names and give the model what it returned. A name that is not a specialist goes back to the model as a message, not a crash.
  • A turn budget. Stop after max_turns, however keen the model is to carry on.
  • An approval gate. An action that changes something outside, here sending an email, runs only when approve() says yes.

The model is scripted and the specialists are stubs, so it runs offline in a second. The supervisor is yours.

Checking your work

Six checks in test_supervisor.py say what the supervisor must do, one behaviour each. The first passes before you start; the others fail with the TODO they need. A missing turn budget fails its check after 50 turns instead of running for ever. The code tour below gives one hint per TODO when you want one.

When you are done

solution.py in the same folder has one way to do it, and PRACTICE_SOLUTION=1 python3 -m unittest -v runs the same checks against it. Then open Multi-agent orchestration, which builds the same supervisor with the OpenAI Agents SDK: find where its turn limit is set and where an approval step would go.