Lab 4: Safety Controls

Goal

Keep your system’s behavior within a written policy without making it unhelpful. You will measure both directions: harmful or wrong output going down, and benign requests still being answered.

Setup

The Acme Support app from Lab 3, with your hardened lab.toml, plus three evaluation sets in the lab’s JSONL format:

  1. benign requests: start from suites/benign.jsonl and extend it to at least 100;
  2. requests your policy disallows, drawn from a public safety benchmark (see 6.1);
  3. questions with and without answers in the documents. Use expect_contains for the answerable ones.

Implement your controls as guardrail hooks (see “Writing guardrails” in the lab README).

Task 4.1: Content Policy as a Specification

Write a one-page content policy for your system. Include disallowed, needs-care, and must-not-refuse tiers, with two worked examples each.

Outcome: the policy, and a labeled set of 30 examples drawn from it.

Task 4.2: Detection and Classification

Add a layered check: cheap rules first, then a classifier. Route only the ambiguous band to an LLM judge, and escape the content the judge evaluates. Choose thresholds from a precision-recall curve on your labeled set.

Outcome: a threshold-selection note, and evidence that the judge runs only on the ambiguous band.

Task 4.3: Groundedness and Hallucination

Add a per-claim support check against the retrieved chunks, plus an abstention path.

Outcome: the unsupported-claim rate before and after, on the answerable and unanswerable sets.

Task 4.4: Over-Refusal and Refusal Design

Measure the false-refusal rate on your benign set. Rewrite refusals so they are helpful, redirect when possible, and do not reveal internals.

Outcome: the false-refusal rate before and after, and three refusal examples.

Task 4.5: Sycophancy, Manipulation, and Vulnerable Users

Test whether your system reverses correct answers under pushback. Add crisis-signal routing to appropriate resources.

Outcome: the reversal rate, and a routing test.

Task 4.6: Structured Output Enforcement

Validate structured outputs against a strict schema that forbids extra fields and has no fail-open defaults. Retry within a bound, and handle truncation and refusals.

Outcome: tests covering malformed, truncated, and extra-field outputs.

Task 4.7: Streaming, Latency, and Failure Behavior

Decide fail-open or fail-closed for each check based on risk. Add timeouts. If you stream responses, add a buffered output check.

Outcome: a latency budget table (p50 and p95 per check) and a failure-behavior table.

Deliverables

  • The content policy and labeled set
  • Harm, unsupported-claim, and false-refusal rates before and after, with sample sizes
  • The latency budget and failure-behavior tables