Data Science

Agent AI 103: Building a multi-agent team

introduce

In the article in TD, we explore the basics of proxy AI. I’ve been sharing some concepts with you that will help you browse what we’ve seen there.

In the last two articles, we explored the following:

  • How to Create Your First Agent
  • What are tools and how to implement them in the proxy
  • Memory and reasoning
  • Guardrail
  • Agent evaluation and monitoring

OK! If you want to read it, I suggest you check out these articles [1] and [2] From the reference section.

Agent AI is one of the hottest topics right now, and you can choose from several frameworks. Fortunately, one thing I have seen from the experience of understanding agents is that these basic concepts can be transferred from one perspective to another.

For example, class Agent From a framework to chat In another or even other aspects, but generally have similar arguments and have the same goal associated with large language models (LLM).

So let’s take another step in the learning journey.

In this post, we will learn how to create multi-agent teams, giving us the opportunity to let AI perform more complex tasks for us.

For consistency, I will continue to use agno As our framework.

Let’s do this.

Multi-agent team

Multi-agent teams are nothing more than the meaning of this word: a team with more than one agent.

But why do we need that?

Well, I created this simple rule of thumb for myself, if the agent needs to use more than 2 or 3 tools, it’s time to build a team. There are two reasons expert Working together will be better than one Generalist.

When you try to create a “Swiss Knife Agent”, it is very likely to see things go backwards. The agent will be overwhelmed by different instructions and the number of tools to be processed, so it will eventually drop an error or return a bad result.

On the other hand, when you create a proxy for one purpose, they only need a tool to solve the problem, thereby improving performance and improving results.

To coordinate this team of experts, we will use this course Team From Agno, the task can be assigned to the appropriate agent.

Let’s move on and see what we’re going to build next.

project

Our projects will focus on the social media content generation industry. We will build a team of agents that generate Instagram posts and present images based on topics provided by users.

  1. User prompts to send a post.
  2. The coordinator sends the task to writer
    • It goes to the internet and searches for the topic.
  3. this writer Return to text on social media posts.
  4. Once the coordinator gets the first result, it routes the text to Illustrator proxy, so you can create prompts for posts.
The workflow of the agent team. Image of the author.

Note how we separate tasks well so each agent can focus on their work. The coordinator will ensure that each agent is doing its job and will work together to achieve good end results.

To make our team more performant, I will limit the topics to create posts about Wine and food. In this way, we narrow down the scope of knowledge required by an agent, and we can make their role clearer and more focused.

Let’s code now.

Code

First, install the necessary libraries.

pip install agno duckduckgo-search google-genai

Create a file for environment variables .env And add the required API keys for Gemini and any search mechanism you use (if needed). Duckduckgo doesn’t need one.

GEMINI_API_KEY="your api key"
SEARCH_TOOL_API_KEY="api key"

Import the library.

# Imports
import os
from textwrap import dedent
from agno.agent import Agent
from agno.models.google import Gemini
from agno.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.file import FileTools
from pathlib import Path

Create a proxy

Next, we will create the first proxy. It is a sommelier and expert in food.

  • It requires a name To make the team easier to identify.
  • this role Tell it what its specialty is.
  • one description Tell the agent how to perform.
  • this tools It can be used to perform tasks.
  • add_name_to_instructions is the response sent with the name of the agent engaged in the task.
  • We describe expected_output.
  • this model It is the brain of the agent.
  • exponential_backoff and delay_between_retries Avoid too many requests to LLMS (Error 429).
# Create individual specialized agents
writer = Agent(
    name="Writer",
    role=dedent("""
                You are an experienced digital marketer who specializes in Instagram posts.
                You know how to write an engaging, SEO-friendly post.
                You know all about wine, cheese, and gourmet foods found in grocery stores.
                You are also a wine sommelier who knows how to make recommendations.
                
                """),
    description=dedent("""
                Write clear, engaging content using a neutral to fun and conversational tone.
                Write an Instagram caption about the requested {topic}.
                Write a short call to action at the end of the message.
                Add 5 hashtags to the caption.
                If you encounter a character encoding error, remove the character before sending your response to the Coordinator.
                        
                        """),
    tools=[DuckDuckGoTools()],
    add_name_to_instructions=True,
    expected_output=dedent("Caption for Instagram about the {topic}."),
    model=Gemini(id="gemini-2.0-flash-lite", api_key=os.environ.get("GEMINI_API_KEY")),
    exponential_backoff=True,
    delay_between_retries=2
)

Now, let’s create the Illustrator proxy. The arguments are the same.

