Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/LangChain Mastery/Part 8 · 7. Tools & Agents
Lesson 56 of 68

ReAct Agents

Reasoning + Acting. The loop that defined 2023.

Derpx0610 Jan · 1 min read
LangChain Mastery
Designing Tool SchemasFunction Calling in LangChainTool Selection & ValidationReAct AgentsPlan-and-Solve AgentsFallbacks & Error HandlingLangGraph: Stateful AgentsHuman-in-the-Loop
Contents
1. Beyond the Chain2. The ReAct Pattern3. The Execution Flow4. Pros and Cons5. Summary
0% read · 1 min leftBack to top ↑
Course outline & contents0%
LangChain Mastery
Designing Tool SchemasFunction Calling in LangChainTool Selection & ValidationReAct AgentsPlan-and-Solve AgentsFallbacks & Error HandlingLangGraph: Stateful AgentsHuman-in-the-Loop
Contents
1. Beyond the Chain2. The ReAct Pattern3. The Execution Flow4. Pros and Cons5. Summary

1. Beyond the Chain

A "Chain" is a straight line: A -> B -> C. But real life is not linear. If I ask "Who is the CEO of the company that made the iPhone?", you can't just fetch one URL. You need to:

  1. Search "Who made iPhone?" -> Apple.
  2. Search "CEO of Apple" -> Tim Cook.

This requires a Loop.

2. The ReAct Pattern

ReAct stands for Reasoning + Acting. It is a prompt structure that forces the model to "Think out loud" before it touches a tool.

The Prompt Format:

Text
Question: {input}
Thought: What do I need to do?
Action: {tool_name}
Action Input: {tool_args}
Observation: {tool_result}
... (Repeat) ...
Final Answer: {answer}

3. The Execution Flow

  1. Model: "Thought: I need to find the maker of iPhone. Action: Search('Who made iPhone')"
  2. System: Executes Search. Returns "Apple Inc."
  3. Model: "Observation: Apple Inc. Thought: Now I need CEO of Apple. Action: Search('CEO Apple')"
  4. System: Executes Search. Returns "Tim Cook."
  5. Model: "Observation: Tim Cook. I have the answer. Final Answer: Tim Cook."

4. Pros and Cons

  • Pros: Highly flexible. Can solve problems the developer never anticipated.
  • Cons: Verbose (uses lots of tokens). Can get stuck in "Thought Loops" (I need to search... I need to search...).

5. Summary

ReAct was the breakthrough that made Agents possible. It turns the "Black Box" of inference into a transparent "Step-by-Step" log.

Key Intuition: "Don't just do it. Think about it first."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonTool Selection & ValidationNext lesson →Plan-and-Solve Agents