---
title: "Spotlighting pattern for AI agents | Agentic Pattern Language"
description: "Mark untrusted text inside the prompt so the model can tell it apart from your instructions. Sourced from Hines et al., Nasr et al., and Microsoft."
url: https://agenticpatternlanguage.com/patterns/spotlighting/
---

36 [One call](https://agenticpatternlanguage.com/#one-call)

# Spotlighting

Mark untrusted text inside the prompt so the model can tell it apart from your instructions.

SW Hines et al., Nasr et al., Microsoft, Anthropic, Simon Willison

[How to read this](https://agenticpatternlanguage.com/notation/)

## Part of

* [Guardrails](https://agenticpatternlanguage.com/patterns/guardrails/)

## Alternatives

* [Dual LLM](https://agenticpatternlanguage.com/patterns/dual-llm/)

## The problem

A model cannot tell your instructions from instructions hidden in the text it is asked to read.

> The prompt injection problem stems from the LLM’s inability to distinguish between valid system instructions and invalid instructions that arrive from external inputs.

Hines et al. [Defending Against Indirect Prompt Injection Attacks With Spotlighting](https://arxiv.org/abs/2403.14720) Mar 20, 2024

> In the AI security vulnerabilities reported to Microsoft, indirect prompt injection is one of the most widely-used techniques.

Microsoft [How Microsoft defends against indirect prompt injection attacks](https://www.microsoft.com/en-us/msrc/blog/2025/07/how-microsoft-defends-against-indirect-prompt-injection-attacks) Jul 29, 2025

## Therefore

> We introduce spotlighting, a family of prompt engineering techniques that can be used to improve LLMs’ ability to distinguish among multiple sources of input.

Hines et al. [Defending Against Indirect Prompt Injection Attacks With Spotlighting](https://arxiv.org/abs/2403.14720) Mar 20, 2024

> Spotlighting involves specific changes to the system prompt and a corresponding transformation of the external text.

Microsoft [How Microsoft defends against indirect prompt injection attacks](https://www.microsoft.com/en-us/msrc/blog/2025/07/how-microsoft-defends-against-indirect-prompt-injection-attacks) Jul 29, 2025

> JSON escaping provides unambiguous delimiters between the untrusted payload and the surrounding structure, so an attacker cannot close a quote or tag to “break out” into an instruction context.

Anthropic [Mitigate jailbreaks and prompt injections](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/mitigate-jailbreaks)

## In use

Microsoft

> Microsoft’s multi-layered defense includes: Preventative techniques like hardened system prompts and Spotlighting to isolate untrusted inputs.

Microsoft [How Microsoft defends against indirect prompt injection attacks](https://www.microsoft.com/en-us/msrc/blog/2025/07/how-microsoft-defends-against-indirect-prompt-injection-attacks) Jul 29, 2025

## Where it breaks

People have written many attacks that get past it, and an attacker who knows the delimiters can forge them.

> human participants generated 265 successful attacks against Spotlighting and 178 against Prompt Sandwiching.

Nasr et al. [The Attacker Moves Second: Stronger Adaptive Attacks Bypass Defenses Against LLM Jailbreaks and Prompt Injections](https://arxiv.org/abs/2510.09023) Oct 10, 2025

> If an adversary gains knowledge of our system prompt, and therefore an understanding of the delimiting strategy, then it would be simple to craft a string that contains our delimiters and overrides our instructions.

Hines et al. [Defending Against Indirect Prompt Injection Attacks With Spotlighting](https://arxiv.org/abs/2403.14720) Mar 20, 2024

> Any difference between instructions and user input, or text wrapped in delimiters v.s. other text, is flattened down to that sequence of integers.

SW Simon Willison [Delimiters won’t save you from prompt injection](https://simonwillison.net/2023/May/11/delimiters-wont-save-you/) May 11, 2023

## Sources

1. [Defending Against Indirect Prompt Injection Attacks With Spotlighting](https://arxiv.org/abs/2403.14720) Keegan Hines, Hines et al., Mar 20, 2024
2. [The Attacker Moves Second: Stronger Adaptive Attacks Bypass Defenses Against LLM Jailbreaks and Prompt Injections](https://arxiv.org/abs/2510.09023) Milad Nasr, Nasr et al., Oct 10, 2025
3. [How Microsoft defends against indirect prompt injection attacks](https://www.microsoft.com/en-us/msrc/blog/2025/07/how-microsoft-defends-against-indirect-prompt-injection-attacks) Andrew Paverd, Microsoft, Jul 29, 2025
4. [Mitigate jailbreaks and prompt injections](https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/mitigate-jailbreaks) Anthropic
5. [Delimiters won’t save you from prompt injection](https://simonwillison.net/2023/May/11/delimiters-wont-save-you/) Simon Willison, May 11, 2023

Added Nov 14, 2026
