Repo·github.com
multi-agentagencyopenaicustomizableopen-sourceproductionassistants api
Agency Swarm
Build a collaborative AI agent swarm with specialized roles using the Agency Swarm framework. Leverage OpenAI Assistants API for persistent threads, tool management, and seamless inter-agent communication to solve complex tasks.
intermediate30-60 minutes5 steps
The play
- Set Up Your EnvironmentInstall the necessary dependencies. This typically involves installing the `agency-swarm` package and any other required libraries (e.g., OpenAI's Python library). You'll also need an OpenAI API key.
- Define Agent RolesCreate classes for each agent in your swarm, inheriting from a base `Agent` class. Define the agent's role, goal, and any specific tools they need to access. Specify the agent's instructions, which guide their behavior.
- Create the AgencyInstantiate the agents you defined and create an `Agency` object, assigning the agents to their respective roles within the agency. Define the organizational structure by specifying which agents report to whom.
- Run the SwarmUse the `agency.run()` method to start the swarm. Provide the initial task or prompt to the agency. The agents will then communicate and collaborate to complete the task.
- Review the ResultsAfter the swarm completes its task, review the output. This might involve examining the messages exchanged between agents, the final output generated, or any logs produced during the process.
Starter code
Start by defining simple agent roles with clear goals and instructions. Gradually add complexity by incorporating more agents, tools, and sophisticated communication patterns.
Source