This came unexpected! @OpenAI released Swarm, a lightweight library for building multi-agent systems. Swarm provides a stateless abstraction to manage interactions and handoffs between multiple agents and does not use the Assistants API. ๐ค
How it works:
1๏ธโฃ Define Agents, each ns, role (e.g., "Sales Agent"), and available functions (will be converted to JSON structures).
2๏ธโฃ Define logic for transferring control to another agent based on conversation flow or specific criteria within agent functions. This handoff is achieved by simply returning the next agent to call within the function.
3๏ธโฃ Context Variables provide initial context and update them throughout the conversation to maintain state and share information between agents.
4๏ธโฃ Client run() initiate and manage the multi-agent conversation. It needs an initial agent, user messages, and context and returns a response containing updated messages, context variables, and the last active agent.
Insights:
๐ Swarm manages a loop of agent interactions, function calls, and potential handoffs.
๐งฉ Agents encapsulate instructions, available functions (tools), and handoff logic.
๐ The framework is stateless between calls, offering transparency and fine-grained control.
๐ ๏ธ Swarm supports direct Python function calling within agents.
๐ Context variables enable state management across agent interactions.
๐ Agent handoffs allow for dynamic switching between specialized agents.
๐ก Streaming responses are supported for real-time interaction.
๐งช The framework is experimental. Maybe to collect feedback?
๐ง Flexible and works with any OpenAI client, e.g., Hugging Face TGI or vLLM-hosted models.
