liveBook · Manning

Defense in depth

As explained in Designing AI Systems

Defense in depth is a security pattern that applies multiple independent protective controls so that failure of one control does not eliminate protection.

Defense in depth places multiple inspection points across an AI assistant’s request lifecycle, so one missed threat or invalid action does not directly produce an unsafe outcome. The architecture validates user input at the gateway, checks tool arguments between the model and tools, and filters responses before delivery. section 10.7

Apply the pattern at three distinct control boundaries:

  • Input validation detects prompt-injection attempts, classifies topics, and blocks or redirects requests outside the assistant’s domain. section 6.7.1
  • Tool argument validation checks schemas, required fields, ranges, dates, authenticated identities, and resource existence before execution. section 6.7.1
  • Output filtering inspects the model’s response before returning it and records applied safety filters. section 10.7

Constrained assistant actions

A calendar tool rejects events whose timestamps are in the past, while a ticket-creation policy limits activity within a session. Separately, a topic policy blocks medical, legal, financial-trading, and personal-relationship requests before they reach the main model. section 10.7

Figure 10.7 Adding guardrails. Safety policies validate inputs, tool arguments, and outputs at multiple points in the request flow.

Trace how input, tool-call, and output controls are positioned across the request flow. section 10.7

How Designing AI Systems covers it

How deep it goes
Traces gateway checks, model-to-tool validation, output filtering, classifiers, schemas, constraints, and enforcement branches.
Examples
Uses medical-topic blocking, past-date rejection, patient-identity checks, output filtering, and session-scoped ticket limits.
What it assumes
Assumes an assistant request flow with model responses, tool calls, sessions, and gateway or service-level policy hooks.
What you can do after
Configure guardrails that block, redirect, warn, or constrain requests and tool calls before unsafe actions complete.
How it connects
Connects input validation, prompt injection detection, topic classification, schema validation, tool argument validation, and output filtering.

Also explained in

Compare how 11 books explain defense in depth →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.