We will start with the million dollar question: “What is an AI agent?”.
Everyone seems to have a slightly different definition of what an AI agent is. I like the definition given by Harrison Chase, the co-founder of LangChain:

I feel this is one of the most clean definitions. You can read the full article here.
But how can we use an LLM to decide the control flow of an application?
Well, very often LMMs are referenced as "glorified autocompletes". You will give an LMM an array of words such as "Mike is quick he moves ...", and the LLM will add the word "fast".
For decision-making, we can use the same autocomplete mechanism.
Let's say you pass to the LLM the input "I have a chain saw and a screwdriver. To cut down a tree I will use the ... ". The LLM will respond with "chain saw".
But, in this case, the autocomplete done by the LLM also functioned as a decision. It decided we could use the chain saw tool to achieve the objective.
By the way, the "Mike is quick he moves ..." is an example given by Ishan Anand, in this fantastic talk Decoding the Decoder LLM. I highly recommend you watch that talk if you want to get a deeper understanding of the technical inner workings of LLMs.
In a very simple way we can see AI Agents as a sum of the following parts:

An LLM with looping, termination, and tools is usually considered an AI Agent. A system that loops on the same prompt, or some set of prompts, plus it has the ability to continue execution and then decide when it wants to stop that's an AI Agent.
If you want to read more, Shawn Swyx Wang wrote a really good article on AI Agents.
Picture the following scenario. You open up your computer and type in the following prompt into your favorite LLM:
This weekend I want to do a hiking trip in the south of France! Please arrange all the details for me.
A typical LLM might respond:
I apologize, but as a language model, I'm unable to actually make travel arrangements or bookings for you.
And for good reasons. The LLM would need various pieces of information and capabilities to achieve this objective. For example:
- your current location
- a web browser to check if the weather is suitable for a hiking trip
- a way to book your plane tickets and hotel
- a way to call for a taxi to take you to the airport and hotel
The actions the LLM can take to reach its goals are represented by tools. Tools are typically code functions that allow the LLM to call APIs, browse the web, read or write files on your local machine, and more.
The flow of this personal assistant AI Agent is illustrated in the diagram below:

But where does LangGraph fit into this picture? Well, we will explore that in the next part.
Meet Your New Best Friend: LangGraph
LangGraph is a framework developed by the same company that created LangChain. Its purpose is to simplify how we build, interact with, and manage AI Agents.
I will refer again to the words of Harrison Chase (co-founder LangChain) to describe the role of LangGraph: "I think at the end of the day, what it all comes down to is communication. If there's some agent that's doing something, we need to communicate to it how we want it to behave."
If you're interested, you can watch the full interview with him here:
Sometimes, a simple prompt is enough to guide an AI, but code is a more powerful communicator. Code can be more precise, cost-effective, and provide better structure.
AI using code is way more powerful than AI just using language, aka prompt engineering.
This is exactly where LangGraph fits into the AI Agent landscape.
LangGraph aims to provide a straightforward way to define and orchestrate the behavior of AI Agents. It offers easy-to-use mechanisms for tasks such as:
- describing the flow of how an AI Agent should act
- building the toolbox an AI Agent needed to achieve its objectives
- helping the AI Agent manage different conversation threads
- human in the loop confirmations
- first-class support for streaming
- and much more
One of the best features of LangGraph is that it avoids hidden prompts, making everything cleaner and easier to manage.
And just like LangChain, LangGraph is available in two versions: JavaScript and Python.
To get started to LangChain you can checkout the official docs, or some of my previous articles:
📖 Build a full trivia game app with LangChain
Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js
📖 Build a full trivia game app with LangChain
Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js