Multi-Agent Systems
Learn how to build a production-grade multi-agent system built with LangGraph and LangChain, featuring a web search agent and a Celo blockchain agent powered by Google's Gemini.
Featuresβ
- π€ Supervisor agent that orchestrates specialized agents
- π Web search agent for retrieving real-time information
- βοΈ Blockchain agent for fetching Celo blockchain data
- π Memory management for conversation history
- π€ Gemini AI for intelligent agent capabilities
- π§΅ Thread support for maintaining conversation state
What are Multi-Agent Systems?β
Sure! Here's a simplified and accessible concept module-style intro to multiagent systems, tailored to fit the Celo Docs style:
What Are Multiagent Systems?β
Multiagent systems (MAS) are groups of independent software agents that work together to solve complex problems. Instead of relying on one big, centralized program, MAS use many smaller agentsβeach with their own goals and responsibilities. These agents can collaborate, compete, or coordinate to get things done more efficiently.
In Web3, this is especially powerful. Agents can perform tasks like:
- Optimizing DeFi yields
- Voting in governance protocols
- Bridging assets across blockchains
- Managing liquidity in real-time
Because these agents are autonomous and can operate in parallel, the system becomes more scalable and resilient. If one agent fails, others can keep running. That means fewer single points of failureβan important trait in decentralized systems.
Multiagent architectures help developers build apps that respond to changing network conditions, user demands, or even market dynamics without needing centralized control. This makes them a great match for Celoβs L2 ecosystem and the broader Web3 world.
Architectureβ
The system uses a hierarchical multi-agent architecture with a supervisor agent orchestrating specialized agents.
Setupβ
- Clone the repository
- Install dependencies:
pip install -e ".[dev]"
- Set up environment variables:
export GOOGLE_API_KEY=your_google_api_key
export TAVILY_API_KEY=your_tavily_api_key
You can also create a .env
file in the project root (the application uses python-dotenv to load variables automatically).
Usageβ
Run the main application:
python main.py
The application maintains conversation state using thread IDs, allowing for coherent multi-turn interactions.
Project Structureβ
multi-agent-system/
βββ src/
β βββ agents/
β β βββ __init__.py
β β βββ blockchain_agent.py # Agent for Celo blockchain interactions
β β βββ search_agent.py # Agent for web search capabilities
β β βββ supervisor.py # Orchestrates specialized agents
β βββ tools/
β β βββ __init__.py
β β βββ blockchain_tools.py # Tools for interacting with Celo blockchain
β β βββ search_tools.py # Tools for web search using Tavily
β βββ utils/
β βββ __init__.py
β βββ config.py # Configuration and environment variables
βββ main.py # Application entry point
βββ pyproject.toml # Dependencies and project metadata
βββ README.md
How It Worksβ
- The Supervisor Agent analyzes user queries and determines which specialized agent to use
- For blockchain-related queries, the Blockchain Agent fetches real-time data from the Celo blockchain
- For information retrieval, the Search Agent uses Tavily to search the web for relevant information
- All conversation state is maintained using thread IDs for coherent multi-turn interactions
- The system uses Google's Gemini models for intelligent natural language understanding and generation
Licenseβ
MIT