Skip to main content

Module guardrails

Module guardrails 

Source
Expand description

Input guardrails: local heuristic screening of chat input for prompt-injection / jailbreak patterns and obvious secrets/PII, run before the LLM call.

This is a first-line, dependency-free signal — substring matching for injection phrases and shaped scans for secrets/PII. It is intentionally conservative (accepts false negatives) and never echoes the matched value; findings carry only a category and a short label.

The InputScreen trait allows replacing or supplementing the built-in heuristic with a classifier-based screen (e.g. an LLM judge). Callers use screen_input for the built-in heuristic or compose screens via ChainedScreen.

Structs§

ChainedScreen
Chains multiple screens, returning the first finding from any screen. Screens are evaluated in order; the first non-None result wins.
GuardrailFinding
A guardrail finding: the category and a short, content-free reason label.
HeuristicScreen
The built-in heuristic screen (substring + shaped scans). This is the default screen used when no custom screen is configured.

Enums§

GuardrailCategory
Category of a guardrail finding.

Traits§

InputScreen
Pluggable input screen interface. Implement this to replace or supplement the built-in heuristic with a classifier-based screen (e.g. an LLM judge).

Functions§

screen_input
Screen chat input. Returns the first finding (injection takes precedence over PII), or None when screening is disabled or the input is clean.