Large language models like ChatGPT have become commonplace tools, helping me write emails as well as code. Other times, though, I found that one LLM wasn't sufficient to manage complex, multistep tasks. That's where I started exploring "multi-agent systems."
Steps we'll cover:
- What Are Multi-Agent LLM Systems?
- Why I Started Using Multi-Agent Systems and Their Benefits
- Choosing the Right LLM for Your Agents
- How I Use VoltAgent for Multi-Agent Systems
- My Final Thoughts
What Are Multi-Agent LLM Systems?
Simply put, I see an agent system like having multiple specialist AI agents working together to accomplish an objective. I think of it like project work where individuals have specific talents. In my experience, there is often one "boss" agent that oversees the team to assign individual tasks to individual "sub-agents."
- A Research Agent gathers relevant data from the internet.-
- The Writer Agent processes this information to create the report.
- The draft goes through review and polishing by an Editor Agent.
- A Summarizer agent creates a short summary of the final report.
The Supervisor Agent organizes all this by assigning tasks to the respective agents and collating their results before presenting the final output.
Why I Started Using Multi-Agent Systems and Their Benefits
Instead of relying on a single AI to carry out all tasks, I've found allocating tasks between specialist agents has numerous benefits:
- Expertise: Each agent has an area of specialty (e.g., coding, translation or data analysis), leading to higher-quality results in my projects.
- Multistep workflows: Steps in tasks that have more than one step (e.g., product concept creation, market research, preparation of presentations) become more manageable. The flow is coordinated by the supervisor.
- Scalability & Modularity: Sub-problems of complex tasks are broken down. I find integrating new, specialist agents is easy, or existing ones can simply be modified.
- Enhanced Quality Output: Through concentrated capabilities of task-specific agents for individual sections of an inquiry, overall performance in terms of output is improved.
- Flexibility: Any combination of agents can perform more than one task, giving me more options.
Are There Any Downsides? My Experience with Challenges
Like any technology I work with, multi-agent systems aren't without their challenges:
- Coordination Complexity: Coordination between agents involves delegating tasks, including communication, that adds complexity to my setups.
- Dealing with errors: A single agent's mistake or miscommunication can influence all processes, making it hard sometimes to pinpoint where the issue lies.
- Cost: Deploying multiple agents can potentially be computationally more expensive than deploying one. Fortunately, modern architectures like VoltAgent, which I'll discuss next, help address these limitations.
Choosing the Right LLM for Your Agents
Selecting the appropriate Large Language Model (LLM) for each agent, including the supervisor, is a key part of designing an effective multi-agent system. It's not always necessary, or even optimal, for every agent to use the same model. Here are a few things I consider:
- Task Needs: Does an agent need strong reasoning (like a supervisor might), creative flair (like a writer), or specific knowledge (like a coder)? I try to match the model's strengths to the agent's role.
- Cost & Speed: More powerful models often deliver better results but come at a higher cost and potentially slower response times. I might use a top-tier model for the supervisor or critical tasks, but opt for faster, cheaper models (like
gpt-4o-mini
in my example) for simpler, high-frequency subtasks. - Mixing Models: One of the advantages I find with VoltAgent is the flexibility to easily assign different LLMs to different agents. This allows me to optimize both performance and cost across the entire system.
Instead of just reading my considerations, try this interactive guide to get a suggestion based on your needs:
Remember, these are just starting points. Ultimately, I recommend experimenting...
How I Use VoltAgent for Multi-Agent Systems
I've found VoltAgent to be an effective tool for creating AI agents, and I can develop multiple agents simply using its Supervisor Agents and Subagents.
- Define Agents: First, I define my subagents that specialize in a particular task (e.g., "Story Writer" agent, "Translator" agent). An agent consists of a name, description (instructions), and the LLM it uses.
- Build the Supervisor: Second, I build the supervisor agent that will manage these subagents. In defining the supervisor, I simply specify which subagents it will manage using the
subAgents
parameter. - Automatic Installation: What I like is that whenever I install a supervisor agent, VoltAgent automatically configures the following in the background:
- It revises the supervisor's system message (i.e., its basic instructions) to include instructions on treating its subagents.
- Includes in the supervisor an additional
delegate_task
tool that allows it to delegate tasks to subagents. - Holds records for agent relations.
- Task Flow: The process usually goes like this:
- I forward my request to the supervisor agent.
- The supervisor reviews the request to select which subagents will most effectively accomplish the task.
- It uses
delegate_task
to delegate the task(s) to the corresponding subagents. - Subagents carry out their assignments and report their results back to the supervisor.
- The supervisor combines results from all subagents and provides the final answer.
Let Me Show You a Practical Example with VoltAgent
Let me walk you through the story writing and translation example I built. First, I needed a VoltAgent project, which I created easily using the command line:
npm create voltagent-app@latest my-multi-agent-project
cd my-multi-agent-project
Before proceeding, I needed to provide my OpenAI API key. I created a file named .env
in the root of my my-multi-agent-project
directory and added my key like this:
# .env file
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Replace sk-proj-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
with your actual OpenAI API key. VoltAgent automatically loaded this key for me.
This command set up my basic VoltAgent project structure 🎉
Now, I modified the agent logic (typically in a file like src/index.ts
or similar within the new project) to implement my supervisor and subagents:
// Inside your VoltAgent project (e.g., src/index.ts)
import { VoltAgent, Agent } from "@voltagent/core";
import { VercelAIProvider } from "@voltagent/vercel-ai";
import { openai } from "@ai-sdk/openai";
// 1. Create Subagents
const storyWriter = new Agent({
name: "Story Writer",
description: "You are an expert at writing creative and engaging short stories.",
llm: new VercelAIProvider(),
model: openai("gpt-4o-mini"),
});
const translator = new Agent({
name: "Translator",
description: "You are a skilled translator, proficient in translating text accurately.",
llm: new VercelAIProvider(),
model: openai("gpt-4o-mini"),
});
// 2. Create the Supervisor Agent (linking subagents)
const supervisorAgent = new Agent({
name: "Supervisor Agent",
description:
"You manage workflows between specialized agents. " +
"When asked for a story, use the Story Writer. " +
"Then, use the Translator to translate the story. Present both versions to the user.",
llm: new VercelAIProvider(),
model: openai("gpt-4o-mini"),
// Connect the subagents here
subAgents: [storyWriter, translator],
});
new VoltAgent({
agents: {
supervisorAgent,
},
});
After saving this code (e.g., in src/index.ts
), I opened my terminal in the project directory (my-multi-agent-project
) and installed the necessary dependencies:
npm install
Once the dependencies were installed, I started the VoltAgent development server:
npm run dev
I saw output similar to this in my terminal, indicating the server was running:
══════════════════════════════════════════════════
VOLTAGENT SERVER STARTED SUCCESSFULLY
══════════════════════════════════════════════════
✓ HTTP Server: http://localhost:3141
Developer Console: https://console.voltagent.dev
══════════════════════════════════════════════════
Then, I opened my web browser and navigated to the Developer Console URL shown (https://console.voltagent.dev).
Inside the console:
- I could see my agents listed. I clicked on "Supervisor Agent".
- In the agent details view, I clicked the chat icon (usually in the bottom right).
- I typed my request into the chat input:
Write a short story about a robot learning to paint and translate it to German.
and pressed Enter.
The Supervisor Agent then executed the workflow: it first delegated the story writing task to the Story Writer
subagent, then delegated the translation task to the Translator
subagent, and finally presented both results in the chat interface. I found that VoltAgent handled all the background coordination automatically.
My Final Thoughts
In my view, Multi-agent LLM systems represent the next step in AI capabilities. I've seen how they break hard challenges down, combine multiple areas of knowledge, and permit more powerful, more flexible solutions. For me, VoltAgent has been an invaluable instrument that simplifies designing and embedding these sophisticated systems.
Are you ready to build your own AI team? I hope this guide helps!