References: How agent loops work
Source material
Section titled “Source material”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): MITThis lesson adapts the agent-loops section of Stanford CME 295 Lecture 7,covering [01:31:58-01:38:24] the agent definition + ReAct + the workedteddy-bear-temperature example, [01:38:24-01:42:00] multi-agent and theAgent-to-Agent (A2A) protocol, [01:42:00-01:47:38] the safety threads(data exfiltration, prompt injection, tool misuse) and the two classes ofremediation. Clawdemy provides original notes, summaries, and quizzesderived from this material for educational purposes. All rights to theoriginal lectures remain with Stanford and the instructors.Foundational paper
Section titled “Foundational paper”- "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 safety literature
Section titled “Agent safety literature”-
"ToolSword: Unveiling Safety Issues of Large Language Models in Tool Learning Across Three Stages", Ye et al., 2024 (the "tool sword" paper the lecturer cited). Studies safety risks for tool-using models at the input, execution, and output stages, including malicious queries, jailbreak attacks, and noisy tool results. Worth reading for a broader view of the threats this lesson summarized.
-
"Agent-SafetyBench: Evaluating the Safety of LLM Agents", Zhang et al., 2024. Introduces a benchmark for evaluating the safety of LLM agents in interactive environments that involve tool use. Useful if you want to see how the field is starting to formally measure agent-safety claims.
-
Anthropic's report on the late-2025 cyber attack launched from Claude. The lecturer's reference. A real-world example of how tool-and-agent capabilities can be misused at scale, plus a step-by-step walkthrough of the defenses. Worth reading even at a non-technical level for the framing of how this problem looks in production.
Adjacent topics
Section titled “Adjacent topics”-
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.
Going deeper
Section titled “Going deeper”A short list of papers and posts on adjacent agent patterns.
-
"Reflexion: Language Agents with Verbal Reinforcement Learning", Shinn et al., 2023. An agent pattern where the model self-critiques after each iteration and uses that critique to improve subsequent iterations. Useful for understanding one approach to mitigating cumulative error.
-
"Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning by Large Language Models", Wang et al., 2023. A paper behind the plan-first pattern: produce a full plan up front, then execute step-by-step. Different shape from observe-plan-act-each-iteration; tradeoffs are mostly about predictability vs adaptability.
-
"Constitutional AI", Bai et al., 2022. Anthropic's approach to training-stage safety, originally for chat models but with implications for agents. Worth reading after this lesson for one example of how training-stage remediation gets implemented in practice.
Stanford CME 295 cheatsheet
Section titled “Stanford CME 295 cheatsheet”- 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.
Community discussion
Section titled “Community discussion”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.