Defending AI Agents
עברית Join waitlist
Menu

Module 00 · Lesson 01

An agent is a model with side effects

Strip away the frameworks and an agent is a loop:

flowchart TD
  S["system prompt<br/>(the developer)"] --> H
  U["user task<br/>(the user)"] --> H
  H["prompt + history"] --> M["model"]
  M --> C["tool call<br/>(name, arguments)"]
  C --> T["tool"]
  T --> W["the world:<br/>files, mail, money, code"]
  T --> R["result"]
  R --> H

The model reads text and emits either an answer or a tool call: a name and some arguments, usually JSON.

{"name": "send_email",
 "arguments": {"to": "partner@example.com", "subject": "Q3 summary", "body": "..."}}

Something outside the model executes it, appends the result to the history, and calls the model again. The loop ends when the model answers instead of calling a tool, or when a step limit runs out. Module 1 gives you this loop in 88 lines, and you read every one of them.

Where an attacker can write

Count the arrows that carry text into the model:

Input Who writes it Trusted?
System prompt The developer Yes
User task The user Usually: the user is the principal, the party the agent acts for and whose authority it uses
Tool results Whoever wrote the file, e-mail, web page, ticket or API response No
Tool descriptions Whoever publishes the tool Only as far as you trust the publisher
Memory, retrieved documents Whoever wrote them, possibly weeks ago Depends on provenance

The model sees all of it as one stream of tokens. It has no reliable way to tell an instruction from its principal apart from an instruction that arrived inside an e-mail it was asked to summarise. That is the whole of prompt injection in one sentence. Module 4 adds the details.

The boundary is the tool call

A model's output does harm when something acts on it. In an agent, what acts on it is almost always a tool call: before that, the output is text. So the main place to enforce security is outside the model, at the tool call, where the action is structured, inspectable and stoppable, and in how the system is built, which decides what tool calls are possible at all.

"Almost always" matters. The other thing that acts on model output is whatever renders it. If the answer contains an image or a link and the user's client fetches it automatically, that fetch is an outbound request, made by the client, that no tool-call gateway sees. Lesson 2's public case, EchoLeak, sent its data out that way. The control for it is the same idea moved to the screen: strip or allow-list the addresses in model output before anything fetches them. This course builds the tool-call side; keep the rendering side on your list of doors.

"Train the model to refuse" helps, and the providers do it. It is not a boundary, for the same reason a classifier's training objective is not a guarantee about its worst input. The attacker chooses the input after seeing the defence: the attacker moves second.

Check yourself

  1. A support agent reads tickets and can issue refunds up to €50. List every party who can put text in front of its model.
  2. Why is the tool description in the table at all? Who could change it, and when?
  3. Name one thing a tool-call boundary cannot see that the model can.
Answers
  1. The developer, through the system prompt; the user who assigns the task; every customer or stranger who can open a ticket, with its attachments and quoted e-mails; whoever publishes the tools, refunds tool included, through their descriptions; and whoever wrote the knowledge base, memory or earlier tickets it retrieves. The €50 limit bounds what it does, not who writes to it.
  2. Because a tool's description is text in front of the model, and the model reads it as it reads any other. The publisher can change it whenever they update the tool, including after you reviewed and installed it, and every later session reads the new text with nothing to show it changed.
  3. Where the call came from. The boundary sees a name and arguments; the model saw the whole context, including the e-mail sentence that prompted the call, so the boundary cannot tell a send the user asked for from one an injected instruction asked for when the two look the same.