A moderation flag names a kind of harm, as a category with a score. Your flagsFor() from the last lesson raises one for each category whose score reaches its threshold.
A flag doesn’t say what the assistant should do. Course 3’s emergency check still runs first, so an emergency gets the rescue number alone and never reaches moderation. After it, if every flag gets the same refusal, a person in crisis is turned away, and nobody at the warden’s desk hears about a threat.
Key Points
- Each category gets its own action, in a table in your code that names each category exactly as your thresholds name it. A
self-harm/intentflag gets crisis resources instead of a refusal. The reply is a crisis line from config and a short supportive message, and the model isn’t called. A violence flag goes to a person at the warden’s desk, and harassment gets a short blocking message. How the handoff to the warden’s desk works comes later in the course. - None of the last lesson’s labeled warden threats reaches the desk. The English threat says “hurt”, so the emergency check sends it the rescue number alone. The German, Italian and French versions are flagged only for harassment and blocked. Save them with your known misses in
evals/adversarial/. - The first matching row wins. A row matches a flag with its category, and the rows are checked from top to bottom, so their order is the priority when a question raises two flags. None of these actions sends the question to the model. A flag with no row is blocked too, and a question with no flags goes to the model as usual.
- Routing a batch gives you a count per action. Eight July questions, with flags from your thresholds recorded on December 2, 2026, came out as four answered, and one each for the rescue number, crisis resources, a person and a block. A threat that raised both harassment and violence went to a person, because the violence row sits higher. Eight questions is a toy batch, but the same code routes a whole season.
- Moderation checks harm, not instructions. Two of the four answered questions were attacks. One told the assistant to ignore its instructions, and the other gave it a new role with no rules. Neither holds harmful content, so both passed untouched. Catching them takes checks in your own code, which the next section, Guarding Answers in Code, starts building.
Final Code
Like the rescue number, the crisis line comes from config.
guards/actions.js
export const ACTIONS = [
{ category: "self-harm/intent", action: "crisis" },
{ category: "violence", action: "person" },
{ category: "harassment", action: "block" },
];
export function chooseAction(flags) {
for (const row of ACTIONS) {
if (flags.some((f) => f.category === row.category)) {
return row.action;
}
}
return flags.length > 0 ? "block" : "answer";
}
A script runs the emergency check and then chooseAction() on each recorded question, and counts the actions. The script, scripts/route-batch.js, and the batch, data/july-batch.json, are in the code download. Run it with node scripts/route-batch.js, and its last line is the count:
{ answer: 4, rescue: 1, crisis: 1, person: 1, block: 1 }
Next, in Exercise: Set Moderation Thresholds, you’ll write the policy yourself, choosing a threshold and an action for each category and deciding what happens when the moderation call fails.