1
Set Your OpenAI Key
Begin by setting your OpenAI API key in the
.env file. It will be loaded automatically on agency initialization2
Create Project Structure
Agent Folder Structure:When you run the create-agent-template command, it creates the following folder structure for your agent:This structure ensures that each agent has its dedicated space with all necessary files to start working on its specific tasks.Agency Folder Structure:The full structure of the project will look like this:
3
Create Tools
In 1.x versions of the framework, you have 2 ways of defining custom tools:By extending agency_swarm’s Or by using openai’s
BaseTool class and implementing the async run method.my_custom_tool_class.py:@function_tool decorator.my_custom_tool.py:4
Define Agent Roles
Adjust the parameters and instructions for each agent.developer.py:Tools are imported directly into the agent definition instead of from a folder.instructions.md:
5
Create Agency
Import your agents and initialize the Agency class.agency.py:The first positional argument is the entry point agent that users interact with directly. Communication flows are defined separately.
In Agency Swarm, communication flows are directional tuples. For instance, in the example above:
(ceo, developer), the CEO can initiate a chat with the Developer, and the Developer can respond in this chat. However, the Developer cannot initiate a chat with the CEO.6
Run Demo
There are multiple ways to run the demo. Add one of the following to your Terminal Version:Backend Version (Sync):Backend Version (Async):
agency.py file:Web Interface:Copilot demo is currently minimal and will be updated in future patches
Next Steps
- Learn the core concepts of Tools, Agents, and Agencies.
- Watch the Deployment Tutorial.