9.1 Defense-in-Depth Guardrail Architecture
Key Takeaways
Governance, Safety & Risk Management is 14% on the November v1.1 blueprint and 16% on the December 7 v1.1 blueprint. Place mutually reinforcing input, model, execution and output controls.
Enforce tenant isolation, permissions and financial limits in trusted application/backend code; instructions, classifiers and structural checks alone are not authorization.
Evaluate classifiers and deterministic checks together. For sensitive output, validate before release and account for partial streaming responses and scanner limitations.
Measure policy violation detection and false refusals on representative, labeled test cases; adjust controls according to risk without weakening authorization.
9.1 Defense-in-Depth Guardrail Architecture
Governance, Safety & Risk Management is 14% on the November 2026 v1.1 exam blueprint and 16% on the December 7 v1.1 blueprint. Enterprise assistants need layered controls because no single model instruction or screening mechanism can enforce all business and security requirements.
Multi-Layer Guardrail Placement
- Input (pre-inference): Authenticate the caller, validate request structure and size, minimize sensitive fields before transmission or logging, and screen content where appropriate. For instance, an application can impose a project-specific request size limit. A lightweight model can classify inputs, but must be calibrated; if it returns a refusal or no valid verdict, handle that safely rather than treating it as a pass.
- Model and instructions: Define scope, escalation, refusal and source-grounding rules. Keep trusted instructions separate from untrusted retrieved content. These policies guide model behavior but are not enforcement boundaries.
- Tool execution: Independently authenticate and authorize every consequential operation in trusted code. Bind permissions to the verified request principal, validate arguments and state transitions, constrain credentials and destinations, and use parameterized database queries. When using the Claude Agent SDK, a
PreToolUsehook can reject operations before execution; the backend must still enforce its own authorization and business limits. With Managed Agents, client-handled custom tools require authorization in the client/backend rather than relying on the hosted tool permission policy. - Output (before release): Validate structure, sensitive-data handling, safe rendering and citation support as appropriate to the task. Schema validation and sensitive-data pattern checks are complementary; neither guarantees semantic correctness or absence of every sensitive value.
| Layer | Example controls | Limitation if used alone |
|---|---|---|
| Input | Size limits, data minimization, classification | Cannot authorize later tool actions or ensure correct answers |
| Model | Scope, trusted instruction separation and abstention | Model behavior remains probabilistic |
| Execution | Authenticated scope, least privilege, argument and state checks | Does not validate all generated prose |
| Output | Schema, disclosure and evidence checks before release | Cannot undo a completed side effect |
Streaming vs. Output Validation
Streaming improves perceived responsiveness but a client cannot un-receive bytes already sent. Incremental validation can work for suitable patterns if the implementation retains enough context across boundaries; a simple fixed-length scanner may miss a value split across chunks. For sensitive or structured responses requiring whole-output validation, buffer the complete result, check the final stop reason, schema, disclosure policy and evidence before release. Treat refused or incomplete responses as incomplete; never perform a side effect based on a partial tool argument. Measure the latency cost against the application requirement.
Deterministic Controls vs. Classifier Guardrails
Consider an illustrative test with 500,000 prohibited requests and a classifier with 99.2% recall on that distribution. If the observed rate generalizes, the expected number of missed prohibited requests is 500,000 × (1 − 0.992) = 4,000. At 99.9% recall it is 500. If only 1% of 500,000 total requests are prohibited, the first estimate instead is 5,000 × 0.008 = 40. Missed classifications do not necessarily become actual breaches, which is precisely why independent execution checks matter.
Use enforceable invariants for well-defined boundaries:
- Tenant isolation: Derive tenant scope from verified authorization at the data-access service. Do not trust the model to select a tenant.
- Financial and quota limits: For an example 500-credit standard refund limit, reject amounts above the limit or route exceptions for authorized review before the payment system executes. Anthropic recommends human approval of each money-moving tool call; a cap is an additional safeguard. Enforce cumulative restrictions where applicable.
- State transitions: Reject malformed inputs and unauthorized changes before any side effects; validate the final state.
Correctly implemented deterministic checks enforce specified rules independently of a model verdict, but implementation errors or incomplete policies can still fail. Test them separately from semantic screening.
Managing False Positives and Over-Refusal
Measure both the fraction of prohibited test cases correctly blocked (recall) and the fraction of permitted cases incorrectly blocked (false-positive or over-refusal rate). Also assess precision and actual unauthorized outcomes. A claims review assistant, for example, may need to summarize legitimate clinical documentation containing sensitive vocabulary; refusing all such documents is not a useful workflow.
- Build representative labeled datasets of permitted tasks and policy violations, with separate held-out examples.
- Calibrate the screen using the intended policy and verified role context. Role context helps interpretation, but it does not waive policy or authorization.
- Where appropriate, provide a safe subset of a result or route the decision to an authorized reviewer. Do not expose sensitive information merely because an approval is requested.
- Monitor and revise thresholds using the project's risk tolerance, domain expertise and measured errors. A finite evaluation cannot prove a system is safe in every situation.
Exam Trap: Prompt-only tenant isolation or refund ceilings are not enforcement. Output checks cannot reverse completed operations or previously released data.
A SaaS analytics platform lets enterprise customers ask Claude to query usage metrics via a run_analytics_sql tool. A security review finds that Claude currently passes tenant_id as a tool argument, and the system prompt instructs Claude never to query another customer's tenant ID. Which architectural change provides reliable tenant isolation?
Remove tenant_id from the tool schema exposed to Claude and inject the verified tenant_id from the server-side authentication token inside the tool execution service
Add a Claude Haiku output classifier to verify that generated answers only mention the requesting customer's company name
Repeat the tenant isolation instruction in XML tags at both the start and end of the system prompt
Switch the run_analytics_sql tool to read-only database credentials while keeping tenant_id as a model-supplied parameter
An enterprise deploys a customer-support agent with a $250 standard refund limit and separate required human payment approval. During load testing, a multi-turn prompt persuades the model to issue a $1,200 refund, and a secondary LLM guardrail judge misses the violation 0.6% of the time. Where should the $250 refund ceiling be enforced?
In the input pre-screen classifier by scanning user messages for numbers above 250
In a deterministic pre-execution check and payment backend that reject or escalate amounts above 25,000 cents
In the system prompt using bold warning text and few-shot refusal examples
In an asynchronous post-response audit job that alerts finance 15 minutes after the refund settles
A healthcare insurer launches a Claude-powered claims-review assistant and observes a 16% refusal rate on legitimate nurse-reviewer requests because the input guardrail flags terms like "overdose," "suicide risk," and "controlled substance." What is the best remediation strategy?
Disable the input and output classifiers completely for all internal employees
Instruct nurse reviewers to replace clinical terms with coded abbreviations before submitting prompts
Calibrate the guardrail against a hard-negative clinical benchmark, pass verified reviewer role context, and measure both attack block rate and over-refusal rate together
Increase the model temperature to 0.9 so responses are less likely to trigger standard refusal templates
A wealth-management portal streams Claude's responses token-by-token to client browsers to keep Time to First Token under 500 ms. A compliance audit finds that an account number occasionally appears on screen for a fraction of a second before an end-of-stream DLP check aborts the session. Which output-layer architecture resolves this defect?
Move the DLP scanner to the input layer so client names are stripped before inference
Keep unbuffered streaming and hide leaked strings client-side using JavaScript after the stream finishes
Disable all tool calls and rely solely on system prompt instructions forbidding account numbers
Buffer the response until appropriate whole-output disclosure checks and final completion checks pass, then release it
Sections you finish are checked off in the contents.