How a many-shot jailbreak works
The attack has three parts, all delivered in a single long prompt:
- The prompt is filled with fabricated dialogue in which an assistant complies with requests it should refuse.
- The real request is appended after that dialogue.
- The attack relies on in-context learning to shift the model's behavior toward the pattern shown in the fabricated examples.
Why long context windows increase exposure
The attack depends on a long prompt that can hold a large amount of fabricated dialogue. Wherever an AI system accepts long content, there is room for that structure to appear. That content can arrive in several places: the user message, retrieved passages, files, and conversation history. Each is a point where the dialogue-like pattern can enter the prompt, which is why the controls below cover more than the user's message alone.
Where runtime controls fit in the request path
Each enforcement point addresses a different part of the problem, and each has a limitation worth planning around.
Enforcement points at a glance
- Input and contextInspect prompts, history, and retrieved content before they reach the model.
- Policy decisionApply rules that do not depend on the model's own judgment.
- Tool callCheck permissions and approvals before any action executes.
- OutputReview responses before they reach the user or downstream systems.
- LoggingRecord decisions so attempts can be investigated.
What each control does
| Control | What it does |
|---|---|
| 1. Input inspection | Examines the user message for repeated dialogue-like structure, such as many alternating role labels, and applies length or structure limits where the use case allows. |
| 2. Context inspection | Applies the same checks to retrieved passages, files, and conversation history before they are assembled into the prompt. |
| 3. Policy enforcement | Evaluates each request against explicit rules outside the model, such as which users, data, and actions are allowed. |
| 4. Tool-call restrictions | Checks agent permissions, scope, and approval requirements at the point of the call, independent of the model's output. |
| 5. Output checks | Reviews responses for policy violations or sensitive data before delivery. |
| 6. Logging and monitoring | Records inputs, decisions, and actions so attempts can be detected and investigated. |
Tradeoffs: false positives, latency, and evasion
Every control above has a limitation worth planning around:
- False positives (input inspection): Legitimate long inputs, like transcripts, can resemble the attack.
- Latency (context inspection): The checks add work on every request and depend on knowing which content is untrusted.
- Coverage (policy enforcement): Rules only cover what has been defined.
- Scope of impact (tool-call restrictions): They limit impact but do not stop unsafe text.
- Evasion (output checks): Checks can miss paraphrased or encoded content.
Logging, governance, and where runtime policy enforcement fits
Logging and monitoring record inputs, decisions, and actions so attempts can be detected and investigated. Logging records an attack but does not prevent it, so it complements the controls that block, rather than replacing them.
Policy enforcement sits between the request and the model, and again at the tool call. It evaluates rules outside the model, which means the decision does not depend on the model's own judgment. Together with logged decisions, this gives security teams a basis for investigation and audit.
Questions to ask when evaluating a runtime control
- At which points does it inspect or enforce policy: input, retrieved context, tool call, or output?
- What are the false-positive rate and added latency on long-context inputs, and how were they measured?
- Can it restrict or require approval for tool calls independently of the model's output?
- What is logged for each blocked or allowed request, and does it support investigation and audit?
- What evidence shows it holds up against obfuscated or restructured many-shot prompts?