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:
- v1 — primitives + DAG completeness: https://doi.org/10.5281/zenodo.19573903
- v2 — six extensions with proofs: https://doi.org/10.5281/zenodo.19574625
292 lines of Python, one algebraic primitive. Swarm's design instinct was right — this formalizes why.
Source: openai/swarm