Why this module exists. Every team’s first instinct against prompt injection is an input filter — a classifier or a regex that looks for “ignore previous instructions.” It does not work, and betting your architecture on it is how you end up in an incident report. This module explains why filtering fails against an adaptive adversary and walks through the defence-in-depth patterns that actually contain injection: privilege separation, the dual-LLM pattern, capability-based tool design, and deterministic guardrails on the action layer.
Why input filtering cannot be the primary control
Prompt injection is not a fixed signature; it is any natural-language text that redirects a model’s behaviour. The input space is unbounded and the adversary is adaptive: paraphrase, translate into another language, encode in base64, split across turns, hide in a modality the classifier does not read, or embed in retrieved content the filter never sees. A classifier trained on today’s payloads is a speed bump, not a boundary. Treat input filtering as defence-in-depth — useful for cutting noise and raising cost — but architect as though it will be bypassed, because against a motivated attacker it will be.