Classification.
Don’t ask a model to write. Ask it to decide.
A classification model reads its input once and answers fixed, typed questions: yes or no, one of a few choices, a score on a scale. It doesn’t write a reply. It puts a probability on every option and stops. That makes it fast, cheap, and easy to act on in code, because the answer is already a number.
The example is Cloudflare’s Clef, on Workers AI. Here it’s a tripwire in front of a coding agent: pick an instruction or write your own, and Clef decides whether the agent may go ahead, should ask a human, or must refuse. Nothing is ever executed. There is no agent behind this demo.
Live classification demo: the tripwire
- Decisions
- 0
- Allowance
- 5 of 5 decisions left this minute.5 left this minute
- Spent
- $0
- Executed
- nothing, ever
Instruction to the agent
261 / 600⌘/Ctrl + Enter sends
Clef Workers AI · four questions, one pass
Intent: no reading yet.
Reach: no reading yet.
Injection: no reading yet.
Approval: no reading yet.
Route plain code
- Proceed to the agent
- Ask a human to a reviewer
- Refuse blocked
The policy waits for Clef’s numbers. Five rules; the strictest one tripped decides.
The receipt nothing yet
Each decision asks Clef and Clef-flash the same four questions at the same moment. The server times both calls and prices them from the tokens they read. The bill lands here.
Your decisions newest first
Your decisions collect here. Try the hostile ones, then try to sneak one past.
How it's wired.
Four questions, two models, one rulebook- Request
Your press sends one
POSTto/api/concepts/classification/decisionswith the instruction as text. The Worker checks your allowance first, before any model is called, because every decision is a paid call. - Questions
Four questions go with it, and they never change: what the instruction really wants, whether it hides orders aimed at the agent, how far a mistake could reach, and whether a careful engineer would want to sign it off. Each one has a fixed type: a choice, a yes or no, or a score on a five-level rubric.
- Two models
Clef and Clef-flash get the same text and the same questions at the same moment, with
Promise.all. Each reads the text once and hands back a probability for every option. No words, no reasoning, nothing to parse but numbers. - Policy
The model doesn’t decide what happens. Five rules in plain code do, each one a number and a threshold. The strictest rule that trips picks the route. Clef’s answers decide; Clef-flash stands in only if Clef fails.
- Timing and cost
The server times each call with
performance.now()and prices it from the input tokens the model reports. Clef models bill input only: there’s no output text to pay for.
export const QUESTIONS = [
{ id: "intent", kind: "choice",
options: { read, change, destroy, exfiltrate } },
{ id: "injection", kind: "yes-no" },
{ id: "reach", kind: "score",
levels: REACH_LEVELS }, // 0 nothing … 4 customers
{ id: "approval", kind: "yes-no" },
];// the model gives numbers; code decides
export function decide(answers) {
const tripped = RULES
.filter((r) => r.measure(answers) >= r.threshold)
.sort(bySeverity);
return { route: tripped[0]?.route ?? "proceed", tripped };
}
// injection ≥ 0.5 → refuse · exfiltrate ≥ 0.4 → refuse
// destroy ≥ 0.3 · approval ≥ 0.5 · reach ≥ 2.5 → ask a humanWhen to reach for one.
A fixed question, asked often- Agent guardrails
- A cheap check in front of anything an agent is about to do, so the risky few go to a person and the rest go straight through.
- Support triage
- Which team, how urgent, is the customer angry, is it a refund. Typed answers you can route on, before anyone reads the ticket.
- Moderation against your own rubric
- Your rules, written as questions, with thresholds you set and can change without retraining anything.
- Routing before an expensive model
- Decide whether a request needs a large model at all, or which one, before you pay a large model to find out.
The small print.
What a probability doesn't promise- A probability isn’t a fact.
- 0.97 means the model is very sure, not that it’s right. Clef can be confidently wrong, which is why the bars show every option and not just the pick.
- The thresholds are policy, and you own them.
- Refuse at 0.5 for injection, ask a human at 0.3 for anything destructive: those are choices, written down in one file. Move them and the same numbers route differently.
- Classifiers can be fooled.
- Two of the presets hide an instruction, and Clef usually catches them. A patient attacker can phrase one it won’t. Try it. A tripwire is one layer, not the only one.
- You pay for the questions too.
- The billed tokens include the four questions and their option descriptions, not just your text. That’s why a short instruction still reads as a few hundred tokens.
- The limits are approximate.
- Your allowance and the site’s daily cap are counted in Workers KV, which has no atomic increment. Two decisions at the same instant can both slip under the line.
- Prices and speeds move.
- Costs use Cloudflare’s published Workers AI rates, checked 22 Nov 2026: $0.24 per million input tokens for Clef, $0.038 for Clef-flash. Cloudflare’s own benchmark puts their medians at about 209 ms and 39 ms. Here, measured from one Worker, either can be the faster on a given call.
- Clef-flash reads less.
- Its context window is smaller than Clef’s, so it suits short inputs on the request path. Long documents belong with Clef.