Topic Restriction
Enforce on-topic conversations by defining valid and invalid topic lists.
Topic Restriction
The Topic Restriction provider enforces conversational boundaries by ensuring inputs and outputs stay within approved topics. Define what your agent should and should not discuss, and Nyraxis will flag off-topic content automatically.
What it detects
| Category | Examples |
|---|---|
| Off-topic inputs | User asking a customer support bot about stock trading |
| Invalid topic engagement | Agent responding to questions outside its domain |
| Scope violations | Conversations drifting into restricted subject areas |
Configuration
{
"policy_type": "topic_restriction",
"mode": "blocking",
"config": {
"valid_topics": ["billing", "account management", "product features", "technical support"],
"invalid_topics": ["politics", "investment advice", "medical advice", "legal counsel"]
}
}| Parameter | Type | Default | Description |
|---|---|---|---|
valid_topics | string[] | [] | Topics the agent is allowed to discuss. If set, anything outside this list is flagged. |
invalid_topics | string[] | [] | Topics the agent must never discuss. These are always flagged regardless of valid_topics. |
You can use valid_topics alone (allowlist approach), invalid_topics alone (blocklist approach), or both together for maximum control.
Example violation
{
"allowed": false,
"violations": [
{
"policy_type": "topic_restriction",
"severity": "medium",
"description": "Off-topic content detected: input relates to 'investment advice' which is restricted",
"detected_topic": "investment advice",
"restriction_type": "invalid_topic"
}
]
}Best practices
- Use
valid_topicsfor narrowly scoped agents (e.g., a billing bot should only discuss billing). - Use
invalid_topicsfor general-purpose agents that need a few hard boundaries. - Be specific with topic names — "medical diagnosis" is better than "health" if you still want to allow general wellness discussion.
- Start with
mode: "warning"to identify how often users go off-topic before enforcing blocks. - Review flagged conversations to refine your topic lists — overly broad restrictions frustrate users.