Français

Slides — Session 6: The agentic loop

Program: Applied AI — Intermediate Level · Instructor: Yann Isola
Duration: 2 h · Module 4 — Part 1 · 28 slides
Palette: ink #1A2230 teal #0F7A6C copper #B4612A light teal #E9F6F3 background #F4F7F6

Slide 1 — Title

The agentic loop

From the chatbot that responds… to the agent that acts

Applied AI — Intermediate Level · Session 6 · Yann Isola

Slide 2 — Session 5 Reminder

What you already know

  • Tool calling: the model requests a tool call, your code executes it
  • The tool_use loop: query → block tool_use → execution → tool_result → the model continues
  • The principle of least privilege

Slide 3 — Session Objectives

  1. Distinguish between chatbot and agent
  2. Unwind the loop: perceive → reflect → act → observe
  3. Understand planning and working memory
  4. Install the essential safeguards
  5. Know when an agent is over-engineered

Slide 4 — The frustrating experience

“Book me a flight to Lisbon”

A classic chatbot responds:

“Here’s how to book a flight: 1. Go to a comparison site… 2. …”

He explains. He doesn't.

Slide 5 — Chatbot vs agent

Chatbot Officer
Operation One round: question → answer → stop A loop until the end of the task
Stop Mechanics, after the answer Decided by the agent when the objective is reached
Production From the text actions + text
Error False answer Failed action → possible catch-up

Slide 6 — The definition in one sentence

An agent = a language model in a loop, with tools, and the right to decide when it is finished.

Slide 7 — The analogy

  • Chatbot = consultant on the phone: it tells you what to do, then hangs up.
  • Agent = personal assistant: you entrust him with the mission; he makes calls, compares, reserves — and comes back to you when it's done (or to ask for your agreement).

Slide 8 — The agentic loop

The four-stroke cycle

PERCEIVE → THINK → ACT → OBSERVE → (start again)

…until the agent judges the objective to have been achieved ✅

Slide 9 — Time 1: PERCEIVE

Read the state of the world

  • The user's mission
  • History: what has already been done, found, failed
  • TripDesk, iteration 1: “Mission received. I don't know the flights or the schedule.”

Slide 10 — Time 2: THINK

Decide on the next action

  • Where am I in relation to the objective?
  • What am I missing? Which tool gets me closer?
  • TripDesk: “I need the flight list first → I'll call chercher_vols.”

Slide 11 — Time 3: ACT

The tools are the hands of the agent

{ "outil": "chercher_vols",
  "arguments": { "origine": "CDG", "destination": "LIS",
                  "semaine": "2026-07-14" } }

You already know this step: it's the tool calling from Session 5.

Slide 12 — Time 4: OBSERVE

Read the result — and loop back

  • Success? Data ? Error ?
  • The result joins the context → new perceive
  • TripDesk: “3 flights found. Now: check the calendar.” → the loop starts again

Slide 13 — Demo: TripDesk step by step

🖥️ Interactive viewer

5 iterations, from mission to confirmation —
with an agenda conflict, human validation and a breakdown along the way.

Slide 14 — Planning

Break it down before you act

Goal: Paris-Lisbon flight compatible with the calendar
Plan: 1. Search for flights    2. Check the calendar
      3. Pick the best one     4. User validation
      5. Book                  6. Confirm

Slide 15 — A plan is not a contract

The plan is revised along the way

  • Iteration 2: agenda conflict discovered → step 3 changes
  • Like a GPS (Global Positioning System) which recalculates the route

Slide 16 — Working memory

How does TripDesk remember the 3 flights?

  • Everything is in the conversation history (the scratchpad, notepad)
  • Reread in full at each iteration
  • Limited by the context window

Slide 17 — Ephemeral memory

⚠️ Notepad is cleared at the end of execution

  • New mission = working memory blank
  • Persistent memory (preferences, profiles) is a distinct mechanism, to be designed explicitly

Slide 18 — The other side of autonomy

“The agent decides when he is finished.” What if it never ends?

