AI security: secure and test LLM apps and agents

Stage 2 · Lesson 1 of 7

How a request becomes a context window

How LLM apps and agents work, and where they break

When a user sends a message, the app builds the text the model will read: the (the developer's instructions), earlier conversation, retrieved documents, tool descriptions and tool results, then the user's message. This bundle is the context window.

The model reads all of it and produces the next . Ordinary code then takes the answer and shows it, stores it or acts on it. Security work starts by drawing this assembly for a real app: every source that adds text to the context is a way in, and every place the answer goes is a way out. Notice how many sources the user never sees, such as a web page fetched by a tool.

Common trapthinking the chat box is the only input, when emails, files and web pages the app reads on its own are often the bigger risk.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking Prompt Engineering for Software Engineers

    Design Gurus · Beginner · Subscription

    How system prompts, context and structured output really work, the ground every LLM risk stands on

  • CourseFree
    Hugging Face Learn

    Hugging Face · Intermediate

    Free courses on how language models, embeddings and agents work, at an engineer's level

Practise

  • Run a small model locally as the heart of the practice app you will defend and test

  • Build your practice app's two tools as a tiny MCP server, so later stages have something real to secure

Keep handy

Also worth your time

Mark this stage as not done?