buildfastwithaibuildfastwithai
AI WorkshopsAll blogsAgentic AI Launchpad
Agentic AI Launchpad
Unrot Logo5 min AI learning appUnrotLearn AI in 5 minutes a day.Get the appNext live workshopFree AI WorkshopLive session, recording includedReserve a seat
Newsletter
Stay Ahead
Get the latest AI insights and tools delivered to your inbox.
Share
Back to blogs
Tutorials
Automation

AI Automation Made Easy with Agency Swarm

March 10, 2025
4 min read
Share:
AI Automation Made Easy with Agency Swarm
Share:

Are you waiting for change, or will you create it?

The future is calling—answer it with Gen AI Launch Pad 2025.

Introduction

Automation has become a game-changer in modern workflows, allowing businesses to optimize processes and enhance efficiency. Enter Agency Swarm, an advanced AI framework that enables multiple AI agents to work together just like a human team. With features like modular agent roles, intelligent communication, and customizable workflows, Agency Swarm is transforming automation.

This guide walks you through setting up and using Agency Swarm, helping you harness its full potential for task automation and data collection.

Key Features of Agency Swarm

  1. Modular Agent Roles:- Agency Swarm allows you to create AI agents with specialized roles such as Manager, Researcher, Developer, or Analyst. Each agent performs a specific function, making collaboration efficient and structured.
  2. Seamless Collaboration:- Agents communicate through an intelligent messaging system, ensuring smooth task execution without conflicts or delays.
  3. Customizable Workflows:- Define and control how agents interact, automate repetitive tasks, and adapt the system to various use cases.
  4. State Management:- Agents can remember past interactions and track progress using a state-saving system, ensuring continuity in long-term projects.
  5. Scalable & High Performance:- Designed for large-scale automation, Agency Swarm is optimized for high efficiency and production readiness.

Installing and Setting Up Agency Swarm

To start using Agency Swarm, follow these steps:

Step 1: Install Dependencies

Use the following command to install the necessary libraries:

pip install -U agency-swarm gradio selenium webdriver-manager selenium_stealth

Step 2: Set Up API Keys

Set up OpenAI API keys for AI-powered automation:

from google.colab import userdata
OPENAI_API_KEY = userdata.get('OPENAI_API_KEY')

from agency_swarm import set_openai_key
set_openai_key(OPENAI_API_KEY)

Step 3: Import the Genesis Agency

from agency_swarm.agency.genesis import GenesisAgency

Step 4: Initialize a Test Agency

test_agency = GenesisAgency()

Step 5: Launch Gradio Demo

test_agency.demo_gradio()

Creating AI Agents

The CEO Agent oversees operations and ensures seamless task execution:

from agency_swarm import Agency, Agent

ceo = Agent(
    name="CEO",
    description="Responsible for client communication, task planning and management.",
    instructions="You must converse with other agents to ensure complete task execution.",
    tools=[],
)

Creating a Test Agent

A Test Agent verifies system responses:

test = Agent(
    name="Test Agent",
    description="Test agent",
    instructions="Please always respond with 'test complete'",
    tools=[],
)

Managing Threads and Settings

Define thread management to keep track of ongoing conversations:

threads = {}

def load_threads():
    global threads
    return threads

def save_threads(new_threads):
    global threads
    threads = new_threads

Define settings management:

settings = []

def load_settings():
    global settings
    return settings

def save_settings(new_settings):
    global settings
    settings = new_settings
Agentic AI LaunchpadApplications open

Build AI agents, don't just use them

Six weeks live. Five deployed apps.

6weeks

Live mentorship

5+apps

Built & deployed

1,000+

Builders trained

LLM agentsRAG pipelinesTool callingMulti-agent orchestration
Explore program

Initializing the Agency

Integrate multiple agents and set up an asynchronous communication model:

agency = Agency(
    [ceo, [ceo, test]],
    async_mode="threading",
    threads_callbacks={"load": load_threads, "save": save_threads},
    settings_callbacks={"load": load_settings, "save": save_settings},
)

⚠ Note: 'threading' mode is deprecated. Use send_message_tool_class = SendMessageAsyncThreading for async communication.

Sending Messages to Agents

agency.get_completion("Say hi to test agent", yield_messages=False)

Checking Agency Status

agency.get_completion("Check status", yield_messages=False)

Launching Gradio Demo

agency.demo_gradio()

Building a Data Collection Swarm

Import Required Modules

import sys
sys.path.insert(0, "../")

from agency_swarm import Agency, Agent
from agency_swarm.agents import BrowsingAgent

Creating a Report Manager Agent

The Report Manager supervises web data collection:

report_manager = Agent(
    name="Report Manager",
    description="Supervises data collection from various websites.",
    instructions="Break down user tasks into steps, instruct BrowsingAgent, and compile reports with sourced links.",
)

Configuring Selenium & Browsing Agent

Configure Selenium for web browsing automation:

selenium_config = {
    "headless": False,
    "full_page_screenshot": False,
}

browsing_agent = BrowsingAgent(selenium_config=selenium_config)

Initializing the Data Collection Agency

agency = Agency(
    [report_manager, [report_manager, browsing_agent]],
    shared_instructions="Find relevant information online and compile detailed reports.",
)

Launching the Gradio Demo

demo = agency.demo_gradio(height=700)

Conclusion

Agency Swarm is a powerful AI automation framework that simplifies complex workflows with modular agents and intelligent coordination. Whether you're managing projects, collecting data, or automating repetitive tasks, Agency Swarm provides scalability, efficiency, and adaptability.

Start integrating AI agents today and revolutionize your workflow automation!

References

  • Agency Swarm Documentation
  • Gradio for AI Interfaces
  • Selenium Web Scraping Guide
  • Agency Swarm Experiment Notebook

---------------------------

Stay Updated:- Follow Build Fast with AI pages for all the latest AI updates and resources.

Experts predict 2025 will be the defining year for Gen AI Implementation. Want to be ahead of the curve?

Join Build Fast with AI’s Gen AI Launch Pad 2025 - your accelerated path to mastering AI tools and building revolutionary applications.

---------------------------

Cohort program

Claude Mastery: Cowork & Code

Prompting to shipping real software. No coding experience needed.

  • Live sessions with Satvik
  • 6+ hands-on labs and agent builds
  • Ship real code with Claude Code
  • 1-year access with updates
Explore program

Resources and Community

Join our community of 12,000+ AI enthusiasts and learn to build powerful AI applications! Whether you're a beginner or an experienced developer, our resources will help you understand and implement Generative AI in your projects.

  • Website: www.buildfastwithai.com
  • LinkedIn: linkedin.com/company/build-fast-with-ai/
  • Instagram: instagram.com/buildfastwithai/
  • Twitter: x.com/satvikps
  • Telegram: t.me/BuildFastWithAI
Enjoyed this article? Share it →
Share:
    You Might Also Like
    Muse Code vs Claude Code vs Codex: Best Agent 2026
    Tools
    Muse Code vs Claude Code vs Codex: Best Agent 2026

    Muse Code vs Claude Code vs Codex compared: benchmarks, pricing, features, and which AI coding agent to actually use in 2026. Meta's cheap new agent vs the leaders.

    7 AI Tools That Changed Developer Workflow (Aug 2026)
    Tools
    7 AI Tools That Changed Developer Workflow (Aug 2026)

    The 7 AI developer tools reshaping workflow in August 2026: Claude Code on Opus 5, Codex, Cursor 3, Antigravity, BrowserStack Test Companion, Kimi K3 and Cline.