Week 4 · Module 1 · Foundations

 Reasoning, planning & the agent loop .

 Week 3 was about one great prompt. This week the model gets to send many prompts — a loop where it sees a result, thinks, and chooses its own next step. The loop is the part of an agent that you own: you can read it, budget it, audit it, and stop it.

 📌 This week's logistics: Group Assignment 1 is due on iCollege — the two sections’ deadlines are a day apart, so check iCollege for your section’s due date ( enrollment & submission details ). The final-project proposal is released on iCollege this week. And the Agent Radar presenter slot for next week is open — sign up.

 The big question

 Discussion question In Week 2 you watched Codex loop: observe → decide → act, over and over. Who decides that the loop should run one more time — and who decides that it should stop?

 See the answer 
 The model proposes ("I'm not done — the tests still fail"), but the harness disposes: the loop code you write decides whether to grant another iteration, checking the stop condition, the step cap, and the budget. An agent that "knows when to stop" is really a loop that checks. This week you build that loop yourself — first on paper, then in LangGraph.

 Why one prompt is not enough

 One shot vs the loop

 One-shot prompt 
 Q: Which is taller — the tallest building
in Atlanta, or twice the height of the
Statue of Liberty?

Model: (from memory, no checking)
"Twice the Statue of Liberty is taller." ✗

 No tools, no verification, no recovery. If the memory is wrong, the answer is wrong — and nobody notices.

 The loop 
 Thought: I need both heights. Search first.
Action: Search("tallest building Atlanta")
Observation: Bank of America Plaza — 312 m
Thought: Now the statue, then compare.
Action: Search → 93 m · Calculator → 186 m
Thought: 312 > 186. Done.
Answer: the Atlanta building — by 126 m. ✓

 Each observation is fed back before the next decision. Wrong turns become visible — and recoverable.

 The trade: every extra loop step is another model call — more latency, more tokens, more money. This week is about buying reliability with steps, and knowing when you're overpaying.

 This week's pages

 Work through in order

 01 
 The agent loop Reactive vs goal-oriented · the Observe → Reason → Act cycle · step through a real ReAct episode · where the human gate goes. 
 → 

 02 
 Reasoning patterns ReAct · plan-then-execute · reflection · Tree of Thoughts — what each buys, what each costs, and how to choose (with the papers). 
 → 

 03 
 LangGraph — the loop you own State, nodes, edges · the canonical agent graph, clickable · build a minimal agent on the Gemini free tier · the max-iteration guard. 
 → 

 04 
 Practice & case Annotate a real trace · draw the state graph · the itinerary case (greedy vs plan-and-check) · interview check · readings. 
 → 

 Why managers care

 The loop is the auditable part

 Auditability An explicit loop logs every thought, tool call, and state change. When compliance asks "why did the system do that?", you replay the trace.

 Cost control Steps are the unit of spend. A step cap and a token budget turn "AI costs" from a surprise into a line item.

 Reliability Feeding observations back is what lets an agent notice failure and recover — the difference between confident nonsense and a checked answer.