The ReAct (Reason & Action) framework was introduced in the paper Yao et al., 2022. It is one of the widely used prompting strategies in Generative AI applications. For more details on the ReAct framework, please refer here.

In this blog, we will delve into the implementation of the ReAct framework within Langchain and provide a detailed, step-by-step guide on the functioning of a simple agent. Additionally, there will be a bonus section detailing how to utilize LangSmith for a thorough step-by-step analysis of an agent's execution and how to use Langchain to align agents behavior.
The "Magic Sauce" in the ReAct framework is the prompt that encourages the LLM model to use the below though process: Question, Action, Action Input, and Observation.
Answer the following questions as best you can. You have access
to the following tools:
{tools}
Use the following format:
Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!
Question: {input}
Thought:{agent_scratchpad}
<aside> š” There are three placeholders {tool}, {input}, and {agent_scratchpad} in this prompt. These will be replaced with the appropriate text before sending it to LLM.
</aside>
tool - tools available to the agent
input - Original question to the LLM (Typically a question from an User)
agent_scratchpad - Holds the history of previous Thoughts/Actions/Action Inputs/Observations (It will makes sense when you see the example below)
LLMs are stateless machines. They do not remember past conversations. Therefore, agent_scratchpad would be used to inject the past conversation, which contains the path (though process) the agent has taken so far.

How can we perform complex task in our AI applications which requires multiple steps, potentially using the external tools? One answer is Langchain Agents & Agent Executors