The Artificial Intelligence industry is moving fast. It’s impressive and again and again overwhelming.
I even have been studying, learning, and constructing my foundations on this area of Data Science because I consider that the longer term of Data Science is strongly correlated with the event of Generative AI.
It was just the opposite day after I built my first Ai Agent, after which a few weeks after that, there have been several Python packages to pick from, not to say the no-code options which are doing thoroughly, like .
From “mere” models that might just chat with us to a of AI Agents which are all over the place, searching the Web, handling files, and making whole Data Science projects (from EDA to modeling and evaluation), all of that happened in only a few years.
What?
Seeing all of that, my thought was: . In any case, it’s higher to surf the wave than be swallowed by it.
For that reason, I made a decision to begin this series of posts where I plan to go from the basics to construct our first AI Agent, until more complex concepts.
Enough talk, let’s dive in.
The Basics of AI Agents
An AI Agent is created after we give the Llm the ability to interact with tools and perform useful actions for us. So, as a substitute of being only a chatbot, now it will probably schedule appointments, handle our calendar, search the web, write social media posts, and the list goes on…
AI Agents can do useful things, not only chat.
But how can we give that power to an LLM?
The straightforward answer is to make use of an API to interact with the LLM. There are several Python packages for that these days. When you follow my blog, you will notice that I even have already tried a few packages to construct agents: Langchain, Agno (former PhiData), and CrewAI, for example. For this series, I’ll keep on with Agno [1].
First, arrange a virtual environment using uv
, Anaconda, or the environment handler of your preference. Next, install the packages.
# Agno AI
pip install agno
# module to interact with Gemini
pip install google-generativeai
# Install these other packages that will likely be needed throughout the tutorial
pip install agno groq lancedb sentence-transformers tantivy youtube-transcript-api
Quick note before we proceed. Don’t forget to get a Google Gemini API Key [2].
Creating a straightforward agent could be very easy. All of the packages are very similar. They’ve a category Agent
or something similar that permits us to pick a model and begin interacting with the LLM of our alternative. Listed below are the major components of this class:
model
: the reference to the LLM. Here we are going to make a choice from OpenAI, Gemini, Llama, Deepseek etc.description
: This argument lets us describe the behavior of the agent. That is added to thesystem_message
, which is the same argument.instructions
: I like to think about an agent like an worker or an assistant that we’re managing. As a way to have a task done, we must provide the instructions of what must be done. Here is where you possibly can try this.expected_output
: Here we can provide instructions concerning the expected output.tools
: That is what makes the LLM an Agent, enabling it to interact with the actual world using these tools.
Now, let’s create a straightforward agent that has no tools, but will serve to construct our intuition across the structure of the code.
# Imports
from agno.agent import Agent
from agno.models.google import Gemini
import os
# Create agent
agent = Agent(
model= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "An assistant agent",
instructions= ["Be sucint. Answer in a maximum of 2 sentences."],
markdown= True
)
# Run agent
response = agent.run("What is the weather like in NYC in May?")
# Print response
print(response.content)
########### OUTPUT ###############
Expect mild temperatures in NYC during May, typically starting from the low 50s
to the mid-70s Fahrenheit.
There is a likelihood of rain, so packing layers and an umbrella is advisable.
That’s great. We’re using the Gemini 1.5 model. Notice the way it responds based on the info it was trained on. If we ask it to inform us the weather today, we’ll see a response saying it will probably’t access the web.
Let’s explore the instructions
and expected_output
arguments. We now need a table with the month, season and average temperature for NYC.
# Imports
from agno.agent import Agent
from agno.models.google import Gemini
import os
# Create agent
agent = Agent(
model= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "An assistant agent",
instructions= ["Be sucint. Return a markdown table"],
expected_output= "A table with month, season and average temperature",
markdown= True
)
# Run agent
response = agent.run("What is the weather like in NYC for every month of the 12 months?")
# Print response
print(response.content)
And there’s the result.
Month | Season | Average Temperature (°F) |
---|---|---|
January | Winter | 32 |
February | Winter | 35 |
March | Spring | 44 |
April | Spring | 54 |
May | Spring | 63 |
June | Summer | 72 |
July | Summer | 77 |
August | Summer | 76 |
September | Autumn | 70 |
October | Autumn | 58 |
November | Autumn | 48 |
December | Winter | 37 |
Tools
The previous responses are nice. But we naturally don’t wish to use powerful models akin to LLMs to play with a chatbot or tell us old news, right?
We would like them to be a bridge to automation, productivity, and knowledge. So, the Tools will add capabilities to our AI Agents, constructing, subsequently, the bridge with the actual world. Common examples of tools for agents are: searching the online, running SQL, sending an email or calling APIs.
But greater than that, we are able to create custom capabilities to our agents by utilizing any Python function as a tool.
Tools are functions that an Agent can run to attain tasks.
By way of code, adding a tool to the Agent is only a matter of using the argument tools
within the Agent
class.
Imagine a solopreneur (one-person company) within the healthy living business who desires to automate their content generation. This person posts recommendations on healthy habits day by day. I do know for a indisputable fact that content generation will not be as straightforward because it looks like. It demands creativity, research, and copywriting skills. So, if this may very well be automated, or at the least a part of it, that’s time saved.
So we write this code to create a quite simple agent that may generate a straightforward Instagram post and put it aside to a markdown file for our review. We reduced the method from pondering > researching > writing > reviewing > posting to reviewing > posting.
# Imports
import os
from agno.agent import Agent
from agno.models.google import Gemini
from agno.tools.file import FileTools
# Create agent
agent = Agent(
model= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "You're a social media marketer specialized in creating engaging content.",
tools=[FileTools(
read_files=True,
save_files=True
)],
show_tool_calls=True)
# Writing and saving a file
agent.print_response("""Write a brief post for instagram with suggestions and tricks
that positions me as an authority in healthy eating
and put it aside to a file named 'post.txt'.""",
markdown=True)
Because of this, we now have the next.
Unlock Your Best Self Through Healthy Eating:
1. Prioritize whole foods: Load up on fruits, vegetables, lean proteins, and whole
grains. They're full of nutrients and keep you feeling full and energized.
2. Mindful eating: Listen to your body's hunger and fullness cues.
Avoid distractions while eating.
3. Hydrate, hydrate, hydrate: Water is crucial for digestion, energy levels,
and overall health.
4. Don't deprive yourself: Allow for infrequent treats.
Deprivation can result in overeating later. Enjoy every part carefully!
5. Plan ahead: Prep your meals or snacks upfront to avoid unhealthy
impulse decisions.
#healthyeating #healthylifestyle #nutrition #foodie
#wellbeing #healthytips #eatclean #weightloss #healthyrecipes
#nutritiontips #instahealth #healthyfood #mindfuleating #wellnessjourney
#healthcoach
Definitely, we could make it rather more fancy by making a crew with other agents to go looking a listing of internet sites for content, a content checker and reviewer, and one other one to generate a picture for the post. But I consider you bought the overall idea of learn how to add a tool
to an Agent
.
One other sort of tool we are able to add is the function tool. We will use a Python function to function a tool for the LLM. Just don’t forget so as to add the sort hints like video_id:str
, so the model knows what to make use of because the function’s input. Otherwise, you may see an error.
Let’s see briefly how that works.
We now want our Agent to have the opportunity to get a given YouTube video and summarize it. To perform such a task, we simply create a function that downloads the transcript of the video from YT and passes it to the model to summarize.
# Imports
import os
from agno.agent import Agent
from agno.models.google import Gemini
from youtube_transcript_api import YouTubeTranscriptApi
# Get YT transcript
def get_yt_transcript(video_id:str) -> str:
"""
Use this function to get the transcript from a YouTube video using the video id.
Parameters
----------
video_id : str
The id of the YouTube video.
Returns
-------
str
The transcript of the video.
"""
# Instantiate
ytt_api = YouTubeTranscriptApi()
# Fetch
yt = ytt_api.fetch(video_id)
# Return
return ''.join([line.text for line in yt])
# Create agent
agent = Agent(
model= Gemini(id="gemini-1.5-flash",
api_key = os.environ.get("GEMINI_API_KEY")),
description= "You're an assistant that summarizes YouTube videos.",
tools=[get_yt_transcript],
expected_output= "A summary of the video with the 5 major points and a pair of questions for me to check my understanding.",
markdown=True,
show_tool_calls=True)
# Run agent
agent.print_response("""Summarize the text of the video with the id 'hrZSfMly_Ck' """,
markdown=True)
After which you could have a result.
Agents with Reasoning
One other cool option from the Agno package is allowing us to simply create agents that may analyze the situation before answering a matter. That’s the reasoning tool.
We are going to create a reasoning agent with Alibaba’s Qwen-qwq-32b model. Notice that the one difference here, besides the model, is that we’re adding the tool ReasoningTools()
.
The adding_instructions=True
means providing detailed instructions to the agent, which reinforces the reliability and accuracy of its tool usage, while setting this to False
forces the agent to depend upon its own reasoning, which might be more vulnerable to errors.
# Imports
import os
from agno.agent import Agent
from agno.models.groq import Groq
from agno.tools.reasoning import ReasoningTools
# Create agent with reasoning
agent = Agent(
model= Groq(id="qwen-qwq-32b",
api_key = os.environ.get("GROQ_API_KEY")),
description= "You're an experienced math teacher.",
tools=[ReasoningTools(add_instructions=True)],
show_tool_calls=True)
# Writing and saving a file
agent.print_response("""Explain the concept of sin and cosine in easy terms.""",
stream=True,
show_full_reasoning=True,
markdown=True)
Follows the output.

