11 Building Tool-based Agents with LangGraph
This chapter covers
- Building LLM-powered agents using LangGraph
- Registering and using tools for dynamic agent execution
- Debugging agent execution and tool calls
- Simplifying agents with pre-built LangGraph components
- Observing agent execution with LangSmith
In chapter 5, you explored the distinction between agentic workflows and agents. You learned that agentic workflows are fundamentally deterministic: their logic is based on flows with conditional paths that depend on the current application state. These workflows can be elegantly modeled using node-based graphs in LangGraph, and you saw a complete, hands-on example of such a system.
Agents, however, operate differently. Rather than following a predetermined flow, agents rely on dynamic, context-sensitive decision-making. With the help of a language model (LLM), an agent chooses which tools to use—and in what order—based on the evolving context of the task at hand. These decisions aren’t pre-scripted; instead, they unfold step by step, as the agent continually evaluates the outputs of previous actions and adapts accordingly.
In this chapter, you’ll put these ideas into practice by building a multi-tool travel information agent. We’ll begin simply, implementing an agent that provides destination information using a single tool. From there, we’ll extend it into a true multi-tool agent, able to answer questions about both travel destinations and their current weather conditions.