Introduction

articles here in TDS, we explored the fundamentals of Agentic AI. I have been sharing with you some concepts that will help you navigate through this sea of content we have been seeing out there.

In the last two articles, we explored things like:

  • How to create your first agent
  • What are tools and how to implement them in your agent
  • Memory and reasoning
  • Guardrails
  • Agent evaluation and monitoring

Nice! If you want to read about it, I suggest you look at the articles [1] and [2] from the References section.

Agentic AI is one of the hottest subjects at the moment, and there are several frameworks you can choose from. Fortunately, one thing that I have seen from my experience learning about agents is that these fundamental concepts can be carried over from one to another.

For example, the class Agent from one framework becomes chat in another, or even something else, but usually with similar arguments and the very same objective of connecting with a Large Language Model (LLM).

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

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

For the sake of consistency, I will continue to use Agno as our framework.

Let’s do this.

Multi-Agent Teams

A multi-agent team is nothing more than what the word means: a team with more than one agent.

But why do we need that?

Well, I created this simple rule of thumb for myself that, if an agent needs to use more than 2 or 3 tools, it is time to create a team. The reason for this is that two specialists working together will do much better than a generalist.

When you try to create the “swiss-knife agent”, the probability of seeing things going backwards is high. The agent will become too overwhelmed with different instructions and the quantity of tools to deal with, so it ends up throwing an error or returning a poor result.

On the other hand, when you create agents with a single purpose, they will need just one tool to solve that problem, therefore increasing performance and improving the result.

To coordinate this team of specialists, we will use the class Team from Agno, which is able to assign tasks to the proper agent.

Let’s move on and understand what we will build next.

Project

Our project will be focused on the social media content generation industry. We will build a team of agents that generates an Instagram post and suggests an image based on the topic provided by the user.

  1. The user sends a prompt for a post.
  2. The coordinator sends the task to the Writer
    • It goes to the internet and searches for that topic.
  3. The Writer returns text for the social media post.
  4. Once the coordinator has the first result, it routes that text to the Illustrator agent, so it can create a prompt for an image for the post.
Workflow of the Team of agents. Image by the author.

Notice how we are separating the tasks very well, so each agent can focus solely on their job. The coordinator will make sure that each agent does their work, and they will collaborate for a good final result.

To make our team even more performant, I will restrict the subject for the posts to be created about Wine & Fine Foods. This way, we narrow down even more the scope of knowledge needed from our agent, and we can make its role clearer and more focused.

Let’s code that now.

Code

First, install the necessary libraries.

pip install agno duckduckgo-search google-genai

Create a file for environment variables .env and add the needed API Keys for Gemini and any search mechanism you are using, if needed. DuckDuckGo does not require one.

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

Import the libraries.

# 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

Creating the Agents

Next, we will create the first agent. It is a sommelier and specialist in gourmet food.

  • It needs a name for easier identification by the team.
  • The role telling it what its specialty is.
  • A description to tell the agent how to behave.
  • The tools that it can use to perform the task.
  • add_name_to_instructions is to send along with the response the name of the agent who worked on that task.
  • We describe the expected_output.
  • The model is the brain of the agent.
  • exponential_backoff and delay_between_retries are to 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 us create the Illustrator agent. 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
)

Creating the Team

To make these two specialized agents work together, we need to use the class Agent. We give it a name and use the argument to determine the type of interaction that the team will have. Agno makes available the modes coordinate, route or collaborate.

Also, don’t forget to use share_member_interactions=True to make sure that the responses will flow smoothly among the agents. You can also use enable_agentic_context, that enables team context to be shared with team members.

The argument monitoring is nice if you want to use Agno’s built-in monitor dashboard, available at https://app.agno.com/

# 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 the Team’s response. Image by the author.

This is how the 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.

After we have this text file, we can go to whatever LLM we like better to create images, and just copy and paste the Prompt to generate an image.

And here is a mockup of how the post would be.

Mockup of the post generated by the Multi-agent team. Image by the author.

Pretty good, I’d say. What do you think?

Before You Go

In this post, we took another step in learning about Agentic AI. This topic is hot, and there are many frameworks available in the market. I just stopped trying to learn them all and chose one to start actually building something.

Here, we were able to semi-automate the creation of social media posts. Now, all we have to do is choose a topic, adjust the prompt, and run the Team. After that, it is all about going to social media and creating the post.

Certainly, there is more automation that can be done in this flow, but it is out of scope here.

Regarding building agents, I recommend that you take the easier frameworks to start, and as you need more customization, you can move on to LangGraph, for example, which allows you that.

Contact and Online Presence

If you liked this content, find more of my work and social media in my website:

https://gustavorsantos.me

GitHub Repository

https://github.com/gurezende/agno-ai-labs

References

[1. Agentic AI 101: Starting Your Journey Building AI Agents] https://towardsdatascience.com/agentic-ai-101-starting-your-journey-building-ai-agents/

[2. Agentic AI 102: Guardrails and Agent Evaluation] https://towardsdatascience.com/agentic-ai-102-guardrails-and-agent-evaluation/

[3. Agno] https://docs.agno.com/introduction

[4. Agno Team class] https://docs.agno.com/reference/teams/team

Share.

Comments are closed.