Week 04 — ReAct: Reasoning and Acting

Material Where
HTML chapter The Agent Loop and ReAct
Lab Open in Colab · Download notebook
Homework Open in Colab · Download notebook
Local Jupyter Lab ZIP · Homework ZIP · Provided helper
Paper ReAct (Yao et al., ICLR 2023)
Student presentation slides ReAct

All chapters: reading index

This week

The HTML chapter explains the agent loop and ReAct through one complete search example, showing how each observation informs the next action or final answer. A short pseudocode example and lab overview connect the concepts to practice; SQL, API code, and execution instructions are in the notebook.

In the lab, execute and inspect one model–tool exchange, repeat it in a loop, then add ReAct to the same shop-data question. Use the notebook to follow the code, inspect each observation, and check the final answer against the data.

Run in Colab

Click Open in Colab, choose File → Save a copy in Drive, and run the installation and setup cells. The notebook downloads its helper automatically; no file upload or local installation is needed. Enter your OpenAI API key in the hidden input when prompted. See API Setup if you need a key. Both notebooks use GPT-4.1 and the same synthetic shop.

The original lab takes about 80 minutes. Section 6 adds about 20 minutes of joint investigation: compare February and March by category, then inspect product changes, including products with zero sales.

Homework

Follow the Evidence in a Sales Investigation — about 60–75 minutes. Apply the lab to January and February 2025:

  1. Complete the loop’s tool execution, message saving, and stopping block.
  2. Compare completed sales by category, choose the category with the largest increase, and investigate its products in a fresh conversation.
  3. Record the monthly amounts and changes. Explain one Observation → next decision transition, why you selected the category, and what the records cannot establish about causes.

The notebook’s final check verifies format only: required fields, types, and saved record structure. A PASS or HOMEWORK COMPLETE message does not certify correct answers. Correctness and explanations are assessed after submission by the instructor.

Run the completed notebook top to bottom, keep the outputs, and run the format check last. Choose File → Download → Download .ipynb and upload that file to the LMS. Due date: see the LMS.