An agent without limits can:

  • 🔁 loop infinitely (and burn budget each turn)
  • 💸 undertake irreversible actions wrongly
  • 🧭 drift away from the mission

Slide 19 — The three canonical safeguards

Guardrail TripDesk Example
Max iterations 15 turns, otherwise stop + gear
Budget ceiling ⚠ p. ex. €0.50 API per mission (prices change)
Human-in-the-loop Mandatory validation before reserver_vol

Slide 20 — Error recovery

The 4-step pattern

  1. Tool fails: reserver_vol → “complete flight”
  2. The model reads the error (it happens in context, like any result)
  3. He adapts his strategy: there is no point in trying the same flight again
  4. He retries differently: the alternative, after new validation

Slide 21 — Your error messages are prompts

❌ "error 500" → the agent is blind

✅ "flight full — no seats left on AF1148; other flights remain available" → agent bounces

Slide 22 — Journal, always

Each iteration leaves a trace

  • What: summarized thought, tool called, arguments, result
  • Why: diagnose dead loops, audit actions, invoice

Slide 23 — The trap of over-engineering

Each iteration = one call to the model = cost + latency + risk

“Summarize this document” → a prompt is enough.
“What is the weather in Lisbon?” → one tool call is enough.
If a prompt is enough, an agent is a design fault.

Slide 24 — The decision tree

  1. Should we act or read living data? → No: prompt (± RAG, Retrieval-Augmented Generation, generation augmented by recovery)
  2. One tool call, known order? → Yes: tool calling simple
  3. Fixed stages, known in advance? → Yes: workflow
  4. The order depends on intermediate results? → Agent (+ safeguards!)

Slide 25 — And in YOUR profession?

To you: propose a task from your daily life

Prompt? Unique tool? Workflow? Agent ?

Slide 26 — Exercise in pairs

Exercise 1: unwind the loop by hand

SupportBot Agent: customer complaint → verify → refund (if justified) → prevent.
Table: perceive / reflect / act / observe, iteration by iteration.

Slide 27 — What to remember

  1. Agent = model + loop + tools + stopping decision by the model
  2. Perceive → think → act → observe, and we start again
  3. Revisable plan + ephemeral working memory (context)
    4.Minimal kit: max iterations, budget cap, human-in-the-loop
  4. The error read is information: adapt, try again differently
  5. The simplest weapon that accomplishes the mission — often it's not an agent

Slide 28 — The rest

Session 7

You know how to run an agent.
The rest of Module 4 awaits you — bring a real case from your profession: we will pass it to the decision tree.

📄 Take away: the interactive viewer (index.html, offline), the exercise sheet, the corrected quiz.

Notes: Home. Announce the promise of the session: "By the end, you will know exactly what an agent is, how it works, how to make it safe — and most importantly when NOT to use one."

Notes: 2 minutes max. Check question: "Who actually executes the tool call?" If the room hesitates, repeat the reminder. Session 5 is the hard prerequisite of this session.

Notes: Emphasize point 5: a session on agents which also teaches not to abuse them, that's what makes it credible.

Notes: Hook of Sequence A. Ask the room: “Why doesn't he do it?” Let the answers come: no access to the systems (→ tools, Session 5), and above all… it stops after ONE answer.

Notes: THE pivotal slide of the session. The “Stop” line is the conceptual distinction: control of “when it’s finished” passes from code to model. Have it written down word for word.

Notes: Central message of the session. You will repeat it at least three times. Clarify the common misunderstanding right away: it is NOT another, more intelligent model — often it is exactly the same model, in a different architecture. Agency is a property of the system.

Notes: The analogy holds throughout the session: the assistant has “hands” (tools), a plan, a notepad, and limits that you set for him (guardrails).Transition: “Let’s look at the engine of this wizard.”

Notes: Announce the plan for the following 4 slides: one time per slide, always illustrated by TripDesk, our travel reservation agent. Present TripDesk and its mission: “Paris–Lisbon flight week of the 14th, calendar compatible, book, confirm”. Its 4 tools: `chercher_vols`, `consulter_agenda`, `reserver_vol`, `envoyer_confirmation`.

