Chapter 21 · when one agent hits its ceiling
"Write it, critique it, rewrite it, fact-check, stay friendly" — the instructions fight each other.
A writer that only writes + a critic that only critiques beats one agent doing both.
def collaborate(task):
draft = agent(WRITER, task)
critique = agent(CRITIC, f"DRAFT:\n{draft}")
final = agent(WRITER, f"Fix these:\n{critique}")
return final
Passing outputs between agents is a function call.
Each is control flow over one-job prompts.
if over a classificationroute = agent(ROUTER, message).strip() # "billing"
answer = agent(SPECIALISTS[route], message)
Scale across domains without one bloated prompt.
Pay when quality is worth it. Evaluate the OUTPUT, not your faith in the architecture (week 15).
Split roles, compose with plain control flow. Pipeline, router, debate. Frameworks add convenience, not magic. Next: the capstone — the whole course in one app.