guardrails
diapason.security.guardrails
¶
GuardrailsEngine — security-aware inference engine wrapper.
GuardrailsEngine
¶
Bases: InferenceEngine
Wraps an existing InferenceEngine with security scanning.
Not registered in EngineRegistry — instantiated dynamically to wrap
any engine at runtime.
Parameters¶
engine:
The wrapped inference engine.
scanners:
List of scanners to run. Defaults to SecretScanner + PIIScanner.
mode:
Action taken on findings: WARN, REDACT, or BLOCK.
scan_input:
Whether to scan input messages.
scan_output:
Whether to scan output content.
bus:
Optional event bus for publishing security events.
engine_id
property
¶
Delegate to the wrapped engine.
generate(messages, *, model, temperature=0.7, max_tokens=1024, **kwargs)
¶
Scan input, call wrapped engine, scan output.
health()
¶
Delegate to wrapped engine.
list_models()
¶
Delegate to wrapped engine.
stream(messages, *, model, temperature=0.7, max_tokens=1024, **kwargs)
async
¶
Use the same safe boundaries as rich output, including long secrets.
stream_full(messages, *, model, temperature=0.7, max_tokens=1024, **kwargs)
async
¶
Stream verified text without releasing tools or terminal data early.
SecurityBlockError
¶
Bases: Exception
Raised when mode is BLOCK and security findings are detected.