Rules
Define behavioral constraints and guidelines for your agents.
Rules are the governance layer of LensOS. They let you define behavioral boundaries, content policies, and response guidelines for your agents — without modifying application code.
How Rules Work
Rules are evaluated at runtime before and after each agent response. They can filter inputs, constrain outputs, and enforce compliance policies. Rules are applied in priority order, and you can combine multiple rules to create layered policies.
Rule Types
Content Rules
Control what topics and content your agent can discuss:
Example
{
"type": "content",
"action": "block",
"description": "Block discussions about competitors",
"patterns": ["competitor-name", "alternative-product"]
}Behavior Rules
Define how your agent should behave and respond:
- Response tone and formality level
- Language and localization preferences
- Citation and source requirements
- Response length constraints
Safety Rules
Built-in safety rules protect against common issues:
- PII detection and redaction
- Harmful content filtering
- Prompt injection protection
- Rate limiting per user
Managing Rules
Rules can be managed through the dashboard or the API:
API Example
await lens.rules.create({
name: 'concise-responses',
type: 'behavior',
description: 'Keep responses under 200 words',
priority: 10,
active: true,
})Tip
Use the dashboard's rule testing feature to preview how rules affect agent responses before deploying them to production.