Guest Lecture: Agentic AI Loops¶
Estimated time: ~30 min as delivered, ~40 min on your own with the backup slides
Sequence, selection, iteration. This is the guest lecture Tyson Swetnam gave in Fall 2026 to UNM's Ethical AI for Autonomous Systems course, part of the RAISE NSF Research Traineeship. It is a thirty-minute overview of agentic AI; the course instructors then lead a discussion of the ethical implications, including moral agency and accountability, so the lecture stays on the machinery and leaves those questions open for them. The class is deliberately mixed: computer, electrical, mechanical and civil engineers sit next to students of security policy and of organization, information and learning sciences. So the lecture needs no programming. It starts with what agentic AI is and how it differs from the statistical models and chatbots people already know, and then makes one argument: an AI agent is a loop, three old ideas from programming are still the right questions to ask of it, and what has changed is who decides what happens next.
It draws on this course (Modules 1, 2, 4 and 5), the GPT 101 workshop and Awesome Open Science. The talk itself is 21 slides. Another 19 backup slides follow in two groups, one going deeper for questions and for the engineers, one holding material the instructors may draw on for the discussion, and 39 numbered references close the deck.
Open the lecture full screen Download the slides (PDF)
Driving the slides
Click inside the slides first, then use Right and Left
(or Space) to move, Home and End to jump to either end, N
for the speaker notes and F for full screen. On a touch screen, swipe.
The menu in the toolbar jumps to any slide, every bracketed citation is a
link to its source, and each slide has its own address (for example
agentic-ai-loops.html#agent-loop), so you can link to one. The file is
self-contained: fonts and images are embedded and it makes no network
requests, so it also works offline.
Agentic AI in one sentence¶
Software that is given a goal, decides its own steps, and acts, using tools, until it judges the job done. The agents in the news fit it: coding agents that change files, run the tests and try again; assistants that click through websites and fill in forms on your behalf; research agents that read the sources, run the analysis and write the report.
Three kinds of AI¶
The instructors asked for this comparison, because most students know agentic AI only from the news. An agent is not a third kind of learning. It is a language model placed in a loop and handed tools, so that it acts.
| Predictive model | Language model | AI agent | |
|---|---|---|---|
| Also called | Regression, classifiers | LLMs, chatbots | A language model in a loop |
| How it works | Learns a pattern from examples with known answers | Learns the patterns of language from a vast amount of text | A language model placed in a loop and given tools |
| In and out | Measurements in, a number or a label out | A prompt in words in, text out | A goal in, actions out, then a report |
| Who acts on it | A person, or code someone wrote | The person reading it | The agent itself, step after step |
| On a robot or a vehicle | "Is that a pedestrian?" "How far will this battery go?" | "Explain this fault code." "Draft the inspection report." | "Move tomorrow's drone survey to a dry time slot." |
Each wraps the one before: an agent is a language model in a loop, and the tools it calls are often predictive models.
One bridge inspection, three kinds of AI¶
| Predictive model | Language model | AI agent | |
|---|---|---|---|
| You give it | A photo of the bridge deck | Your field notes | A goal: "Inspect the bridge and report" |
| You get back | "Crack: 92% likely" | A draft inspection report | A flight plan, photos, crack scores, a second pass over the blurry spots, then a draft report |
| It stops | After one answer | After one reply | When it judges the job done |
| When it is wrong | A wrong number that a person can check | A confident sentence that is false | A wrong action in the world, possibly repeated |
Three things are new with an agent: it acts, it takes many steps, and it decides for itself when to stop. The last row is the ethics row. This is an illustration, not a description of a product you can buy today.
Eight words for today¶
| Word | What it means |
|---|---|
| Model | The trained AI that writes text. On its own it can only talk. |
| Agent | A model placed in a loop so it can take steps toward a goal. |
| Tool | Anything the agent can use to act: search, email, a calendar, a robot arm. |
| Harness | The program around the agent. It owns the loop and the permissions. |
| Sandbox | A fenced-off place where an agent can work without touching the real world. |
| Hallucination | A confident answer that is wrong or made up. |
| Trace | The step-by-step record of what the agent thought and did. |
| Gate | A point where the agent must stop and ask a person. |
Three building blocks¶
The structured program theorem (Böhm and Jacopini, 1966) says three moves are enough to write any program. Dijkstra's case for using only those three was about people: a program built from them is one a person can follow by reading it. The ethical question for agents is whether a person can still follow what the machine will do.
Do this, then this, then this, in order. Like following a recipe.
In an agent: everything so far is kept in order, and the agent rereads all of it on every lap.
If this, do that; otherwise do something else. Like a traffic light.
In an agent: on each lap the AI picks one tool by reading its
description, or picks none. A human approval gate is itself a selection,
and somebody has to decide what goes after the if.
Who decides what happens next¶
This table is the thesis of the lecture.
| Building block | In ordinary software | In an AI agent |
|---|---|---|
| Sequence | A programmer wrote the steps, in order | The AI makes up the steps as it goes |
| Selection | A programmer wrote every if and else, and anyone can read and test them |
The AI chooses, by reading descriptions written in plain English |
| Iteration | A programmer wrote the rule for when to stop | The AI decides when it is done, unless a step limit cuts it off |
The three building blocks are still there. Their author is now an AI, deciding one step at a time, and that is where the questions about accountability, fairness and oversight come in.
The agent loop¶
Loops are everywhere: a thermostat, a robot vacuum's sense, plan, act, a pilot's observe, orient, decide, act, and quality management's plan, do, check, act. The agent loop is the newest member of an old family. What is new is that an AI does the planning step.
flowchart LR
P["1 Perceive<br/>read the goal and what<br/>has happened so far"] --> L["2 Plan<br/>decide the next step,<br/>or decide to stop"]
L --> A["3 Act<br/>use a tool<br/>to do it"]
A --> O["4 Observe<br/>read what<br/>came back"]
O --> D{"Done?"}
D -- "not done: loop again" --> P
D -- "done" --> C["5 Conclude<br/>report the answer"]
Module 1's foundational concepts define the four stages, and Module 2's foundational concepts show the runtime behind them, including the rule that stops the loop.
One request, three laps¶
You ask: "Move tomorrow's drone survey to a dry time slot, and tell the crew."
| Lap | The agent decides | Tool it uses | What comes back |
|---|---|---|---|
| 1 | "I need tomorrow's forecast." | Weather service | Rain from 9 to 11 am |
| 2 | "Find a dry slot when the crew is free." | Team calendar | 2 pm is open |
| 3 | "Move the booking and draft a note to the crew." | Calendar, email | Booking moved. Note drafted, waiting for your OK |
| Done | "Nothing left to do." | None | A short report to you |
Nobody wrote these steps in advance. The agent chose each one after seeing the last result, and it stopped to ask before doing something that could not be taken back. That pause is a gate, and somebody had to design it. This is an illustration, not a transcript of a real system.
Going further: three nested loops¶
This picture sits in the backup slides for the discussion. Each loop needs its own way to stop, and each outer loop must be able to stop the one inside it.
flowchart TB
subgraph G["Governance loop · months · the institution · NIST AI RMF 1.0"]
g0["Govern → Map → Measure → Manage → back to Govern"]
subgraph O["Oversight loop · minutes to days · the operator · EU AI Act Article 14"]
o0["Trace → Review → Approve or reject → Revise → back to Trace"]
subgraph A["Agent loop · seconds · the model and its harness"]
a0["Perceive → Plan → Act → Observe → back to Perceive"]
end
end
end
g0 -. "can stop" .-> o0
o0 -. "can stop" .-> a0
The July 2026 OpenAI and Hugging Face incident, covered in Part 3, is what it looks like when the inner loop runs for weeks and the outer two never fire. Who designs the gate between the loops, and who answers when it is skipped, are the questions the lecture hands to the instructors' discussion.
Lecture outline¶
Each link opens the slides at that point.
| Part | Slides | What it covers | In this course |
|---|---|---|---|
| Opening | 1-2 | The plan: a thirty-minute overview, then the instructors' discussion | How this course works |
| Part 1: What is agentic AI? | 3-7 | Agentic AI in one sentence; predictive models, language models and agents side by side; one bridge inspection done three ways; eight words for today | Module 1 |
| Part 2: Three building blocks | 8-14 | Sequence, selection and iteration; loops you already know; the agent loop and a worked example; who decides what happens next; five levels of autonomy | Module 1, Module 2 |
| Part 3: Loops of loops | 15-18 | Four ways agents coordinate, why multi-agent systems fail, the July 2026 incident | Module 4 |
| Close | 19-21 | Where to keep learning, compute at CARC, and the hand-off to the discussion | Module 5 activities |
| Backup: going deeper | 22-33 | The scale of the AI buildout, where agents meet RAISE's four research themes, the classic definition of an agent, how an agent picks a tool (MCP), reasoning paradigms as control structures, coding harnesses, hallucination as an engineering problem, AI sandboxes, four ways agents get attacked, the OWASP Top 10 for agentic applications, knowledge as a guardrail | Module 2, Module 5 |
| Backup: for the discussion | 34-40 | Five lessons from the incident, the human gate as an if statement, three nested loops, accountability, and two sets of discussion prompts; not presented, kept for the instructors | Module 5 |
| References | 41-43 | 39 sources, numbered in order of first citation |
Twelve slides carry a one-line "For the engineers" note in small type, so the main text stays plain and the technical students still get the detail.
Discussion prompts¶
In the Fall 2026 delivery the course instructors led the discussion after the lecture, so these two sets of prompts sit in the backup slides rather than in the talk. Use them with a class, a reading group, or on your own. They have no answer key: the point is the argument you make.
Discussion 1: Who decides what happens next
Pick a machine that acts on its own: a robot vacuum, a self-driving car, a delivery drone, a Mars rover. Work in pairs first, then bring it to the room.
- Where do its steps, its choices and its repeats come from today? Who wrote them?
- Which of the three would you hand to an AI first? Which one never?
- What makes it stop: a rule someone wrote, a limit, or a person?
For facilitators: mix the pairs if you can, an engineer with a policy or learning sciences student. Push on question 3. For most AI agents in use today the honest answer is that the AI decides when it is done, with a step limit as the backstop. Ask what the equivalent would be for their car, drone or rover.
Discussion 2: Design the gate
Pick one: a drone swarm, a self-driving shuttle, or a spacecraft too far away to steer in real time.
- Which actions cannot be undone, and who is allowed to approve them?
- What does that person need to see before saying yes?
- The machine acts faster than a person can review. What do you change?
- Who answers for it when the gate is skipped?
For facilitators: question 3 is the crux for space and defense autonomy. If the machine is faster or farther away than a person can follow, the gate has to move from the moment of action to the design stage: limits, safe envelopes and lists of pre-approved actions instead of approvals one at a time. Question 4 has no engineering answer, which is why the policy students should lead on it.
Reusing the lecture¶
The slides, this page and the PDF are licensed CC BY 4.0 like the rest of the course. The HTML file is a single self-contained document, so you can download it and present from it without a network connection. Some slides are reused from Tyson Swetnam's MESA talk at the NCEMS Annual Summit (August 2026); MESA is supported by the U.S. National Science Foundation under Award #2632685.
References¶
Numbered in order of first citation on the slides, in PLOS style. The last three slides carry the same list with the slide numbers that cite each entry.
- UNM Center for Advanced Research Computing. GPT 101: a workshop on generative AI and prompt engineering. 2026. CC BY 4.0. Available from: tyson-swetnam.github.io/intro-gpt
- James G, Witten D, Hastie T, Tibshirani R. An introduction to statistical learning: with applications in R. 2nd ed. New York: Springer; 2021. Available from: statlearning.com
- Brown TB, Mann B, Ryder N, Subbiah M, Kaplan J, Dhariwal P, et al. Language models are few-shot learners. Adv Neural Inf Process Syst. 2020;33:1877–1901. Available from: proceedings.neurips.cc
- Center for Advanced Research Computing, University of New Mexico. AI Automation and Agents [online course]. 2026. Developed at the Arizona Institute for Artificial Intelligence, University of Arizona. CC BY 4.0. Available from: tyson-swetnam.github.io/AI-Automation-and-Agents
- Swetnam TL. MESA: Multidisciplinary Environment for Scientific Advancement. NCEMS Annual Summit; 2026 Aug. Available from: idss-mesa.github.io
- Böhm C, Jacopini G. Flow diagrams, Turing machines and languages with only two formation rules. Commun ACM. 1966;9(5):366–371. doi:10.1145/355592.365646
- Dijkstra EW. Go to statement considered harmful. Commun ACM. 1968;11(3):147–148. doi:10.1145/362929.362947
- Boyd JR. The essence of winning and losing [unpublished briefing]. 1996. Available from: slightlyeastofnew.com
- Deming WE. Out of the crisis. Cambridge (MA): MIT Press; 1986. Available from: books.google.com
- Kephart JO, Chess DM. The vision of autonomic computing. Computer. 2003;36(1):41–50. doi:10.1109/MC.2003.1160055
- LangChain. Agents. LangChain documentation. Available from: docs.langchain.com/oss/python/langchain/agents
- SAE International. Taxonomy and definitions for terms related to driving automation systems for on-road motor vehicles. Standard J3016_202104. 2021. Available from: sae.org/standards/content/j3016_202104
- Stone P, Veloso M. Multiagent systems: a survey from a machine learning perspective. Auton Robots. 2000;8(3):345–383. doi:10.1023/A:1008942012299
- Cemri M, Pan MZ, Yang S, Agrawal LA, Chopra B, Tiwari R, et al. Why do multi-agent LLM systems fail? Adv Neural Inf Process Syst. 2025;38 (Datasets and Benchmarks Track). arXiv:2503.13657
- OpenAI. The Hugging Face incident and the road ahead. 2026 Aug 26. Available from: openai.com/index/hugging-face-incident-and-the-road-ahead
- Hugging Face. Anatomy of a frontier lab agent intrusion: a technical timeline. 2026 Jul 27. Available from: huggingface.co/blog/agent-intrusion-technical-timeline
- METR, Redwood Research. Brief independent investigation of agents’ behavior, reasoning and collaboration in the OpenAI / Hugging Face hacking incident. 2026 Aug 26. Available from: metr.org/blog
- Swetnam TL. Awesome Open Science. Available from: tyson-swetnam.github.io/awesome-open-science
- RAISE. Graduate Certificate on Ethical AI for Autonomous Systems. University of New Mexico. Available from: raise.unm.edu
- Wooldridge M, Jennings NR. Intelligent agents: theory and practice. Knowl Eng Rev. 1995;10(2):115–152. doi:10.1017/S0269888900008122
- Yao S, Zhao J, Yu D, Du N, Shafran I, Narasimhan K, et al. ReAct: synergizing reasoning and acting in language models. arXiv:2210.03629 [Preprint]. 2022.
- National Institute of Standards and Technology. Artificial Intelligence Risk Management Framework (AI RMF 1.0). NIST AI 100-1. 2023. doi:10.6028/NIST.AI.100-1
- European Parliament and Council. Regulation (EU) 2024/1689 laying down harmonised rules on artificial intelligence (Artificial Intelligence Act). Off J Eur Union. 2024 Jul 12. Available from: eur-lex.europa.eu/eli/reg/2024/1689/oj
- OWASP GenAI Security Project. OWASP Top 10 for Agentic Applications for 2026. Available from: genai.owasp.org
- UNM Center for Advanced Research Computing. CARC documentation: facilities description and general FAQ. Available from: carc.unm.edu/docs
- Federal Highway Administration. Highway statistics series. Washington: US Department of Transportation. Available from: fhwa.dot.gov/policyinformation/statistics.cfm
- Epoch AI. AI capital expenditure. Data insights. Available from: epoch.ai/data-insights/ai-capex
- NASA History Office. NASA history. Available from: nasa.gov/history
- Gartner. Gartner forecasts worldwide AI spending to grow 47 percent in 2026 [press release]. 2026 May 19. Available from: gartner.com/en/newsroom
- Moorhouse F. [Chart comparing AI data-center spending with historical megaprojects; post on X]. 2026. Available from: x.com/finmoorhouse/status/2044933442236776794
- RAISE: Responsive and Resilient AI for Autonomous Systems Engineering. Research. University of New Mexico. Available from: raise.unm.edu/research
- Model Context Protocol. Specification and documentation. Available from: modelcontextprotocol.io
- Wei J, Wang X, Schuurmans D, Bosma M, Ichter B, Xia F, et al. Chain-of-thought prompting elicits reasoning in large language models. Adv Neural Inf Process Syst. 2022;35:24824–24837. Available from: proceedings.neurips.cc
- Yao S, Yu D, Zhao J, Shafran I, Griffiths TL, Cao Y, et al. Tree of thoughts: deliberate problem solving with large language models. Adv Neural Inf Process Syst. 2023;36:11809–11822. Available from: proceedings.neurips.cc
- Zhou A, Yan K, Shlapentokh-Rothman M, Wang H, Wang YX. Language agent tree search unifies reasoning, acting, and planning in language models. arXiv:2310.04406 [Preprint]. 2023.
- Merchant A, Batzner S, Schoenholz SS, Aykol M, Cheon G, Cubuk ED. Scaling deep learning for materials discovery. Nature. 2023;624:80–85. doi:10.1038/s41586-023-06735-9
- Anthropic. Beyond permission prompts: making Claude Code more secure and autonomous. 2025 Oct 20. Available from: anthropic.com/engineering/claude-code-sandboxing
- Google Cloud. Open Knowledge Format (OKF) specification. Knowledge Catalog. Available from: github.com/GoogleCloudPlatform/knowledge-catalog
- Floridi L, Cowls J, Beltrametti M, Chatila R, Chazerand P, Dignum V, et al. AI4People—an ethical framework for a good AI society: opportunities, risks, principles, and recommendations. Minds Mach. 2018;28(4):689–707. doi:10.1007/s11023-018-9482-5
Machine-readable: this page as Markdown · raw source on GitHub · llms.txt · llms-full.txt (whole site). See For AI agents.