Agent with Knowledge
This tool is the simplest way for me to create a Retrieval Augmented Generation (RAG). With this feature, you possibly can point the agent to a web site or a listing of internet sites, and it should add the content to a vector database. Then, it becomes searchable. Once asked, the agent can use the content as a part of the reply.
In this easy example, I added one page of my website and asked the agent what books are listed there.
# Imports
import os
from agno.agent import Agent
from agno.models.google import Gemini
from agno.knowledge.url import UrlKnowledge
from agno.vectordb.lancedb import LanceDb, SearchType
from agno.embedder.sentence_transformer import SentenceTransformerEmbedder
# Load webpage to the knowledge base
agent_knowledge = UrlKnowledge(
urls=["https://gustavorsantos.me/?page_id=47"],
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="projects",
search_type=SearchType.hybrid,
# Use Sentence Transformer for embeddings
embedder=SentenceTransformerEmbedder(),
),
)
# Create agent
agent = Agent(
model=Gemini(id="gemini-2.0-flash", api_key=os.environ.get("GEMINI_API_KEY")),
instructions=[
"Use tables to display data.",
"Search your knowledge before answering the question.",
"Only inlcude the content from the agent_knowledge base table 'projects'",
"Only include the output in your response. No other text.",
],
knowledge=agent_knowledge,
add_datetime_to_instructions=True,
markdown=True,
)
if __name__ == "__main__":
# Load the knowledge base, you possibly can comment out after first run
# Set recreate to True to recreate the knowledge base if needed
agent.knowledge.load(recreate=False)
agent.print_response(
"What are the 2 books listed within the 'agent_knowledge'",
stream=True,
show_full_reasoning=True,
stream_intermediate_steps=True,
)

