#84·swarm

Typed handoff primitive — formalizing Swarm's core pattern

Author: greatmengqiCreated Apr 15, 2026Updated Jun 12, 2026

Swarm's entire orchestration model is one idea: a tool function returns an Agent, and handle_function_result (core.py:71) reassigns active_agent. Elegant and minimal.

I formalized this as a handoff primitive with output type Never — meaning any step chained after a handoff is statically unreachable. This gives you a compile-time guarantee that Swarm currently enforces only at runtime (by silently dropping whatever comes after the agent switch).

Papers:

292 lines of Python, one algebraic primitive. Swarm's design instinct was right — this formalizes why.