2025: The Year of AI Agents – Building Multi-Agent Systems with CrewAi and Gemini 1.5

2025: The Year of AI Agents - Building Multi-Agent Systems with CrewAi and Gemini 1.5

2025: The Year of AI Agents – Building Multi-Agent Systems with CrewAi and Gemini 1.5

As many experts predict, 2025 is gradually becoming the year of agent-based artificial intelligence. This emerging field is poised to redefine the way we interact with technology by introducing highly autonomous systems that can make decisions and execute complex tasks with minimal human intervention. Inspired by this, I began building a multi-agent system that can not only perform specific tasks but also create meaningful content based on user-defined topics.

In this article, I will guide you through the system I built, the challenges I faced, and the exciting future that agent-based AI holds.

What is Agent-Based AI?

Agent-based AI refers to systems designed to perform tasks independently without continuous human supervision. Unlike traditional AI, which requires explicit instructions at every step, agent-based AI can make autonomous decisions and adjust its actions based on changing circumstances.

By 2025, we expect these systems to become central to industries ranging from healthcare to logistics, capable of handling everything from automating repetitive tasks to autonomously solving complex problems. In fact, many predictions suggest that over 60% of corporate AI implementations will integrate agent-based AI in some form.

My Vision Behind the Multi-Agent System

With the vast potential of agent-based AI in mind, I decided to build a simple multi-agent system to showcase its capabilities in content creation and summarization. The system I built accepts user-defined topics, conducts relevant web research, and generates two outputs: a detailed blog post and a concise LinkedIn post.

This project relies on the power of the Gemini 1.5 model, a powerful AI language model that plays a critical role in content generation. Gemini 1.5 offers impressive text generation capabilities, ensuring that the output is both coherent and engaging, along with CrewAi, a platform designed to build and manage AI-driven multi-agent systems. It allows you to create complex workflows by defining agents with specific roles and tasks, and then coordinating them to work seamlessly together.

How the System Works

The multi-agent system I built utilizes three main agents:

Topic Researcher: This agent is responsible for searching and analyzing relevant resources about a given topic from the web. It uses internet search tools to identify the most relevant and informative articles.

Blog Writer: The second agent takes the research findings to write a comprehensive blog post. The blog post includes an introduction, step-by-step guides, and a conclusion, providing readers with a complete understanding of the topic.

LinkedIn Post Creator: The third agent summarizes the information into a concise and engaging LinkedIn post. This agent focuses on crafting messages that resonate with professionals, including relevant hashtags to enhance visibility.

Code Blocks and Explanations

Below are the key components of the system, including code blocks and explanations.

Import Libraries and Initialize Environment

The first step is to load environment variables, such as the API keys for the tools we are using:

import os
from dotenv import load_dotenv
from crewai import Agent, Crew, Process, Task
from crewai_tools import SerperDevTool

# Load environment variables from a .env file
load_dotenv()

# Set the API key for the SerperDevTool (web search tool)
os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY')
GEMINI_API_KEY = os.getenv('GEMINI_API_KEY')

Here, we load the API keys from the .env file to keep them secure instead of hardcoding them directly in the script.

Setting Up AI Tools

Next, we initialize the Gemini 1.5 model and the web search tool (SerperDevTool):

# Initialize the tool for internet searching capabilities
tool = SerperDevTool()
llm = LLM(
    model="gemini/gemini-1.5-flash",  # Specify the AI model to use
    temperature=0.7  # Set the creativity of the model
)

Here, we set up SerperDevTool to perform web searches and use the Gemini 1.5 model to generate content. The temperature parameter controls the creativity or determinism of the responses.

Defining Agents

We defined three agents that work collaboratively to achieve the goal: Topic Researcher, Blog Writer, and LinkedIn Post Creator.

# Define the Topic Researcher agent
topic_researcher = Agent(
    role='Topic Researcher',
    goal='Search for only 1 relevant resource on the topic {topic} from the web',
    verbose=True,
    memory=True,
    backstory='Expert in finding and analyzing relevant content from Web...',
    tools=[tool],
    llm=llm,
    allow_delegation=True
)
# Define the Blog writer agent
blog_writer = Agent(
    role='Blog Writer',
    goal='Write a comprehensive blog post from the only 1 article provided by the Topic Researcher, covering all necessary sections',
    verbose=True,
    memory=True,
    backstory='Experienced in creating in-depth, well-structured blog posts that explain technical concepts clearly and engage readers from introduction to conclusion.',
    tools=[tool],
    llm=llm,
    allow_delegation=True
)
# Define the LinkedIn post writer agent
linkedin_post_agent = Agent(
    role='LinkedIn Post Creator',
    goal='Create a concise LinkedIn post summary from the transcription provided by the Topic Researcher.',
    verbose=True,
    memory=True,
    backstory='Expert in crafting engaging LinkedIn posts that summarize complex topics and include trending hashtags for maximum visibility.',
    tools=[tool],
    llm=llm,
    allow_delegation=True
)

