Learn How to Build Tool-Calling Agents with LangGraph
It’s 2025 and agents are right under our fingertips, but there’s a problem…
The problem—at least when it comes to building agentic systems—is that frameworks for building them, like LangGraph (an evolution of LangChain but designed specifically for building agents), are difficult to learn.
In this video I’ll show you how it works, and how you can use it to build very powerful agents (which—in this case—do very important science 🧪)
Check out the video on YouTube
AI Engineer Roadmap Launch 🚀
The AI Engineer Roadmap is live! You can sign up and start tracking your progress on https://zazencodes.com/
I’ve got a discount code that’s valid during launch month—use ZAZEN33 to get 33% off (ends March 31st 2025)
Topics from this week’s video
Tool Demonstration
Code available on GitHub
Running the agent via Python:
Chose "Neutron stars" as the topic
Archive API fetches related papers
Selects a paper and downloads the PDF
Extracts and summarizes the paper using LLM
Suggests future research directions
Drafts a research paper
Renders the draft into a LaTeX PDF
Provides download link for the generated PDF
Code Overview (Workflow 1)
Uses OpenAI model but can switch to Claude
Creation of a React agent (Reason + Act)
Tools are provided to the agent
Uses an infinite loop with
graph.stream
for continuous interactionInitial prompt guides the agent behavior
Switch to Workflow 2 (Lower-Level LangGraph Implementation)
Key components:
State management with message history
Definition of tools and tool nodes
Switching models (demonstrated with Anthropic Sonnet)
Binding tools to models via prompt augmentation
Local Model Demo with Ollama
Switched to running a local Llama3 Grok model
Successfully made tool calls locally
Demonstrated GPU usage
Limitations with model context windows and performance
Deep Dive into Tool Usage in LangGraph
How tools are defined using decorators (example:
getWeather
)Use of
Literal
fromtyping
to constrain tool argumentsBinding tools to models to include them in prompt context
Prompt augmentation explains tool capabilities to the LLM
Tools included:
Archive Search (fetches research papers)
Read PDF (extracts PDF contents)
Render LaTeX PDF (creates a PDF from LaTeX content)
Closing Thoughts
Importance of responsible use of APIs (e.g., Archive API)
Results are for demonstration, not actual scientific research
The complexity of LangGraph and agent systems
For the physicist or engineer, two systems that obey the same equations have a kind of identity-or at least an analogy. And that, after all, is all our word analog means. A digital watch is nothing like the sun; an analog watch is the memory of a shadow's circuit around a dial.
Jimmy Soni and Rob Goodman, A Mind at Play