Agent with Memory
The last type we are going to go over on this post is the agent with memory.
This kind of agent can store and retrieve details about users from previous interactions, allowing it to learn user preferences and personalize its responses.
Let’s see this instance where I’ll tell a few things to the agent and ask for recommendations based on that interaction.
# imports
import os
from agno.agent import Agent
from agno.memory.v2.db.sqlite import SqliteMemoryDb
from agno.memory.v2.memory import Memory
from agno.models.google import Gemini
from wealthy.pretty import pprint
# User Name
user_id = "data_scientist"
# Making a memory database
memory = Memory(
db=SqliteMemoryDb(table_name="memory",
db_file="tmp/memory.db"),
model=Gemini(id="gemini-2.0-flash",
api_key=os.environ.get("GEMINI_API_KEY"))
)
# Clear the memory before start
memory.clear()
# Create the agent
agent = Agent(
model=Gemini(id="gemini-2.0-flash", api_key=os.environ.get("GEMINI_API_KEY")),
user_id=user_id,
memory=memory,
# Enable the Agent to dynamically create and manage user memories
enable_agentic_memory=True,
add_datetime_to_instructions=True,
markdown=True,
)
# Run the code
if __name__ == "__main__":
agent.print_response("My name is Gustavo and I'm a Data Scientist learning about AI Agents.")
memories = memory.get_user_memories(user_id=user_id)
print(f"Memories about {user_id}:")
pprint(memories)
agent.print_response("What topic should I study about?")
agent.print_response("I write articles for Towards Data Science.")
print(f"Memories about {user_id}:")
pprint(memories)
agent.print_response("Where should I post my next article?")

And here we end this primary post about AI Agents.
Before You Go
There’s lots of content on this post. We climbed step one on this ladder of learning about AI agents. I do know, it’s overwhelming. There may be a lot information on the market that it becomes harder and harder to know where to begin and what to check.
My suggestion is to take the identical road I’m taking. One step at a time, selecting just a few packages like Agno, CrewAI, and going deep on those, learning learn how to create more complex agents every time.
On this post, we began from scratch, learning learn how to simply interact with an LLM to creating agents with memory, and even creating a straightforward RAG for an AI Agent.
Obviously, there’s rather more you possibly can do exactly with a single agent. Take a look at the Reference [4].
With these easy skills, make sure that you’re ahead of lots of people, and there’s quite a bit you possibly can do already. Just use the creativity and (why not?) ask for the assistance of an LLM to construct something cool!
In the following post, we are going to learn more about agents and evaluation. Stay tuned!
GitHub Repository
https://github.com/gurezende/agno-ai-labs
Contact and Online Presence
When you liked this content, find more of my work and social media in my website:
References
[1] https://docs.agno.com/introduction
[2] https://ai.google.dev/gemini-api/docs
[3] https://pypi.org/project/youtube-transcript-api/
[4] https://github.com/agno-agi/agno/tree/major/cookbook
[5] https://docs.agno.com/introduction/agents#agent-with-knowledge