To Data & Beyond

To Data & Beyond

Share this post

To Data & Beyond
To Data & Beyond
Building LLM Agents with LangGraph #2: Building Simple ReAct Agent from Scratch

Building LLM Agents with LangGraph #2: Building Simple ReAct Agent from Scratch

Step-by-Step Guide to Building LLM Agents with LangGraph

Youssef Hosni's avatar
Youssef Hosni
Jan 21, 2025
∙ Paid
7

Share this post

To Data & Beyond
To Data & Beyond
Building LLM Agents with LangGraph #2: Building Simple ReAct Agent from Scratch
1
Share

Get 60% off for 1 year

In the second article of the Building LLM Agents with LangGraph Series we will build a simple ReAct (Reasoning and Action) Agent from scratch in Python.

This article starts with a brief introduction to ReAct agents and their main components and how they work. Then we will define a simple agent class and define the system prompt and the helper functions.

Finally, we will test the agent with some examples and then we will automate the agent calling with a simple Python script.

This article is the Second Article in the ongoing series of Building LLM Agents with LangGraph:

  • Introduction to Agents & LangGraph (Published!)

  • Building Simple ReAct Agent from Scratch (You are here!)

  • Main Building Units of LangGraph (Coming Soon!)

  • Agentic Search Tools in LangGraph (Coming Soon!)

  • Persistence and Streaming in LangGraph (Coming Soon!)

  • Human in the Loop in LLM Agents (Coming Soon!)

  • Putting it All Together! Building Essay Writer Agent (Coming Soon!)

This series is designed to take readers from foundational knowledge to advanced practices in building LLM agents with LangGraph.

Each article delves into essential components, such as constructing simple ReAct agents from scratch, leveraging LangGraph’s building units, utilizing agentic search tools, implementing persistence and streaming capabilities, integrating human-in-the-loop interactions, and culminating in the creation of a fully functional essay-writing agent.

By the end of this series, you will have a comprehensive understanding of LangGraph, practical skills to design and deploy LLM agents, and the confidence to build customized AI-driven workflows tailored to diverse applications.


Table of Contents:

  1. Introduction to ReAct Agents

  2. Build ReAct Agent

  3. Test Agent with Different Examples

  4. Automate the Agent Call


My New E-Book: Efficient Python for Data Scientists

Youssef Hosni
·
Jan 7
My New E-Book: Efficient Python for Data Scientists

I am happy to announce publishing my new E-book Efficient Python for Data Scientists. Efficient Python for Data Scientists is your practical companion to mastering the art of writing clean, optimized, and high-performing Python code for data science. In this book, you'll explore actionable insights and strategies to transform your Python workflows, streamline data analysis, and maximize the potential of libraries like Pandas.

Read full story

1. Introduction to ReAct Agents

The ReACT (Reasoning and Action) agent model is a framework designed to integrate the reasoning capabilities of large language models (LLMs) with the ability to take actionable steps, creating a more sophisticated system that can understand and process information, evaluate situations, take appropriate actions, communicate responses, and track ongoing situations.

It was first introduced in the paper “ReAct: Synergizing Reasoning and Acting in Language Models” in October 2022, and revised in March 2023. The framework was developed to synergize reasoning and action-taking in language models, making them more capable, versatile, and interpretable.

ReAct enables agents to alternate between generating thoughts and task-specific actions dynamically by interleaving reasoning and acting.

The LLM follows a step-by-step problem-solving approach, utilizing various tools or APIs to gather information and perform tasks. ReAct is adaptable to different domains and provides transparency in decision-making, allowing human oversight.

Initially, ReACT showed improved performance over other prompting techniques, particularly in complex, multi-step tasks, but was largely superseded in late 2023 by native function calling techniques supported by OpenAI, Anthropic, Mistral, and Google models. We recommend using function or tool calls instead of ReACT for most production-ready features.

The model uses a specific prompt structure to guide reasoning and action generation and has been implemented in various AI frameworks like LlamaIndex and LangChain, making it accessible for developers to create more capable, reasoning-driven AI applications.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Youssef Hosni
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share