A few months ago, I asked ChatGPT to help me plan a trip to Istanbul. It gave me a beautiful itinerary. But when I asked it to go ahead and book the flights, check hotel availability, and send me a confirmation email, it just stared back at me (metaphorically) and said it could not do any of that.
That moment stuck with me. The model was smart. It could reason, write, and plan. But it could not act. It had no hands.
That is exactly the problem AI agents are built to solve.
In this article, we are going to break down what AI agents actually are, how they are different from a regular chatbot, and why tools like LangChain exist. No jargon. No fluff. Just a clear picture of what is going on under the hood.
First, What Is a Regular LLM?
LLM stands for Large Language Model. Think of it as an incredibly well-read assistant who has consumed billions of pages of text and learned to predict what comes next in a conversation.
When you type a message into ChatGPT or Claude, here is what happens:
- You send a message (called a prompt).
- The model processes it and generates a response.
- That response comes back to you.
That is it. One round trip. The model does not remember your previous conversations (unless the app saves them for you), does not browse the internet, does not check your calendar, and does not take any action in the real world.
It is like talking to someone who gives great advice but cannot do anything for you directly.
So What Makes Something an "Agent"?
An AI agent is a system where a language model is given tools and the ability to decide when and how to use them to complete a goal.
Instead of just answering your question, an agent can:
- Search the web for current information
- Run Python code
- Query a database
- Send an email
- Read and write files
- Call external APIs
The key word here is autonomy. You give the agent a goal, and it figures out the steps on its own.
Here is a simple comparison:
| Regular LLM | AI Agent |
|---|---|
| Answers questions | Takes actions |
| Single response | Multi-step reasoning |
| No memory by default | Can maintain context |
| No tools | Uses tools to interact with the world |
| Reactive | Goal-driven |
A Real-World Example: The Travel Booking Agent
Let us go back to the Istanbul example. Instead of a plain LLM, imagine you had an agent set up like this:
Goal: Plan and book a 5-day trip to Istanbul for next month.
Here is how the agent might think through it step by step:
Step 1: Search the web for best time to visit Istanbul in [current month + 1]
Step 2: Use the flight search tool to find available flights from my city
Step 3: Use the hotel API to check availability and pricing
Step 4: Calculate total cost and check if it fits the budget
Step 5: Send a summary email with options
Step 6: If confirmed, proceed with booking
The agent is not just answering. It is reasoning, planning, and acting across multiple steps using multiple tools. That is the fundamental shift.
The Brain Behind the Agent: The Reasoning Loop
Most AI agents follow a pattern called ReAct, which stands for Reason and Act. The loop looks like this:
THOUGHT --> What do I need to do next?
ACTION --> Call a tool (search, calculate, etc.)
OBSERVE --> See what the tool returned
THOUGHT --> Based on the result, what do I do next?
ACTION --> Call another tool or generate final answer
...repeat until goal is complete
This loop is what makes agents powerful. They can handle tasks that require multiple steps, course-correct when something fails, and adapt based on what they find.
Here is a tiny pseudocode sketch of this idea:
goal = "Find the weather in Istanbul and tell me if I need a jacket"
while not goal_complete:
thought = llm.think(goal, history)
if thought.needs_tool:
result = tools[thought.tool_name].run(thought.tool_input)
history.append(result)
else:
final_answer = thought.answer
goal_complete = True
print(final_answer)
This is a simplified version of what frameworks like LangChain implement for you. You do not have to build this loop from scratch.
Where Does LangChain Come In?
Building an agent from scratch is hard. You need to:
- Format prompts correctly for the model
- Parse the model's output to figure out which tool it wants to call
- Actually call that tool
- Feed the result back into the model
- Handle errors when tools fail
- Manage memory across steps
LangChain is a Python (and JavaScript) framework that handles all of this plumbing for you. It gives you:
- Pre-built agent types (ReAct, OpenAI Functions, etc.)
- A library of tools (web search, calculators, code interpreters, and more)
- Memory modules so your agent can remember past steps
- Chain primitives to connect prompts, models, and tools together
Think of LangChain as the scaffolding that lets you focus on what your agent should do rather than how all the pieces fit together.
And What Is LangGraph?
LangGraph is a newer library built on top of LangChain. It is designed for building agents that need more complex, structured workflows.
Regular agents are great for linear tasks. But what if your agent needs to:
- Make decisions and branch into different paths
- Run multiple tasks in parallel
- Loop back to an earlier step based on a condition
- Coordinate multiple agents working together
LangGraph lets you model your agent as a graph where:
- Nodes are steps or actions (call the LLM, run a tool, check a condition)
- Edges are the transitions between them (go to step A or step B based on the result)
This makes it much easier to build reliable, production-grade agents that behave predictably.
We will get into LangGraph in detail later in this series. For now, just know it exists and it is for when your workflows get more complex.
What Is a Chat LLM?
Throughout this series, we will be using what LangChain calls a Chat LLM (also called a Chat Model).
A Chat LLM is a model that is designed to take a list of messages as input rather than a single string. Each message has a role:
- System -- background instructions for how the model should behave
- Human -- what the user says
- AI -- what the model previously responded
This structure mirrors how a real conversation works and gives you much more control over how the model behaves. Most modern models (GPT-4, Claude, Gemini) are chat models.
A quick preview of what this looks like in LangChain:
from langchain_openai import ChatOpenAI
from langchain_core.messages import SystemMessage, HumanMessage
# Initialize the chat model
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
# Create a list of messages
messages = [
SystemMessage(content="You are a helpful travel assistant."),
HumanMessage(content="What should I pack for a trip to Istanbul in October?")
]
# Get a response
response = llm.invoke(messages)
print(response.content)
Do not worry if this code looks unfamiliar. We will walk through every line of it in the next article when we set up our environment.
Putting It All Together
Here is the big picture before we move on:
Your Goal
|
v
AI Agent (powered by an LLM)
|
|-- uses --> Tools (web search, APIs, code, etc.)
|-- uses --> Memory (to remember context)
|-- follows --> A Reasoning Loop (think, act, observe)
|
v
Result / Action in the Real World
LangChain is the framework that wires all of this together. LangGraph is the tool you reach for when that wiring gets complex.
Key Takeaways
- A regular LLM responds to prompts but cannot take action in the world.
- An AI agent is an LLM that is given tools and the ability to decide when to use them.
- The ReAct loop (Reason, Act, Observe) is the core pattern most agents follow.
- LangChain is a Python framework that handles the plumbing of building agents.
- LangGraph extends LangChain for complex, multi-step, branching workflows.
- Chat LLMs take structured message lists as input, giving you more control over model behavior.
What Is Coming Next
In the next article, we are going to get our hands dirty. We will set up our Python environment, install LangChain, connect to an LLM, and run our first real chat call. By the end of it, you will have a working setup and your first "Hello, Agent" moment.
See you there.
Top comments (0)