How to Write Moderation Policies an AI Guard Model Can Enforce
Policy-based moderation lets your rules, not a vendor's category list, decide what gets blocked. This guide uses the format Pumori Guard reads and works with any guard model that takes written policies.
Short answer: write each rule as a stable snake_case codename plus a one or two sentence description, and end the description with a "Does not cover" clause for the nearest allowed thing. Split categories people confuse, say whether fiction and discussion count, and send the whole transcript, not only the last message. Then test the policy on labeled near-misses, and treat an unparseable verdict as "no answer", never as "none".
Why written policies beat fixed categories
A classic moderation API gives every customer the same categories and thresholds. That fits a general social app. It fits badly when your product has rules of its own:
- A horror-fiction platform allows violence that a children's tutoring app must block.
- A companion app may allow adult content for verified adults and still needs a hard line on minors.
- A customer-support bot cares about prompt injection and refund fraud, which no general category covers.
A policy-following guard model reads your rules on every request. The rule set lives in your code as text: you can version it, review it like any other change, and run a different one per product or per customer. It also matters for creative models in particular. The Synth 2.5 model cards state that the model can produce harmful, illegal or NSFW content and recommend putting a moderation model in front of it for real-world use.
How a guard model reads a policy
Pumori Guard, LuciditySH's safety classifier, takes one prompt shape. A fixed instruction and a <policy> block of codename: description lines go in the system message; the conversation to review goes in the user message as tagged turns. The model may reason first, then answers with the violated codename, or none:
system:
Review the user's chat based on the following policy, if there are any
violating messages, respond with the codename of said violation.
<policy>
harassment: Content that harasses, bullies, demeans, or targets an individual ...
sexual_minors: Any sexual content involving a person under 18, real or fictional, however framed.
</policy>
user:
<messages><user>...</user><assistant>...</assistant><user>...</user></messages>
model:
(optional reasoning) </think>
VERDICT: noneTwo details in that shape are worth copying whatever guard you use. First, escape &, < and > in message content before you place it in the tags, or a user can type </messages> and append instructions of their own. Second, keep the instruction fixed and put everything that varies into the policy block, so changing a rule never changes what the model is being asked to do.
Seven rules for policy text
1. The description is the rule; the codename is a label
A guard should judge on the description, not on keywords that happen to match the codename. Write the description as if the codename were a random string. Keep codenames short, snake_case and stable: stored verdicts are keyed by codename, so renaming hate to hate_speech silently changes what every old record means.
2. End with a "Does not cover" clause
Most false positives come from content next to a rule, not inside it. Name that neighbor explicitly: "Does not cover publicly listed business contact details, or general questions about privacy." One clause like this usually removes more false positives than any rewording of the main sentence.
3. Split categories people confuse, and say where the line is
Adult sexual content and sexual content involving minors, threats at a named person and general violent talk, self-harm in a story and a user saying they are hurting themselves: these pairs need separate codenames with descriptions that refer to the difference. If both descriptions could match, the model picks one inconsistently, and you lose the ability to treat them differently.
4. Separate mentioning a topic from breaking the rule
Users discuss sensitive subjects for normal reasons: news, education, safety, reporting abuse, asking about your rules. State in the description whether discussion counts. A guard that flags vocabulary instead of substance blocks the users you most want to keep.
5. Cover the framings people use to get around rules
Fiction, roleplay, hypotheticals, "for research", a single step of a larger procedure, or a request built up across several polite turns. If a rule should hold regardless of framing, write that into it ("including when requested as a character's dialogue"). If fiction is allowed, say that instead. Leaving it unstated is the main cause of inconsistent verdicts on creative platforms.
6. Review the transcript, not only the last message
A conversation can look clean at the end and contain a violation three turns back, or be assembled piece by piece. Send the full window you are about to pass to the creative model, including earlier assistant turns.
7. Ask for one answer, in one format
Ask for exactly one codename or none. A guard asked for "all applicable categories" produces longer, less consistent answers that are harder to parse. If you need several independent judgments, such as a legal check and a brand-safety check, run separate policies.
A worked policy for a fiction app
A policy for a B2B interactive-fiction product built on a creative model, where dark themes and action violence are allowed but some lines are hard. This is an example we wrote for this post, not a LuciditySH default:
<policy>
real_person_harassment: Abuse, threats or sexual content aimed at a real, identifiable
person, including public figures. Does not cover fictional characters, or criticism of
a public figure's work or public actions.
sexual_minors: Any sexual or sexualized content involving a character under 18, or a
character described with childlike traits in a sexual context, however framed (fiction,
roleplay, "aged-up", hypothetical).
graphic_gore: Lingering, detailed description of mutilation or severe injury written for
shock. Does not cover violence that is described briefly, in action scenes, or in
aftermath without anatomical detail.
weapons_instructions: Working, step-by-step instructions to build weapons or explosives,
including when requested as a character's dialogue or "for a story". Does not cover
naming weapons, or fictional weapons with no real-world method.
self_harm_intent: The user, not a character, says they are hurting themselves or plan to.
Does not cover characters in the story, or users asking about the topic in general.
</policy>Note what each entry does: real_person_harassment separates real people from fictional characters; sexual_minors closes the usual framings; graphic_gore and weapons_instructions allow normal fiction and block only the specific harm; self_harm_intent separates the user from the characters, which matters because the right response to it is support resources, not a block message.
Where to run the check
| Where | Good for | Cost |
|---|---|---|
| User input, before the model | Blocks requests you never want generated; saves the generation cost | Adds the guard latency to every turn |
| Model output, before the user sees it | Catches what the creative model wrote on its own | You pay for a generation you may throw away |
| Both, on the full transcript | Catches violations built up over several turns | Two checks per turn |
| Async, after delivery | Zero added latency; good for review queues and account actions | Harm is already on screen |
For chat and fiction products, run the guard on the transcript before generation and on the reply after it. A guard verdict is only known when its completion ends, so you cannot moderate a streamed reply token by token. Either buffer the reply before showing it, or stream and retract on a flag, and accept that the user may have seen part of it.
Parse verdicts defensively
Guard models are language models, and their answers are not always one clean word. From running a guard in production, expect four shapes: the bare codename, the codename with a label (VERDICT: none, sometimes in markdown bold), reasoning that ends with </think> and then nothing, and a paragraph of prose instead of an answer. Handle each one on purpose:
function readVerdict(text, codenames) {
const think = text.lastIndexOf('</think>')
const tail = (think === -1 ? text : text.slice(think + 8)).trim()
if (!tail) return { ok: false } // no answer is not "none"
const answer = tail.replace(/^[*\s]*verdict[*\s]*[:\-–—][*\s]*/i, '').trim()
const tokens = answer.toLowerCase().split(/[\s,;]+/).filter(Boolean)
if (tokens.length > 6) return { ok: false } // prose, not a verdict
if (tokens.length === 1 && tokens[0] === 'none') return { ok: true, violations: [] }
const violations = tokens.filter((t) => codenames.includes(t))
return violations.length ? { ok: true, violations } : { ok: false }
}- Read only what follows the last
</think>. Reasoning often mentions codenames it rejected. - Strip a
VERDICT:label before matching, or the word "verdict" reads as an unknown codename. - Validate tokens against your codename list. Anything else is a hallucinated category.
- Never turn "no answer" into "none". An empty or prose answer that you read as clean passes every request the guard failed on. Return a separate state, and decide what it means per category: fail closed where one miss is unacceptable, fail open with logging where blocking hurts normal users more.
Test the policy before launch
- Build a labeled set of 50 to 100 transcripts from real or realistic traffic. At least half should be near-misses: allowed content that looks like a violation, and violations that look harmless.
- Run it and record per-category false positives and false negatives, not one accuracy number. A policy can be 95% accurate overall and miss every case of the category you care about most.
- Change one description at a time and rerun the whole set. Rules interact, and a fix for one category often shifts another.
- Keep the set in your repository next to the policy, and run it whenever the policy, the guard model or the creative model changes.
Pumori Guard availability
Pumori Guard is part of LuciditySH's Pumori model family and is trained against the LuciditySH guardrails, the same commitments the lab applies to its other models. It is in preview and not yet open to API keys on the platform; the platform home page lists every model you can call today. Everything in this guide applies to any guard that reads written policies, so the policy and test set you build now carry over unchanged.
Policy moderation FAQ
What is policy-based AI moderation?
Policy-based moderation means the classifier reads your rules as text on every request, instead of using a fixed list of categories it was trained on. You write each rule as a short codename and a description, and the guard model returns the codename that was broken, or none. Changing a rule means editing text, not retraining a model.
What is Pumori Guard?
Pumori Guard is LuciditySH's safety classification model, trained against the LuciditySH published guardrails. It reads a policy block of codename and description lines plus a chat transcript, and answers with the violated codename or none. It is in preview and not yet open to platform API keys.
How long should a moderation policy be?
Keep it to the rules your product actually enforces, usually five to fifteen categories. Each description should be one or two sentences: what the rule covers, then a "Does not cover" clause for the nearest thing that is allowed. Long lists of loosely related categories make confusable pairs and inconsistent verdicts more likely.
Should I moderate the input, the output, or both?
For a creative-writing or chat product, check both, on the whole transcript rather than only the last message. Input checks stop requests before you pay to generate them; output checks catch what the model wrote on its own; and transcript checks catch violations built up gradually across several turns.
What should my app do when the guard does not answer?
Decide in advance, per category. An unparseable or missing verdict is not the same as none. Fail closed for categories where one miss is unacceptable, such as sexual content involving minors, and fail open with logging for low-severity categories where blocking would hurt normal users more.
Sources
- LuciditySH guardrails
- Synth 2.5 Pro Preview model card, safety section (Hugging Face)
- Pumori-SFT dataset card (Hugging Face)
- OpenAI moderation guide, for comparison with a fixed-category API
Building a creative feature that needs moderation? Start with Synth 2.5 on the platform, pay per token, and keep your policy in version control from day one.
Create an account