learning-it by example

#12 AI agents and MCP 6.1 min

Multi-Agent Patterns in Plain Python: Pipeline, Router, Loop

Build a pipeline and a router in plain Python with a local model, then test the four lines that guard a supervisor loop, using a scripted stand-in.

1. What is the difference between a router and a supervisor in multi agent wiring?
2. In the supervisor guard run, the stub's second decision was 'refunds', which is not a team, and a fourth decision was ready. What happened?
3. Why does the router call pass a schema that limits the team to billing, bug or other?
4. What was the supervisor's step limit and fallback tested against, and why does that matter?
5. Before building several agents, what do several of the video's sources say?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. Make refunds a real team

    Copy the code folder first. In guard.py add 'refunds' to HANDLERS. Predict how the output changes, in particular what step 2 prints, then run python guard.py.

    A hint

    The fallback only runs when the team is not in HANDLERS.

  2. Raise the step limit

    In guard.py change MAX_STEPS from 3 to 4 and predict the output. Then change it to 5 and predict again. Run python guard.py each time and compare.

    A hint

    STUB_DECISIONS only has four entries.

  3. Add a second bad decision

    In guard.py change MAX_STEPS to 4 and change the third item of STUB_DECISIONS from 'billing' to 'shipping'. Predict every line the script will print, then run it and compare.

    A hint

    Each unknown route is replaced by 'other' before the step is printed.

  4. Tighten the editor

    In pipeline.py change the editor instruction from at most 12 words to at most 6 words. Predict whether the 2-3 business days detail will survive, then run python pipeline.py. This needs Ollama with llama3.2 and the ollama and pydantic packages. Read both lines and decide whether the editor kept what the writer made up.

    A hint

    The video says the second step can only work with what the first one gave it, so check each step's output.

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

Wiring only: simple tasks on one small local model, nothing measured at scale. The supervisor loop is a scripted stand-in with no model call, so the guards are tested against a planned bad decision, not a real model failure. The pattern advice comes from agency and vendor pages.

Up next in AI agents and MCP

More in AI agents and MCP

All AI agents and MCP videos

Related videos