Reasoning + Acting
Lecture Notes
# The ReAct Framework The **ReAct (Reasoning + Acting)** framework is the most popular mental model for agents. It forces the LLM to output its internal thought process before taking an action. ## The ReAct Loop 1. **Thought**: The agent analyzes the current situation. 2. **Action**: The agent selects a tool and provides the arguments. 3. **Observation**: The system executes the tool and returns the raw output to the agent. 4. *(Repeat until the objective is completed)* ### Example ReAct Trace ```text User: How many days until the next US Presidential Election from today? Thought 1: I need to know today's date, and the date of the next US Presidential Election. I will use the get_current_date tool. Action 1: get_current_date() Observation 1: 2026-06-14 Thought 2: Now I need to find the exact date of the next US Presidential Election. I will use the search_web tool. Action 2: search_web("date of next US Presidential Election") Observation 2: The next US Presidential Election will be held on November 7, 2028. Thought 3: Now I need to calculate the difference in days between June 14, 2026, and November 7, 2028. I will use the run_python_math tool. Action 3: run_python_math("from datetime import date; print((date(2028, 11, 7) - date(2026, 6, 14)).days)") Observation 3: 877 Thought 4: I have the answer. I will now synthesize the final response to the user. Final Answer: There are exactly 877 days until the next US Presidential election on November 7, 2028! ```