In Session 5, we’ll cover building agents with LangGraph! Here’s the big idea:
🕴️ **Agents** with access to **Tools** can solve **Problems**.Agent applications have grown in popularity in 2024 and show no signs of stopping. During our initial foray into agents, we’ll focus on some high-level ideas that are essential to understanding agents, including the ReAct framework and function calling!
To best prepare for today’s session, we want to understand that LangGraph is a natural extension of LangChain. The key to making this connection is the concept of a Runnable Interface in LangChain.
-
Just as last time, ensure that you’ve got a LangSmith account 👇
-
To complete our agent build of the day, set up your Tavily API Key!
-
Read How to think about agent frameworks from Harrison Chase, CEO and Creator of LangChain (April, 2025)
-
Read Context Engineering (for agents) by LangChain (July, 2025)
The term “agent” is often quite confusing. Agency? Virtual assistant? The key to complexity? Just tool calling? What does it mean for something to be “agentic?”
"[Agents] might be neurons ... neurons [form] brains ... At each level, new emergent structures [form] and engage in new emergent behaviors. Complexity [is] a science of emergence.” ~ M. Mitchel Waldrop, Complexity
“Very simple rules, instead of producing fairly simple behavior, actually produce extremely complicated behavior” ~ Stephen Wolfram via Lex Fridman’s podcast
While the level of complexity of what we consider an AI agent is bound to increase with time, you must understand a few things if you’re looking to build, ship, and share agentic applications today.
- Agent == Agentic; this is not a useful distinction to quibble about.
- Agents are a pattern, not a thing. The Reasoning-Action pattern.
- Agents leverage tools through function calling. Most tools are aimed at improving search and retrieval.
- Better retrieval = better RAG. Therefore, agents often leverage the RAG pattern.
Here is our current, working definition, of the word “Agent” in the context of building production LLM applications.
📖Agent: A system that can leverage (or emulate) reasoning (or equivalent processes) to make dynamic decisions in an application flow
The Reasoning Action pattern looks new but describes logic as old as AI.
- Reason: If (something happens)
- Action: Then do (something else)
The ReAct paper was built specifically by combining two ideas:
While large language models (LLMs) have demonstrated impressive performance across tasks in language understanding and interactive decision making, their abilities for reasoning (e.g. chain-of-thought prompting) and acting (e.g. action plan generation) have primarily been studied as separate topics. ~ Cao, et al.
The idea is simple but wide-ranging:
reasoning traces help the model induce, track and update action plans as well as handle exceptions, which actions allow it to interface with and gather additional information from external sources such as knowledge bases or environments.
It’s worth reviewing the primary figure from the paper in detail, as well as other use cases:
Figure 1: (1) Comparison of 4 prompting methods, (a) Standard, (b) Chain-of-thought (CoT, Reason Only), (c) Act-only, and (d) ReAct (Reason+Act), solving a HotpotQA (Yang et al., 2018) question. (2) Comparison of (a) Act-only and (b) ReAct prompting to solve an AlfWorld (Shridhar et al., 2020b) game. In both domains, we omit in-context examples in the prompt, and only show task solving trajectories generated by the model (Act, Thought) and the environment (Obs).
Note the line from the last section: “gather additional information from external sources such as knowledge bases or environments.”
Gathering additional information, especially information that is current, is often the job that’s left to tool calling, also known as function calling.
OpenAI was the first to release function calling in July 2023, but since then it’s gained much steam and there are even function-calling leaderboards now that rates function-calling against benchmarks.
Simply put, LLMs are fine-tuned for function calling. That is, their output schema is constrained to output code capable of calling another API, or function. This, in effect, makes connecting GPTs to external tools and APIs much easier and more reliable.
It should be noted that the beginning of function calling was simple prompting; that is, engineers telling the LLM always output answers in JSON format
. Over time, few-shot learning became fine-tuning, as it tends to as we move down the task-specific spectrum. These days, we can simply set the response_format
to { "type": "json_object" }
directly when using OpenAI (and other function-calling) tooling.
- 📜 The Reasoning Action Paper
- 📜 The Chain-of-Thought Paper
- ⚗️ The MRKL (”miracle”) paper did a lot of heavy lifting in terms of the way we think about agents today. It’s worth a read for sure.