Principle:Truera Trulens Input Blocking Guardrail
| Knowledge Sources | |
|---|---|
| Domains | Guardrails, Safety |
| Last Updated | 2026-02-14 08:00 GMT |
Overview
A runtime guardrail pattern that evaluates user input against a safety or quality threshold before allowing the application to process it.
Description
Input Blocking Guardrail implements a pre-processing safety gate. It decorates an application method and evaluates the user's input before the method executes. If the input scores below the threshold (or above, for inverse metrics like criminality), the method returns a safe default value without executing the underlying logic.
This prevents the application from processing harmful, off-topic, or otherwise undesirable inputs.
Usage
Use this principle when you need to validate user inputs before processing. Apply the decorator to the method that receives user input. Common use cases include blocking toxic inputs, off-topic queries, or prompt injection attempts.
Theoretical Basis
Pseudo-code Logic:
# Abstract input blocking
score = evaluate(user_input)
if score < threshold: # (or > for inverse metrics)
return safe_default_response
else:
return process_normally(user_input)
The higher_is_better flag on the feedback function determines the comparison direction.