Skip to main content
This tutorial guides you through creating a multi-agent system using Galadriel, demonstrating a manager-worker pattern where a manager agent coordinates with a specialized worker agent to accomplish tasks. This setup allows for efficient delegation and specialization, improving overall system performance.

Prerequisites

Before you begin, ensure you have:
  • Python 3.10 or higher
  • Galadriel installed
  • An OpenAI API key

Setup

Create a project directory:
Set up a virtual environment:
Install Galadriel:

Code Implementation

1. Project Structure

Create the following files:
  • agent.py: Contains the agent definitions and runtime setup.
  • template.env: Stores environment variables.

2. Define Environment Variables

Create a .env file with your OpenAI API key:

3. Implement the Agents

Open agent.py and add the following code:

Run the Example

Set the OPENAI_API_KEY in your environment:
Run the agent:

Expected Output

The agent will perform a web search to find the most recent tweets from Daige on X (Twitter) and provide a summary.

Conclusion

This tutorial demonstrated how to create a multi-agent system using Galadriel. By creating a manager agent that delegates tasks to a specialized worker agent, you can build more efficient and modular AI systems.