Skip to content

References: How agent loops work

Source material:
• Stanford CME 295: Transformers & Large Language Models, Autumn 2025
Instructor: Afshine Amidi & Shervine Amidi, Stanford University
Course site: https://cme295.stanford.edu/syllabus/2025/
Cheatsheet: https://cme295.stanford.edu/cheatsheet/
Source lecture (Lecture 7, Agentic LLMs):
see the Autumn 2025 syllabus at https://cme295.stanford.edu/syllabus/2025/ for the lecture URL
License (lecture videos): as published on Stanford's public YouTube channel
License (Amidi cheatsheets): MIT
This lesson adapts the agent-loops section of Stanford CME 295 Lecture 7,
covering [01:31:58-01:38:24] the agent definition + ReAct + the worked
teddy-bear-temperature example, [01:38:24-01:42:00] multi-agent and the
Agent-to-Agent (A2A) protocol, [01:42:00-01:47:38] the safety threads
(data exfiltration, prompt injection, tool misuse) and the two classes of
remediation. Clawdemy provides original notes, summaries, and quizzes
derived from this material for educational purposes. All rights to the
original lectures remain with Stanford and the instructors.
  • "ReAct: Synergizing Reasoning and Acting in Language Models", Yao et al., 2022. The paper that introduced the observe-plan-act-style agent loop pattern (the paper itself uses think-observe-act). Section 2 (the prompting setup) is the conceptual core: interleave thinking and tool calls in a single prompt, with the model deciding when to think and when to act. The technique influenced essentially all production agent frameworks. Worth reading after this lesson; the actual prompting examples are short and concrete.
  • Agent-to-Agent (A2A) protocol. The protocol specification is the primary source if you want the actual standard. It is "an open source project under the Linux Foundation, contributed by Google" and reached version 1.0.0. The framing is the durable part: an agent publishes an Agent Card describing its skills, and a task moves through a defined set of states the caller can poll or stream.

  • Compute-budget management for agents. When an agent might run many iterations, the cumulative cost can balloon. Search terms: "agent budget capping," "iteration limits in agentic workflows," "cost-aware planning in LLM agents." Useful for understanding the practical engineering side of running agents at scale.

  • The reliability-vs-capability tradeoff for long-horizon agents. Search terms: "horizon length in LLM agents," "compounding error in agentic workflows." The cumulative-error framing in this lesson is one piece of a larger empirical literature on why long-horizon agents are still mostly research.

A short list of papers and posts on adjacent agent patterns.

  • Stanford CME 295 cheatsheet by the Amidi twins. MIT-licensed. The agent and safety section covers the same material in their dense visual style. Worth using as a study reference after this lesson.

None selected for this lesson. Vendor reports (Anthropic) and academic sources are the better entry points right now. Durable community references will be added at a future quarterly review if any consolidate.