Prompt Injection Defence in Depth (2026): Six Layers from Input Sanitisation to Output Firewall


The first production prompt-injection incident most teams encounter does not arrive as a clever adversarial prompt — it arrives quietly inside a customer support ticket whose description contains a literal <system>ignore prior instructions</system> tag, which the document loader indexes and the retriever later returns as a top-k result for an unrelated query. This article is a working architect's reference for defending production RAG against prompt injection: an attack taxonomy (direct, indirect via documents, recursive prompt-in-output, multi-turn poisoning), CVE-style example walk-throughs, a five-layer defence-in-depth architecture (input filtering, instruction hierarchy, structured output validation, JSON-schema constrained generation, sandboxed tool execution), an OWASP LLM Top 10 mapping, an evaluation harness with red-team prompts, and the runtime monitoring patterns that turn a one-time hardening exercise into an ongoing security posture.
Agent architecture in 2026 has three stages — prompt engineering, loop engineering, orchestrated teams — with a routing tree, cost matrix, and the eight anti-patterns to avoid.
A comprehensive guide to context engineering — the architectural discipline of designing systems that assemble the right information into an LLM's context window for every request. Covers the five types of context, the four-layer architecture stack, five production patterns, context window architecture for million-token models, agent context management, quality metrics, cost architecture, and three forward-looking trends.
Fine-tuning, RAG, and prompt engineering answer three different questions — how should it behave, what should it know, what should it be told. A decision architecture.
Advertise and partner
Reach engineering leaders and CTOs reading about AI, mobile and cloud architecture.
Sponsored mentions and co-authored articles or technical deep-dives. Relevant products only, always disclosed.