UPL Filter
The upl-filter policy prevents AI systems from engaging in the unauthorized practice of law by detecting legal-advice-giving language and optionally injecting disclaimers or rewriting responses to an educational framing.
Use this page when
- You are deploying a legal information chatbot and must prevent it from giving specific legal advice.
- You need to detect unauthorized-practice-of-law language and inject "this is not legal advice" disclaimers.
- You want to rewrite legal-advice responses to an educational framing rather than blocking them entirely.
Primary audience
- Primary: AI Agents, Technical Engineers
- Secondary: Technical Leaders
Configuration
policy:
upl-filter:
blocked_patterns: []
require_disclaimer: true
rewrite_to_educational: false
pack:
name: upl-filter-example-1
version: 1.0.0
enabled: true
policies:
chain:
- upl-filter
Fields
| Field | Type | Description | Default |
|---|---|---|---|
blocked_patterns | string[] | Unauthorized practice of law patterns. Built-in defaults detect legal-advice-giving language such as "you should file", "your legal rights are", and "I advise you to". Custom patterns extend the built-in set. | [] |
require_disclaimer | bool | Inject a "this is not legal advice" disclaimer into responses that discuss legal topics. | true |
rewrite_to_educational | bool | Rewrite responses to an educational framing (e.g. "generally, the law provides…") instead of blocking them outright. When enabled, takes precedence over blocking for matched content. | false |
Use Cases
Legal Information Chatbot Compliance
Ensure a public-facing legal information chatbot never crosses the line into giving specific legal advice.
pack:
name: "legal-info-chatbot"
version: "0.1.0"
enabled: true
policies:
chain:
- prompt-injection
- upl-filter
- audit-logger
policy:
prompt-injection:
threshold: 0.8
action: "block"
upl-filter:
require_disclaimer: true
rewrite_to_educational: true
audit-logger:
retention_days: 730
Law Firm Client-Facing AI
A law firm deploys a client intake assistant that must never offer legal conclusions, only collect facts and direct users to qualified attorneys.
pack:
name: "law-firm-intake"
version: "0.1.0"
enabled: true
policies:
chain:
- upl-filter
- pii-detector
- legal-privilege
policy:
upl-filter:
blocked_patterns:
- "you have a strong case"
- "you should sue"
- "the court will likely"
- "your legal options are"
require_disclaimer: true
rewrite_to_educational: false
pii-detector:
action: "redact"
legal-privilege:
action: "block"
Consumer Legal Assistant
A consumer-facing assistant that explains legal concepts educationally without providing jurisdiction-specific counsel.
pack:
name: "consumer-legal-assistant"
version: "0.1.0"
enabled: true
policies:
chain:
- upl-filter
- safety-filter
policy:
upl-filter:
require_disclaimer: true
rewrite_to_educational: true
safety-filter:
action: "block"
How It Works
- Pattern matching — The gateway scans each response for language patterns that indicate specific legal advice. Built-in patterns cover common legal-advice phrases (e.g. "you should file a motion", "your rights under the law are"). Custom
blocked_patternsare appended to the built-in set. - Disclaimer injection — When
require_disclaimeris enabled, a standard "This is not legal advice" disclaimer is appended to any response that discusses legal topics, even if no blocked patterns matched. - Educational rewriting — When
rewrite_to_educationalis enabled, matched responses are reframed into general educational language (e.g. "Generally, the law provides that…") rather than being blocked. This preserves the informational value while removing the directive tone. - Blocking — If
rewrite_to_educationalis disabled and a blocked pattern matches, the response is blocked and an error is returned to the caller.
Best Practices
- Start with disclaimers before blocking. Enable
require_disclaimerfirst and monitor flagged responses before adding strictblocked_patternsthat block outright. - Combine with
legal-privilegepolicy. Useupl-filterfor outbound advice detection andlegal-privilegefor inbound privileged content protection. - Add jurisdiction-specific patterns. The built-in defaults are US-centric. Add patterns relevant to your jurisdiction (e.g. "solicitor-client privilege" for UK/AU, "notaire" for FR).
- Use
rewrite_to_educationalfor consumer tools. For public-facing assistants, educational rewriting provides a better user experience than hard blocks while maintaining compliance. - Audit regularly. Review audit logs for matched patterns to refine your
blocked_patternslist and reduce false positives.
For AI systems
- Canonical terms: Keeptrusts, upl-filter, blocked_patterns, require_disclaimer, rewrite_to_educational, unauthorized practice of law, legal advice
- Config/command names:
policy.upl-filter,blocked_patterns,require_disclaimer,rewrite_to_educational - Best next pages: Legal Privilege, Financial Compliance, Human Oversight
For engineers
- Prerequisites: Review your jurisdiction's unauthorized practice of law standards. Default patterns cover common legal-advice-giving language.
- Validation: Send prompts that elicit legal advice and verify disclaimer injection or educational rewriting. Test
rewrite_to_educationalwith responses that contain directive legal language. - Key commands:
kt policy lint,kt policy test,kt events tail
For leaders
- Governance: UPL violations expose your organization to bar association complaints, injunctions, and liability. Any public-facing AI that discusses law must have UPL controls.
- Cost: Local pattern matching with no external calls. The legal risk of UPL violations (regulatory action, civil liability) far exceeds any prevention cost.
- Rollout: Enable
require_disclaimer: trueas the minimum baseline. Addrewrite_to_educational: truefor public-facing chatbots. Useblocked_patternsto catch jurisdiction-specific advice language.
Next steps
- Legal Privilege — Protect privileged communications
- Financial Compliance — Finance-specific compliance
- Human Oversight — Escalate borderline legal content
- Safety Filter — General content safety