Risk-Certified Prompt Optimization: Adding Safety Constraints to LLM Judge Guardrails

Models LLM guardrail system prompt selection as constrained optimization with finite-sample risk certification.
The article introduces a new paper noting that existing system prompt optimization for LLM-as-a-judge guardrails pursues only average performance and ignores tail missed-detection risk. The paper models prompt selection as constrained optimization: under finite-sample statistical control, maximize the benign pass rate while keeping the missed-attack rate below a user-specified level α. The framework combines an LLM judge, automatic prompt generation, and distribution-free risk certification, using simultaneous upper confidence bounds to certify candidate prompts. It instantiates two paths—CPS fixed-pool search and CRISP adaptive search, the latter embedding risk feedback into generation. On datasets covering prompt injection, system-prompt leakage, and sensitive-information disclosure, certified selection consistently meets the target risk level, and benign utility increases as the risk constraint is relaxed, forming an adjustable knob between safety and utility.
LLM-as-a-judge guardrails typically rely on system prompts for control, but standard prompt optimization methods pursue average performance and do not explicitly handle safety constraints. A new paper models system prompt selection as a constrained optimization problem: under finite-sample statistical control, maximize the benign pass rate while keeping the missed-attack rate below a user-specified level α.

Why isn't average performance enough?
Using an LLM as a judge to intercept harmful outputs is the mainstream approach in current guardrail design. How well the system prompt is written directly determines interception effectiveness. The problem is that conventional prompt optimization—whether manual tuning or automated search—often targets average accuracy or average pass rate.
This optimization approach masks tail risk: a prompt may perform well on most samples yet miss many attacks under specific attack patterns. For safety guardrails, the cost of missed detections far exceeds that of false positives. The paper points out that standard prompt optimization methods do not target explicit safety constraints, which is exactly the gap the risk-certification framework aims to fill.
Turning prompt selection into a constrained optimization problem
The paper's core modeling is straightforward: treat system prompt selection as a constrained optimization problem. The objective is to maximize the benign pass rate, subject to the missed-attack rate being below a user-specified level α, with statistical guarantees under finite samples.
The difficulty lies in "finite-sample statistical control." The evaluation set is finite, so the observed missed-detection rate does not equal the true missed-detection rate. The framework introduces distribution-free risk certification, using simultaneous upper confidence bounds to certify candidate prompts; only statistically credible prompts enter the final selection.
The overall framework combines three capabilities: an LLM judge, automatic prompt generation, and distribution-free risk certification.
Distribution-free risk certification is a statistical inference method that does not rely on parametric assumptions about the data distribution. In the guardrail setting, this means the certification conclusions remain valid regardless of the distribution from which attack samples come. Its core tool is simultaneous upper confidence bounds: for each candidate prompt, compute a confidence upper bound on the missed-detection rate based on finite evaluation samples, and require that this upper bound simultaneously, with high probability, be no lower than the true missed-detection rate across all candidates. Unlike pointwise confidence intervals, the "simultaneous" guarantee corrects for multiple comparisons, avoiding underestimation of risk due to selecting among a large number of candidate prompts. Only prompts whose confidence upper bound is below α are certified as safe, thereby converting "observed low missed-detection rate" into the credible claim "true missed-detection rate is likely low."
Two implementation paths: CPS and CRISP
The paper instantiates the framework as two procedures.
CPS (fixed-pool search) first generates a fixed pool of prompts from training data, then certifies candidates on a held-out evaluation set, selecting the certified prompt with the highest benign utility. The pipeline is clear and computationally manageable, suitable for tasks where the prompt space is relatively well-defined.
CRISP (adaptive search) embeds risk feedback into the prompt generation process. It uses hard example-guided rewriting and a reusable-holdout interface to steer generation toward the feasible utility frontier. Simply put, CPS is "generate first, then filter," while CRISP is "filter while generating."
The paper specifically notes that CRISP's value is especially evident when fixed-pool search fails to produce certifiable high-utility candidates.
Hard example-guided rewriting refers to prioritizing, within the prompt generation loop, the collection of hard samples that the current candidate prompt misses or misjudges, feeding them back as context to the LLM and instructing it to rewrite the system prompt to cover these failure modes. The reusable-holdout interface addresses the overfitting problem caused by repeatedly using the same holdout set: through statistical methods (such as multiple splits or confidence sequences), the same holdout data can be queried multiple times without significantly losing certification validity, thereby continuously providing reliable risk signals during adaptive search. Combined, the two enable CRISP to dynamically approach the feasible utility frontier during generation, rather than passively filtering after one-shot generation.
Experimental setup and key findings
Experiments cover four datasets across three risk scenarios: prompt injection, system-prompt leakage, and sensitive-information disclosure.
The results show two consistent patterns. First, risk-certified selection consistently meets the target missed-attack level on held-out tests, indicating that the statistical certification mechanism is indeed effective rather than overfitting the evaluation set. Second, when the allowed risk level is relaxed, utility increases accordingly—consistent with the expectations of constrained optimization: the looser the constraint, the larger the feasible region, and the higher the achievable benign utility.
Together, these two points show that the framework provides an adjustable knob between safety and utility, rather than a fixed trade-off.
Implications for guardrail engineering
This work offers several takeaways for practical deployment. First, system prompts for guardrails should not be selected solely by average metrics; an explicit risk budget α should be introduced so that stakeholders can specify how much missed detection is acceptable. Second, finite-sample certification reminds us that missed-detection rate numbers on small evaluation sets are unreliable and require confidence upper bounds as a safeguard.
CRISP's hard-example-guided approach is also worth adopting—feeding failure cases back into prompt generation can approach the utility frontier better than one-shot prompt pool construction. Of course, the paper currently validates on only four datasets; for more open attack surfaces, the sample size and computational cost required for certification remain engineering challenges for real-world deployment.
One-line Summary
Models LLM guardrail system prompt selection as a constrained optimization problem with finite-sample risk certification.
Paragraph Summary
The article introduces a new paper noting that existing system prompt optimization for LLM-as-a-judge guardrails pursues only average performance and ignores tail missed-detection risk. The paper models prompt selection as constrained optimization: under finite-sample statistical control, maximize the benign pass rate while keeping the missed-attack rate below a user-specified level α. The framework combines an LLM judge, automatic prompt generation, and distribution-free risk certification, using simultaneous upper confidence bounds to certify candidate prompts. It instantiates two paths—CPS fixed-pool search and CRISP adaptive search, the latter embedding risk feedback into generation. On datasets covering prompt injection, system-prompt leakage, and sensitive-information disclosure, certified selection consistently meets the target risk level, and benign utility increases as the risk constraint is relaxed, forming an adjustable knob between safety and utility.
Related articles

Zhipu GLM-5.4 Released: Loop Transformer Runs 28 Layers Twice
Zhipu releases GLM-5.4, the first Loop Transformer flagship: 28 layers run twice for 2-3T-equivalent intelligence, plus video and image input. API and open weights not yet released.

GLM-5.4 Coding Test 4.6x Slower? Unpacking the Loop Transformer Architecture
GLM-5.4 coding test took 431 minutes vs. competitor's 109, 4.6x more steps. We analyze its Loop Transformer architecture, KingBench4 score of 55.3, Max tier's 1.04M token cost, and tier selection advice.

Zhipu GLM-5.4 Quietly Released: A Debut for Loop Transformer Architecture
Zhipu GLM-5.4 quietly lands in coding plans: first Loop Transformer flagship with 750B params, 1M token context, AIM math up from 19.2 to 30.4, and native vision for coding from screenshots.