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.
Swarm's entire orchestration model is one idea: a tool function returns an
Agent, andhandle_function_result(core.py:71) reassignsactive_agent. Elegant and minimal.I formalized this as a
handoffprimitive with output typeNever— 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.