# Illustrator Agent
illustrator = Agent(
    name="Illustrator",
    role="You are an illustrator who specializes in pictures of wines, cheeses, and fine foods found in grocery stores.",
    description=dedent("""
                Based on the caption created by Marketer, create a prompt to generate an engaging photo about the requested {topic}.
                If you encounter a character encoding error, remove the character before sending your response to the Coordinator.
                
                """),
    expected_output= "Prompt to generate a picture.",
    add_name_to_instructions=True,
    model=Gemini(id="gemini-2.0-flash", api_key=os.environ.get("GEMINI_API_KEY")),
    exponential_backoff=True,
    delay_between_retries=2
)

Create a team

To get these two professional agents together, we need to use courses Agent. We give it a name and use argument Determine the type of interaction the team will have. Agno provides the mode coordinate,,,,, route or collaborate.

Also, don’t forget to use share_member_interactions=True Ensure that the response will flow smoothly between agents. You can also use enable_agentic_contextThis allows the team context to be shared with team members.

argument monitoring If you want to use Agno’s built-in monitoring dashboard, that’s fine,

# Create a team with these agents
writing_team = Team(
    name="Instagram Team",
    mode="coordinate",
    members=[writer, illustrator],
    instructions=dedent("""
                        You are a team of content writers working together to create engaging Instagram posts.
                        First, you ask the 'Writer' to create a caption for the requested {topic}.
                        Next, you ask the 'Illustrator' to create a prompt to generate an engaging illustration for the requested {topic}.
                        Do not use emojis in the caption.
                        If you encounter a character encoding error, remove the character before saving the file.
                        Use the following template to generate the output:
                        - Post
                        - Prompt to generate an illustration
                        
                        """),
    model=Gemini(id="gemini-2.0-flash", api_key=os.environ.get("GEMINI_API_KEY")),
    tools=[FileTools(base_dir=Path("./output"))],
    expected_output="A text named 'post.txt' with the content of the Instagram post and the prompt to generate an picture.",
    share_member_interactions=True,
    markdown=True,
    monitoring=True
)

Let’s run it.

# Prompt
prompt = "Write a post about: Sparkling Water and sugestion of food to accompany."

# Run the team with a task
writing_team.print_response(prompt)

This is the response.

Image of team response. Image of the author.

This is what a text file looks like.

- Post
Elevate your refreshment game with the effervescence of sparkling water! 
Forget the sugary sodas, and embrace the crisp, clean taste of bubbles. 
Sparkling water is the ultimate palate cleanser and a versatile companion for 
your culinary adventures.

Pair your favorite sparkling water with gourmet delights from your local
grocery store.
Try these delightful duos:

*   **For the Classic:** Sparkling water with a squeeze of lime, served with 
creamy brie and crusty bread.
*   **For the Adventurous:** Sparkling water with a splash of cranberry, 
alongside a sharp cheddar and artisan crackers.
*   **For the Wine Lover:** Sparkling water with a hint of elderflower, 
paired with prosciutto and melon.

Sparkling water isn't just a drink; it's an experience. 
It's the perfect way to enjoy those special moments.

What are your favorite sparkling water pairings?

#SparklingWater #FoodPairing #GourmetGrocery #CheeseAndWine #HealthyDrinks

- Prompt to generate an image
A vibrant, eye-level shot inside a gourmet grocery store, showcasing a selection
of sparkling water bottles with various flavors. Arrange pairings around 
the bottles, including a wedge of creamy brie with crusty bread, sharp cheddar 
with artisan crackers, and prosciutto with melon. The lighting should be bright 
and inviting, highlighting the textures and colors of the food and beverages.

With this text file we can go to any LLM we prefer to create the image and copy and paste Prompt to generate an image.

This is a model about what the post looks like.

Model of posts generated by multi-agent teams. Image of the author.

Very good, I will say. What do you think?

Before moving forward

In this post, we take another step to understand proxy AI. This topic is very hot and there are many frameworks on the market. I just stopped trying to learn them and instead chose one to start actually building something.

Here we are able to semi-automate the creation of social media posts. Now, all we have to do is select a topic, adjust the prompts and run the team. After that, it’s all about going to social media and creating posts.

Of course, more automation can be done in this process, but the scope here is not out of scope.

Regarding building agents, I recommend you start with a easier framework and since you need more customization, you can move on, for example, which can make you do so.

Contact and exist online

If you like this content, please find more about my work and social media on my website:

GitHub repository

refer to

[1. Agentic AI 101: Starting Your Journey Building AI Agents]

[2. Agentic AI 102: Guardrails and Agent Evaluation]

[3. Agno]

[4. Agno Team class]

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button