Home / Blog / Let's Break Down AI Agents

Let's Break Down AI Agents

Learning Feb 26, 2025 5 min read
V

Vithushan Sylvester

Chief Architect

Let's Break Down AI Agents

AI agents are the coolest tech out there, changing how we talk to machines and process info. These agents, powered by fancy tech like Large Language Models (LLMs), are made up of different parts and processes that can be complex but super interesting. However, a vast segment of the tech world has yet to catch up with this new paradigm.

So, In this article, we’ll break down the inner workings of AI agents in a way that’s easy to understand. We’ll cover their basics, how they think, how they call functions (with examples), and how they store info.

What are AI Agents?


The definition of an AI agent is evolving day by day as the new innovations gets into agentic world. But as of today in early 2025, AI agents are like robots that can do things on their own. They can see their surroundings, figure out what they want to do, and then do it. They’re often powered by LLMs (like OpenAI’s GPT models), which give them the “thinking” and “language understanding” skills. They also have other tools like APIs, databases, and special math algorithms that help them do specific things.


Core Components of AI Agents


Basic Architecture of an AI Agent (composed by the author)

AI agents are built on several interconnected components that enable them to understand, reason, and act autonomously:

  • Foundation Model (e.g., LLMs): Serves as the brain of the agent, capable of understanding and generating natural language.

  • Reasoning Mechanisms: Techniques that help the agent make decisions or draw conclusions.

  • Function Calling Systems: Allows the agent to execute external tasks (e.g., querying APIs, running scripts).

  • Memory Architecture: Ensures persistence of information across interactions for contextual understanding.

Now, let’s dig deeper into each of these components.

1. Large Language Models (LLMs)


LLMs such as GPT-4 oor DeepSeek R1 form the backbone of many AI agents. These models leverage Transformer architectures to predict and generate text based on prompts. The key ideas behind LLMs are:

  • Pretrained Knowledge: LLMs are trained on massive datasets to learn language patterns, concepts, and general knowledge.

  • Tokenization: Text input is converted into tokens (small units of information) before being processed.

  • Contextual Understanding: Models use the prompt and previous tokens to predict the next one, ensuring coherent responses.

For example, suppose an AI agent is asked: “What is the capital of Sri Lanka?” The LLM will understand the query, access its pretrained knowledge, and respond with “Colombo.” (or “Sri Jayawardenepura Kotte” if being specific).

2. Reasoning Techniques: How AI Agents Think


Reasoning is the process through which AI agents make informed decisions. Below are few common reasoning techniques used in basic agents.

  • Chain-of-Thought (CoT): Encourages the model to reason step-by-step to improve accuracy, especially for complex tasks.

  • Self-Reflection: The agent evaluates its own responses and refines its reasoning.

  • ReACT (Reasoning + Acting): This is a powerful reasoning technique that enables AI agents to think and take actions iteratively. It combines chain-of-thought reasoning (where the model explains its thought process step by step) with action execution (where the model interacts with tools or APIs).

Example of Chain-of-Thought Reasoning:

Input:
“Ali has 3 apples. Sara gives him 5 more. How many apples does Ali have now?”
The AI agent may respond:
“Ali initially had 3 apples.”
“Sara gave him 5 more apples.”
“3 + 5 = 8.”
“Ali now has 8 apples.”

3. Function Calling: Letting AI Interact with APIs or Any similar interface


Function calling is a powerful mechanism where an AI agent interfaces with external systems, such as APIs or custom functions, to retrieve, compute, or manipulate data. This increases the agent’s functional capacity beyond its built-in knowledge. Most of the modern foundation models are supporting function calling.

  • Agent Identifies the Task: Based on the input, the agent decides it needs to call a function.

  • Function Description: Functions are described to the agent using metadata (e.g., function names, parameters, and expected output) AKA method signature.

  • Function Invocation: The agent generates a function call in the appropriate format.

  • Execution & Response: The function executes, and the result is sent back to the agent for further processing.

Here’s a Python code snippet to demonstrate how function calling works with an AI agent using OpenAI’s GPT API and a simple git_weather function.

import openai
# Define the function the AI agent can use
def get_weather(city):
 # Dummy function to simulate fetching weather
 return f"The current weather in {city} is sunny with a temperature of 30°C."
# Simulated function calling mechanism
functions = {
 "get_weather": get_weather
}
# Simulating user query
user_query = "What's the weather like in Colombo?"
# Send user query to GPT model
response = openai.ChatCompletion.create(
 model="gpt-4o-mini",
 messages=[
   {"role": "system", "content": "You are a helpful assistant."},
   {"role": "user", "content": user_query}
 ],
 functions=[
   {"name": "get_weather", "parameters": {"city": "string"}}
 ]
)
# Extract the function call from GPT's response
function_call = response['choices'][0].get('function_call')
if function_call:
 function_name = function_call['name']
 parameters = function_call['arguments']
 # Call corresponding function
 result = functions[function_name](**parameters)
 print(result) # Outputs: "The current weather in Colombo is sunny wi

4. Memory: Giving Agents Contextual Awareness


Memory is vital for AI agents to persist information across interactions. Without memory, an AI agent will treat each interaction as independent, limiting its usefulness in multi turn conversations or tasks requiring continuity.

Types of Memory:

Short-Term Memory: Retains context only for the duration of a session.

  • Example: A chatbot remembering the context of a conversation until the session ends.

Long-Term Memory: Stores information persistently across sessions.

  • Example: Virtual assistants remembering your preferences (e.g., “remind me to buy coffee every Friday”).

How Memory Works:

Memory systems store key-value pairs or embeddings (vector representations of text). When a user interacts with the agent, the stored information is retrieved and appended to the input. please check out the following article to know more on memory

(https://medium.com/ideaboxai/blueprint-to-make-your-ai-agents-learn-adapt-and-improve-over-time-785a72188245)

Conclusion

AI agents are more than just language generators. By integrating reasoning techniques, function calling, and memory, these agents evolve into powerful tools capable of solving a wide variety of tasks. Understanding their internals helps us appreciate their capabilities and limitations, paving the way for further innovation.

As AI continues to advance, the future holds even more exciting possibilities. Whether it’s automating workflows, answering complex questions, or operating as digital assistants, AI agents are here to stay and they’re getting smarter every day!

Share Blog


READY TO BEGIN

Build AI Around the Way Your Teams Work

Start with one role, one workflow, and one measurable outcome.

Talk to an Expert