Notes: Perceive = reread the entire context. In iteration 1, it's the mission alone; then it includes all accumulated tool results. Memory teaser (slide 16).

Notes: This is where the model's reasoning lives. Mention the term *reasoning* and, in one sentence, the “ReAct” motif (Reasoning + Acting) that some participants will come across in the literature — same cycle, different name.

Notes: Explicit link with Session 5: the tool call IS the “act”. Safety reminder: the model requests, your code executes. Without tools, the loop “thinks in a vacuum” — it can only speak.

Notes: Emphasize: observation only has value if it is *exploited* in the next turn. An agent that receives errors but does not take them into account is a dead loop (exercise 2 later). Transition: “Let’s see the loop turn in real life.”

Notes: Switch to `webpage/index.html` for ~15 min. Comment on EACH internal step (perceive/think/act/observe) out loud. Three things to note: the iteration/budget counters (guardrails), the growing notepad panel (memory), and the final stopping decision made by the agent. Then break for 10 minutes.

Notes: Resume after the break. The plan is produced by the model itself (often triggered by the system prompt: “make a plan before you act”). It's text in context — nothing magical, not a hidden feature of the Application Programming Interface (API).

Notes: Point of emphasis: an agentic plan is a working hypothesis. The strength of an agent is not having a good initial plan, it is revising it when observations contradict it. A rigid agent following an outdated plan = a disguised workflow that fails.

Notes: Question to the room before displaying: “Between iteration 1 and 4, where are the 3 flights stored?” Analogy: an investigator's notepad during a case. Practical consequence: an agent that loops 50 times with voluminous results saturates its window → summary/truncation techniques.

Notes: Frequent confusion about killing explicitly: no, the agent will not "remember" the previous mission by default. Nothing is written to the model weights during runtime. Teaser: persistent memory will be the subject of a later session.

Notes: Guardrail sequence. Link explicitly to the key distinction in slide 5: it is BECAUSE the agent decides his end that limits are necessary. The safeguards do not restrict the agent — they make their autonomy acceptable in production.

Notes: Please note as is: this is the minimum kit for any agent in production, not an option. Practical rule: any irreversible or costly action requires a human. Reading flights: autonomous. Pay for a ticket: validation. Direct extension of least privilege (Session 5).

Notes: Mentally replay iteration 4 of the demo.Anti-pattern to name: retry THE IDENTICAL in a loop — this is exactly what the max iterations guardrail stops. An agent who catches up is what most visibly distinguishes him from a simple script.

Notes: Direct echo of Session 5 (“tool descriptions are prompts”). The model only adapts its strategy based on what it READS. The robustness of an agent is conceived on the tools side as much as on the model side. This is bonus question 4 of exercise 2.

Notes: Short (2 min). Without a log, a derailed agent is a black box. With a log, exercise 2 becomes possible: we will read together the log of an agent who has gone into a tailspin. Transition to the critical thinking sequence.

Notes: Have the room vote by show of hands on 3–4 examples (summary, translation, weather, multi-constraint reservation). The contrast should be obvious. Agents are in fashion: your value as a professional is knowing how to say “no agent here”.

Notes: The tree is interactive on the webpage — show it briefly, participants will explore it at home. Formula to note: “Prompt < unique tool < fixed workflow < agent: always the simplest weapon that accomplishes the mission.”

Notes: 3–5 min. Take 2–3 cases proposed by participants and classify them together with the tree. This is often the richest moment of the session — real cases reveal the nuances (many “fake agents” are actually good workflows).

Notes: 10 min. Circulate between pairs. Error to watch out for: refund BEFORE checking the order. Trick question to ask quick pairs: “Where do you place human validation, and why not elsewhere?”

Notes: Reread the 6 points out loud, slowly. Then express oral quiz (quiz questions 1, 3, 5, 7, 10) and distribution of exit tickets.

Notes: Finish on time. Remember that the viewer works offline: they can replay TripDesk and the decision tree at home. Collect exit tickets at the exit — it's your thermometer for adjusting Session 7.