learning-it by example

Back to the video

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.

Video #12 ยท AI agents and MCP

Steps in the video

  1. 0:00 Three ways to wire agents
  2. 0:22 The patterns, in plain words
  3. 0:59 Setup
  4. 1:14 Two helpers
  5. 1:46 Pattern one: a pipeline
  6. 2:32 Pattern two: a router
  7. 3:14 Pattern three: a supervisor loop
  8. 4:12 What this does not show
  9. 4:42 Mistakes to avoid
  10. 5:10 My take and next steps
  11. 5:41 Recap

Files

  • agents.py (32 lines)
  • guard.py (12 lines)
  • pipeline.py (8 lines)
  • router.py (14 lines)

Download the code (zip)

Tested with

Python 3.12.15 | ollama==0.6.3, pydantic==2.14.1

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.

Sources

Learning IT by Example.