The rule text you write determines how accurately an input guardrail blocks the right messages. A specific, focused rule trains a reliable classifier. A broad or vague rule produces false positives, false negatives, or a training failure. Use the tips, templates, and examples in this article to write rules that enforce your policy without frustrating users. Enter these rules when you create a guardrail.
Opal decomposes each rule into a maximum of five atomic policies and trains a classifier for each one. Rules that describe both what to block and what to allow help the classifier handle borderline messages.
Tips for writing effective rules
Keep the following in mind when writing your rules:
- Be specific about what to block and what to allow. Including both helps the classifier distinguish borderline cases.
- Use concrete examples of the messages to block, such as compare our product with competitors rather than off-topic messages.
- Keep each guardrail focused on one concern. Broad rules that decompose into more than five policies fail training.
- Test your guardrail with edge cases before you activate it. Messages close to the boundary are the most important to test.
Rule templates
Start from a template and customize the rule text for your organization. Replace placeholder values such as PRODUCT_A with your own products or topics.
| Template | Example rule text | Use case |
|---|---|---|
| Topic scoping | Only answer questions about our products: PRODUCT_A, PRODUCT_B, and PRODUCT_C. Block any questions unrelated to these products. | Customer-facing chatbot limited to specific product lines |
| Off-topic filtering | Block questions about weather, sports scores, general trivia, cooking recipes, or any topic unrelated to business operations. | Internal assistant focused on work-related queries |
| Medical or legal advice | Block any request for medical advice, health diagnoses, legal counsel, or financial investment recommendations. | Compliance-restricted environments |
| Personally identifiable information (PII) protection | Block messages that contain or request social security numbers, credit card numbers, passwords, or other PII. | Data-sensitive environments |
| Professional language | Block messages that contain profanity, hate speech, discriminatory language, or threats. | Any customer-facing or workplace deployment |
Example rules
The following examples expand on the templates with a full configuration for common marketing scenarios. Each example includes a name, rule text, and a block message. Adapt them to fit your organization's needs.
Keep the agent focused on your company
Use this rule for an agent that answers questions about your website, products, or company, when you want to prevent unrelated questions.
- Name – On-topic only
- Rule text – Block messages that ask about topics unrelated to our company, our products, our services, or our website content. The agent should only answer questions about our organization and what we offer. Block requests for general knowledge, personal advice, homework help, coding assistance, or other topics that have nothing to do with our business.
- Block message – This assistant is designed to answer questions about our company and products. For other topics, use a general-purpose assistant.
Protect customer case study confidentiality
Use this rule for an agent with access to customer case studies, when you want to prevent users from sharing confidential details or drafting unauthorized content.
- Name – Case study boundaries
- Rule text – Block messages that ask the agent to share raw customer data, revenue figures, or internal metrics from case studies. Block requests to draft external-facing content such as blog posts, press releases, or social media posts that reference specific customer results without mentioning they need approval. Allow questions that ask for general learnings, strategy summaries, or anonymized takeaways from case studies.
- Block message – I can share general learnings from our case studies, but specific customer data and metrics require approval before external use. Contact the content team for authorized case study materials.
Prevent competitor analysis requests
Use this rule to prevent competitive intelligence and product comparison requests.
- Name – No competitor discussions
- Rule text – Block any message that asks the agent to compare our products or services with a competitor, analyze a competitor's pricing, features, or strategy, or provide recommendations on how to position against a specific competitor. Allow general questions about our own product capabilities and market positioning without reference to named competitors.
- Block message – Competitive analysis requests are handled by the product marketing team. Reach out to them directly for competitor comparisons and positioning guidance.
Block pricing and discount commitments
Use this rule to prevent the agent from generating pricing quotes or promising discounts that need sales team approval.
- Name – No pricing commitments
- Rule text – Block messages that ask the agent to generate a price quote, offer a discount, calculate custom pricing, or commit to any pricing terms on behalf of the company. Block requests to draft pricing proposals or negotiate rates. Allow general questions about publicly available pricing tiers and plan features.
- Block message – I cannot provide custom pricing or discounts. Contact your account manager or the sales team for pricing discussions.
Restrict an agent to marketing scope
Use this rule for a marketing-specific agent, to keep it from answering questions about engineering, HR, finance, or other departments.
- Name – Marketing scope only
- Rule text – Block messages that ask about engineering roadmaps, technical implementation details, HR policies, hiring processes, employee benefits, financial results, accounting processes, or legal and compliance matters. This agent is scoped to marketing topics including campaigns, content strategy, brand guidelines, audience segmentation, analytics, and marketing operations. Allow questions about marketing technology and integrations used by the marketing team.
- Block message – This assistant covers marketing topics only. For engineering, HR, finance, or legal questions, reach out to the relevant team or use their dedicated resources.
Article is closed for comments.