Even when the prompt is right, the output can be wrong
The model can be successfully attacked, exhibit a rare failure, or simply produce content that violates your policies. Output filtering is the layer that catches what the prompt didn't.
Patterns to scan for
- Sensitive data — emails, phone numbers, SSNs, credit cards, internal API endpoints.
- Embedded resource URLs that could exfiltrate (image src, link href).
- Markdown / HTML constructs the UI will render and the user will trust.
- Profanity, hate speech, policy-restricted topics for your context.
- Prompt-injection markers ("ignore previous instructions," tool-call syntax in unexpected places).
How to enforce
- Regex / classifier on raw output before it reaches the user.
- HTML/markdown sanitizer that strips dangerous constructs.
- Second-pass LLM judge for high-risk content.
- Block, redact, or alert depending on severity.