Safety, Security & Responsible AI·Question 15 of 70Intermediate

Design a defence-in-depth strategy for a customer-facing agent that reads user data and can take actions.

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

No single layer is trusted; each shrinks blast radius. From outside in:

Input layer. Cheap heuristics first (length caps, denylists, rate limits), then a fast injection/jailbreak classifier (Prompt Guard-style, tens of ms), then a moderation model for policy. Run these in parallel with the main generation and cancel on a hit so you don't pay serial latency.

Full worked answer with diagram

No single layer is trusted; each shrinks blast radius. From outside in:

Input layer. Cheap heuristics first (length caps, denylists, rate limits), then a fast injection/jailbreak classifier (Prompt Guard-style, tens of ms), then a moderation model for policy. Run these in parallel with the main generation and cancel on a hit so you don't pay serial latency.

Model layer. Use a model trained with an instruction hierarchy. Clearly delimit untrusted content and mark it as data. Keep the system prompt free of secrets. Don't over-rely on this layer - it's probabilistic.

Privilege / architecture layer (the load-bearing one). Least-privilege tool scopes: read-only by default, per-user/per-tenant credentials, short-lived tokens. Break the lethal trifecta - the agent touching private data should not both ingest untrusted content and have an unattended exfil channel. Consider a dual-LLM split: a quarantined model summarises untrusted content into typed values, a privileged model orchestrates.

Output layer. Moderation, PII scan, groundedness check, and - highest leverage - schema/structural validation: constrain tool arguments to typed enums and validated formats so an injection can't smuggle arbitrary actions. Encode/escape anything rendered; allowlist URLs.

Human-in-the-loop. Every irreversible/consequential action (send money, email, delete, change permissions) requires explicit approval, showing the user exactly what will happen.

Monitoring. Immutable audit log of prompts, outputs, tool calls, approvals; anomaly alerts (spend spikes, unusual tool sequences, classifier-hit rates). Feed incidents back into regression evals.

The interview signal is prioritisation: if forced to pick, least privilege + human approval on consequential actions buy the most safety, because they cap damage regardless of whether the model was fooled. Classifiers reduce frequency of attacks; architecture reduces impact. You want both, but impact-reduction is what makes the system defensible.

Worth sketching. Labelling which layers cut frequency and which cut blast radius is what turns a list of controls into a prioritisation argument.

flowchart TD
    A["Request"] --> B["Input classifiers"]
    B -->|"reduce attack frequency"| C["Model layer<br/>instruction hierarchy, delimited data"]
    C --> D["Privilege layer<br/>least-privilege tools, scoped creds"]
    D -->|"reduce blast radius"| E["Output layer<br/>schema validation, encoding"]
    E --> F["Human approval on irreversible actions"]
    F --> G["Audit log and anomaly alerts"]

What a good answer covers

  • No single layer is trusted; each shrinks blast radius
  • Cheap heuristics first (length caps, denylists, rate limits), then a fast injection/jailbreak classifier…
  • Run these in parallel with the main generation and cancel on a hit so you don't pay serial latency
  • Use a model trained with an instruction hierarchy
  • Clearly delimit untrusted content and mark it as data

Key terms: Input layer · Model layer · Output layer · schema/structural validation · Human-in-the-loop · Monitoring

Interviewer follow-ups to expect

  1. If you could only implement two layers, which two and why?

  2. How do you keep the input classifiers from adding 500ms of latency?

  3. Where does this design still fail, and is that residual risk acceptable?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep