Forward Deployed EngineeringEnterprise SecurityGeneration Safety

Defend a high-stakes generation pipeline against jailbreaks and hallucination at the same time.

Question 63 of 73 · Updated

On this page

Interview-ready answer#

I would design the pipeline around two independent release conditions: the output must be permitted, and its material factual claims must be supported. A jailbreak can induce an unauthorized disclosure or prohibited behavior even when the resulting statement is factually correct. A hallucination can produce a harmful falsehood without any malicious input. Passing one condition cannot compensate for failing the other.

The generator is an untrusted proposal producer, not the policy authority or source of truth. I would constrain its evidence and capabilities, independently verify the resulting candidate against authorization, content policy and evidence requirements, and release only the exact candidate that passed every applicable gate. Uncertain cases would abstain or go to qualified review.

For high-consequence actions, I would enforce business invariants outside the model. For semantic correctness and jailbreak resistance, I would quantify residual risk on representative and adversarial test suites rather than promise perfect detection. The design must remain safe when a verifier times out, a source changes, or an attacker influences multiple components simultaneously.

1. Separate the two failure dimensions#

Factually supportedUnsupported or incorrect
Permitted outputEligible for release after remaining checksHallucination or omission; withhold or correct
Prohibited outputSecurity or policy violation; block even if trueBoth security and factual failure; block

For example, an internal financial-policy assistant could disclose an accurate but confidential account detail, or incorrectly assert that a customer qualifies for a payment. The former is a disclosure-control failure; the latter is a correctness failure. An adversarial request can cause both at once.

Treat the combined risk as the union of policy and correctness failures, not the product of their rates. The two can be highly correlated.

2. Layered architecture with a single controlled release point#

Loading diagram…

The diagram emphasizes a join, not a majority vote: all required reports must refer to the same output and applicable request context. A human reviewer may supply missing evidence or resolve uncertainty, but cannot override a non-overridable authorization rule. A revised candidate must be checked again.

Control the evidence and capabilities#

Authenticate the user, authorize the task and enforce document access outside the model. Restrict retrieval to applicable, versioned sources and preserve provenance. An approved document can contain untrusted instructions; its approval as factual evidence does not grant it control-plane authority.

Minimize data sent to the generator and verifiers. Separate tool permissions from natural-language instructions. For a generation-only system, avoid write tools altogether. If actions are necessary, use the independently authorized executor described in FDE-0053.

Generate into a typed intermediate representation where practical: a set of material claims, evidence references and the proposed response. Verify evidence against the actual authorized source version, not a citation label supplied by the model. Check omissions and qualifying conditions as well as positive assertions. Structured output makes validation easier; it does not establish truth.

3. Verify independently and bind the release to the verified artifact#

Different checks need different kinds of evidence.

GateStrongest practical mechanism
Identity, destination, document accessDeterministic policy using trusted request and source metadata
Output-policy complianceApplicable rules and validated classifiers, with review where uncertainty requires it
Exact values, dates, calculations and identifiersDeterministic checks against authoritative records or computations
Semantic claim support and completenessEvidence-aware verifier calibrated against domain experts
High-consequence or uncertain decisionsQualified human oversight where required by the task policy

A second model is not necessarily independent in the statistical sense. Shared training data, identical source defects and similar instruction-following weaknesses can produce correlated errors. Prefer authoritative checks and independent data where available. Give a semantic verifier the relevant evidence and rubric, not the generator's unsupported confidence as proof. Keep verifier capabilities narrow and treat the candidate text as data.

Avoid time-of-check/time-of-use errors. An output that is verified and then edited, personalized, translated or reformatted in a way that changes meaning must not inherit the old approval. Bind reports to the final canonical artifact, authenticated scope, relevant evidence revisions, policy version, checker configuration and validity window. Verify the bindings at release, including current authorization. Stream only approved content: a post-generation checker cannot recall a sensitive token already sent to the user.

Tested Python: fail-closed release join#

This minimal example demonstrates candidate binding and required-gate completeness. Assume reports have already been authenticated and validated against the same request, source versions, policies and expiry rules by trusted application code. The caller, not the model, determines whether human review is required.

PYTHON
from hashlib import sha256 def release(candidate, reports, review_required): required = {'authorization', 'content_policy', 'evidence', 'quality'} if review_required: required.add('human_review') digest = sha256(candidate).hexdigest() for name in required: report = reports.get(name) if report is None or report[0] != digest or report[1] is not True: return False return True

Python 3.13.5 passed 15,554 checks: all 15,552 combinations of six report states across five gate types and two human-review modes, plus an edited-candidate rejection and an unrelated-report check. The six states included missing, pass, fail, unknown, mismatched digest and a non-boolean verdict.

The digest binds bytes; it is not a signature and does not establish who issued a report or whether its conclusion is correct. The example assumes immutable bytes, validated report shapes, authenticated checker identities and typed trusted inputs. In production, use an immutable release manifest and a trusted report store; recheck expiring permissions and evidence revisions at dispatch. A missing required report, timeout or dependency failure is not a pass.

4. Design evaluation around overlapping failures#

Use independent labeled sets for representative traffic and targeted security challenges. Test the actual application, including retrieval, verifiers, rendering, access enforcement and handoff; model-only refusal scores cannot establish system security.

Test familyRequired observation
Direct and indirect instruction manipulationNo unauthorized disclosure, action or policy violation reaches the user
Benign but unanswerable or ambiguous questionAppropriate abstention rather than an invented fact
Relevant source contains misleading instructionsPreserve authorized evidence use without granting the source authority
Factually accurate but restricted materialDisclosure gate blocks it
Permitted but false or incomplete statementEvidence gate rejects or escalates it
Verification outage, stale report or edited candidateNo unvalidated release
Legitimate difficult taskCorrect useful response or approved review, not indiscriminate refusal

Measure security attack success at the protected boundary, not merely whether the model produced a suspicious internal proposal. Measure material unsupported claims and incorrect accepted answers separately. Include false blocking, false abstention, review workload and time to resolution, so a system that refuses everything cannot appear operationally excellent.

For adversarial testing, use controlled synthetic secrets and sandbox resources; inspect actual output, logs and outbound requests. Evaluate multiple turns and combinations of failures. Reserve unseen challenge cases to reduce overfitting to familiar attacks. For ordinary traffic, use representative held-out requests and qualified labels. A curated attack suite's success rate does not directly estimate the incidence of production attacks.

Quantify residual risk without overclaiming#

Consider an illustrative fixed evaluation of 1,000 representative eligible requests. Suppose 600 answers are released. Among them, 5 violate a security or content policy, 9 contain a material factual error, and 2 have both defects.

  • Coverage: 600 / 1,000 = 60%.
  • Security failure among released answers: 5 / 600 = 0.83%.
  • Material factual failure among released answers: 9 / 600 = 1.50%.
  • Combined failure among released answers: (5 + 9 − 2) / 600 = 2.00%.
  • Combined failure per eligible request: 12 / 1,000 = 1.20%.

All counts are hypothetical; this is not a passing system for a customer requiring no observed critical violations. Count overlapping defects once when estimating the union while retaining separate severity labels. Report denominators and confidence bounds. Zero observed critical failures in a finite independent representative sample is not proof of zero risk, as discussed in FDE-0050.

Tune the acceptance threshold on a calibration set, then freeze it for independent evaluation. Choose the highest useful coverage meeting the required risk bounds and non-negotiable policy gates. Never trade an authorization violation against improved groundedness or throughput. FDE-0054 covers the risk–coverage mechanics; this question adds the interaction between security and factual failures at a shared release boundary.

5. Operationalize the safety contract#

Agree on which invariants can be enforced structurally and which semantic judgments require empirical validation. For example, a release service can enforce that a required authenticated report exists for the exact candidate. It cannot guarantee that every semantic verifier is correct merely by checking that report.

Pin and audit the effective model, policy, evidence, verifier and threshold versions. Monitor critical incidents, false acceptance, unsupported claims, coverage, reviewer agreement and dependency failures by risk slice. Independently sample released answers, not just blocked ones. Preserve minimized diagnostic records in the approved trust boundary, and maintain a kill switch that disables affected generation capabilities without model cooperation.

When a verifier fails or review capacity is exhausted, reduce supported scope or switch to a previously validated deterministic workflow. Do not lower safety thresholds or silently bypass verification to recover latency. Optimize shared deterministic checks, parallelize independent checks where appropriate, and measure the latency and cost of the complete release process.

My customer-facing commitment would be specific: enforce explicit permissions and release invariants, measure residual security and factual risks separately and jointly, and require human oversight or abstention when the evidence does not justify an automated answer. That is a defensible safety contract, not a promise that a model is impossible to jailbreak or hallucination-free.

Related questions

Explore other topics:AI AgentsAI System DesignLarge Language Models