By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
A nightly job sends 4,000 support tickets through one instruction: Summarise this ticket and flag urgency. On Tuesday the model returns three tidy sentences. On Thursday it returns a single label. Your loader rejects both, then accepts a third shape on Friday. Nothing in your code changed, and the model did exactly what an open instruction allows.
You have a decision to make, and it is not about finding better words. You can keep repairing output downstream, or you can state the criteria the answer must satisfy before the model writes anything. That is what criteria-first prompting means. It is the difference between a prompt you can test and a prompt you can only hope for.
A criterion is a statement an answer can fail. Be helpful cannot fail, so it is not a criterion. Return one object with `summary` at 40 words or fewer and `severity` of low, medium or high can fail, and the model can check itself against it before it answers.
Four criteria cover most production prompts. The table shows the question each one answers and what it looks like for a support agent.
| Part | Question it answers | Support-agent example |
|---|---|---|
| Goal | What job is this call doing? | Classify the ticket and propose a first reply |
| Constraints | What must never happen? | Never promise a refund above $200 |
| Definition of done | What does a correct answer contain? | Fields: summary, severity, next_action |
| Failure cases | What should the model do when it cannot comply? | Return needs_human true, with a reason |
Write them as labelled lines, not as one long paragraph. A labelled line is something the model can point at, and something your tests can find later. Unlabelled prose invites the model to decide which parts matter.
You send each model call through the Messages API, and it gives you two places for text. The system prompt holds instructions that are true for every call. The user message holds the data for this one call. When your rules travel inside the user message, they compete with the ticket text for attention and they change shape as the ticket changes.
The split also decides cost. Stable text at the front of a request is the part a prompt cache can reuse, and a cache read costs less than fresh input. Rules that drift into the per-call data are paid for at full price every time. The split decides evaluation too: when all the criteria live in one place, one test suite can check them.
A criterion that only lives in prose is still a hope. Put the four parts in a small object and check it. The example below builds both messages from one criteria object, then reports which parts are missing.
from dataclasses import dataclass, field
@dataclass
class Criterion:
goal: str
constraints: list[str] = field(default_factory=list)
definition_of_done: list[str] = field(default_factory=list)
failure_cases: list[str] = field(default_factory=list)
def missing_parts(self) -> list[str]:
parts = {
"goal": self.goal.strip(),
"constraints": self.constraints,
"definition_of_done": self.definition_of_done,
"failure_cases": self.failure_cases,
}
return [name for name, value in parts.items() if not value]
def build_messages(criterion: Criterion, ticket: dict) -> dict:
system = [
f"GOAL: {criterion.goal}",
"CONSTRAINTS:",
*(f"- {line}" for line in criterion.constraints),
"DEFINITION OF DONE:",
*(f"- {line}" for line in criterion.definition_of_done),
"IF YOU CANNOT COMPLY:",
*(f"- {line}" for line in criterion.failure_cases),
]
user = f"Ticket {ticket['id']} (plan: {ticket['plan']})\n{ticket['text']}"
return {"system": "\n".join(system), "user": user}
criterion = Criterion(
goal="Classify the ticket and propose a first reply.",
constraints=["Never promise a refund above $200."],
definition_of_done=["Fields: summary, severity, next_action."],
failure_cases=["Return needs_human true when the order id is missing."],
)
ticket = {"id": "T-4471", "plan": "business", "text": "Charged twice for May."}
print(build_messages(criterion, ticket)["user"].splitlines()[0])
print(criterion.missing_parts())missing_parts is the cheapest test in this section. Run it in your test suite against the criteria object, and a prompt that loses its failure case fails the build instead of the loader.
Two habits keep a prompt honest: a failure case and an explicit output constraint. The failure case gives the model a legal way out, so it stops inventing an answer. The output constraint gives your parser something stable to read, so a bad answer is visible on arrival.
State output constraints as checks, not adjectives. Concise is an adjective. At most 40 words in `summary` is a check. Professional tone is an adjective. No competitor names is a check.
Take one prompt you already run in production and rewrite it as four labelled criteria. Then run three checks.
Criterion object and confirm missing_parts returns an empty list.If a check fails, the fix belongs in the criteria, not in a downstream regex. A regex that repairs a guess hides the bug you were paid to find.
Key takeaways
A criterion is a statement an answer can fail; adjectives are not criteria.
State four things: goal, constraints, definition of done, failure cases.
Stable rules go in the system prompt; this call's data goes in the user message.
Write output constraints as countable checks, not as adjectives.
A declared failure case is what stops the model from inventing an answer.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.