Each agent is defined with specific roles and objectives. For instance, the Topic Researcher agent is responsible for finding relevant articles on the web.

Defining Tasks for Each Agent

Once the agents are set up, we define the tasks that each agent will perform. For example, the Topic Researcher’s task is to identify relevant content:

# Define Tasks
research_task = Task(
    description="Identify and analyze only 1 content or article on the {topic} from the web.",
    expected_output="A complete word-by-word report on the most relevant post or article found on the topic {topic}.",
    agent=topic_researcher,
    tools=[tool]
)
blog_writing_task = Task(
    description="""Write a comprehensive blog post based on the 1 article provided by the Topic Researcher.
                   The article must include an introduction, step-by-step guides, and conclusion.
                   The overall content must be about 400 words long.""",
    expected_output="A markdown-formatted blog post",
    agent=blog_writer,
    tools=[tool],
    output_file='./artifacts/blog-post.md'
)
linkedin_post_task = Task(
    description="Create a LinkedIn post summarizing the key points from the transcription provided by the Topic Researcher, including relevant hashtags.",
    expected_output="A markdown-formatted LinkedIn post",
    agent=linkedin_post_agent,
    tools=[tool],
    output_file='./artifacts/linkedin-post.md'
)

In this case, the tasks involve searching for and analyzing related articles on specific topics, and creating blog and LinkedIn posts.

Running the Process

Once the agents and tasks are set up, we create the crew and initiate the process:

# Create the Crew with defined agents and tasks
my_crew = Crew(
    agents=[topic_researcher, linkedin_post_agent, blog_writer],
    tasks=[research_task, linkedin_post_task, blog_writing_task],
    verbose=True,
    process=Process.sequential  # Run tasks sequentially
)

# Input Topic
topic_of_interest = 'gemini 2.0 multimodel'

# Kick off the process with the provided topic
result = my_crew.kickoff(inputs={'topic': topic_of_interest})
print(result)

Here, the agents work together in a sequential process, ensuring that each agent executes its tasks one after the other. The kickoff method runs the process with the provided topic_of_interest, which in this case is “gemini 2.0 multimodel”.

Generating Outputs

The agents will execute their respective tasks and generate outputs: a comprehensive blog post and a concise LinkedIn post. The results will be printed out at the end.

The Role of Gemini 1.5

One of the most exciting aspects of this project is using the Gemini 1.5 model to power the AI agents. Gemini 1.5 is renowned for its advanced natural language processing capabilities, enabling it to understand and generate human-like text across a wide range of contexts. Whether conducting research or writing content, Gemini 1.5 ensures that the agents effectively complete their tasks with high accuracy and fluency.

Challenges and Lessons Learned

Building this multi-agent system was not without its challenges. Some key obstacles I encountered include:

Integrating Multiple Agents: Ensuring smooth communication between agents is crucial. Each agent has a specific role, but they need to collaborate seamlessly to produce the desired results. I learned that clear and precise task management is essential for the efficiency of the system.

Refining the Research Agent: The task of the Topic Researcher agent is to search for relevant resources on the web. While it performs well overall, it occasionally returns articles that are not entirely relevant to the topic. Fine-tuning its search parameters required some trial and error.

Content Quality Control: Although Gemini 1.5 is highly effective at generating content, the quality of the output depends on the input it receives. It is essential to ensure that the research provided to the blog writing agent and the LinkedIn post creator is comprehensive and clear to produce coherent and well-structured final outputs.

Conclusion

2025 is likely to be the year of agent-based AI, and we are already seeing glimpses of its potential. My multi-agent system is just one example of how AI can be used to automate complex tasks and generate meaningful outputs. As technology continues to advance, we can expect even more powerful systems to emerge, reshaping industries and making AI a key part of our daily lives.

Leave a Comment