Cover of Securing LLM Applications and Agents, edition 2026.11.3, code T64T-4BT9 Securing LLM Applications and Agents T64T-4BT9 3 editions since Nov 2026 Rolling Edition 2026.11.3

Securing LLM Applications and Agents

Edition 2026.11.3 Examples passed Nov 22, 2026 60 of 60 examples pass What changed

Written with AI. Verified by people. How we make books

This book is open to contributions, so anyone can check it or correct it. Its repository · Report an error · How to fix one

How an assistant with tools and data is turned against its users, and which defences measurably stop it: prompt injection, exfiltration, tool misuse and third-party code, on a property office's assistant.

Who it's for An engineer who has shipped, or is about to ship, an assistant or agent that reads text other people wrote and acts on it, and who writes Python.

Start reading

Labs

Work through this book in the Lab

Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Opens in about 30 seconds.

Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Labs runs it for you: 40 hours a month.

Checking for your Lab…

On your own machine, free: download the book's notebooks, with its code and data, from GitHub.

Edition history3 editions since November 2026Every edition and what it changed
2026.11.12026.11.3
2026.11.3 · Nov 25, 2026Library updateNo text changed, 11 examples on new versions

Contents

12 chapters, about 3 hours 43 minutes to read or 4 hours 27 minutes to listen to, with 60 examples.

  1. 1Attack an assistant, then measure a fix

    By the end of this chapter you can attack an assistant with a fixed set of cases, score each run in code, and say with an interval how much one defence changed the result and what it cost in the tasks the assistant still finished.

  2. 2Draw the assistant's threat model

    By the end of this chapter you can draw an assistant's threat model: its assets, the places where text from outside enters it, the flows that carry that text to the model and its tools, and the channels an attacker would use to get data out.

  3. 3Build an attack set you can score in code

    By the end of this chapter you can build a fixed set of attacks on an assistant.

  4. 4Measure what prompt-level defences buy

    By the end of this chapter you can measure what a prompt-level defence does to an assistant's attack success and to its utility, count the tokens it adds to each prompt, and read a held-out result without tuning on it.

  5. 5Detect injected text, and count the false alarms

    By the end of this chapter you can run a classifier on the office's texts, pick its threshold on dev only, count its false alarms on held-out and on two public corpora, and say which of those counts holds for which kind of text.

  6. 6Enforce least privilege outside the model

    By the end of this chapter you can restrict an assistant's tools and arguments in code, so that an injected instruction has less to reach, and you can measure each restriction on a fixed set of attack cases and say what it cost the assistant's ordinary tasks.

  7. 7Close the exfiltration channels

    By the end of this chapter you can keep an assistant's outbound calls and its reply from carrying a tenant's record to a host the office does not run.

  8. 8Keep untrusted data out of the plan

    By the end of this chapter you can build three designs that keep untrusted text away from the model that holds the tools, run each one on the case's attack set and benign tasks, and say what each buys and what each costs, with an interval on both.

  9. 9Keep secrets and other people's records out of the context

    By the end of this chapter you can keep an assistant's secrets out of its prompt, filter the documents it searches by the role of the person it works for, and check its replies for a deposit figure stated without a citation to an office document.

  10. 10Check what third parties hand the assistant

    By the end of this chapter you can check the parts of an assistant that other people wrote: the tools a server offers, the files of the model the assistant loads, and the packages its code installs.

  11. 11Red-team the assistant with an adaptive attacker

    By the end of this chapter you can run an attacker that revises its injection after each try, against a defence, under a fixed budget.

  12. 12Keep the defences from regressing

    By the end of this chapter you can run the defended assistant's attack set as a gate that fails a change which weakens a defence.

Cite this section

Format

Every format names this edition. Its link opens the current edition, where a section’s heading says when its text last changed. Accessed and retrieved dates are the day you open this.