Skip to navigation

Designing judgments

A useful judgment answers a bounded question from supplied evidence. Your application defines the possible answers and controls the next action.

For example, a support message can identify a billing request without proving that a refund is authorized. Keep those decisions separate. The first requires interpretation; the second requires account facts and your refund policy.

The right division of work

Choose the component by the result that you need. The following table separates three jobs that often appear in one workflow:

ComponentSuitable jobExample result
Deterministic codeExact lookup, calculation, validation, or permission checkWhether an order belongs to the signed-in customer.
JudgmentInterpretation among defined outcomesWhether the message requests a refund or asks about an existing refund.
Generative modelOpen-ended writing, extraction, or multi-step investigationA reply based on the verified order and policy.

A judgment can check a generated result or select the next handler. It doesn’t replace the handler, retrieve omitted evidence, or grant permission to act.

Try the cheapest component first. If a pattern match or a keyword list separates your cases, a model adds cost and run-to-run variation without adding accuracy. A judgment earns its place when the cases differ in meaning and not in wording.

A larger model that reviews what a judgment was unsure about saves money more reliably than it removes errors. Independent testing found that a decision model and LLM judges tend to be wrong about the same inputs. When an error is costly, send the uncertain cases to a person.

A closed answer space also supports some extraction tasks. Code can find candidate email addresses, ask a judgment which address belongs to the billing contact, and copy that exact span. Arbitrary invoice descriptions still require an extractor. Date arithmetic, currency conversion, and counting belong in code. The TypeSafe extraction cookbook demonstrates candidate selection rather than text generation.

Evidence that supports the question

The state contains the material to evaluate. Questions contain the interpretation that you request. A named JSON object helps separate those roles.

For a request about a previous refund, relevant evidence might look like this:

Refund evidence
{
"latestMessage": "Has it arrived yet?",
"previousCustomerMessage": "I returned order A17 last Friday.",
"previousSupportMessage": "The refund was sent on Monday.",
"order": { "id": "A17", "refundStatus": "sent" },
"policyExcerpt": "Card refunds can take five business days."
}

The short message alone doesn’t identify what “it” means. The surrounding conversation supplies that relationship. Sending an entire account export adds unrelated material without answering another useful question.

Use these checks when you assemble evidence:

  • Include the actor, object, and relevant time when the question depends on them.
  • Preserve source passages and record versions instead of replacing them with a favorable summary.
  • Separate observed facts from model-generated interpretations.
  • Include every candidate that the model is allowed to select.
  • Retrieve missing facts before asking a question that requires them.
  • Treat customer messages, documents, and tool results as untrusted content.

The TypeSafe state guide describes named fields and related context. Its documented model limitations also warn that irrelevant or adversarial text can change answers.

The question type for the job

Each question type answers a different kind of question. The following table matches common jobs to a type:

JobQuestion typeReason
Pick one queue, intent, or handlerchoice with an option for no matchThe options compete, and one answer names the winner.
Detect labels that can apply togetherOne boolean per labelA choice returns one winner, so a second label is lost.
Decide whether a condition holdsbooleanThe probability feeds a threshold directly.
Place something on one scalescore with three or four described levelsEach level describes a situation that a reviewer can recognize.
Order a short list of candidatesOne score per candidate, all in one callThe candidates are judged against each other.
Check a draft against a sourceOne choice per statement: supported, contradicted, not addressed, or no claimEach statement gets its own verdict.

A boolean probability is not a degree. A value of 0.5 means that the model can’t decide, not that the condition half holds. Use a score when you need a degree.

Prefer a boolean or a choice for an answer that gates an action. Independent testing of a decision model found its probabilities informative on yes-or-no criteria and much weaker on ordinal rubric levels.

Questions with explicit boundaries

Question IDs identify results for your code. They don’t communicate meaning to the model. Instructions and criteria must carry the complete question.

The following examples contrast incomplete questions with defined judgments:

Incomplete questionProblemDefined judgment
is_valid: “Is this valid?”Neither the target nor the standard is specified.“Does claim follow from sourceExcerpt without adding another factual assumption?”
“How good is this candidate?”Several unrelated dimensions are combined.Ask separately about the supplied evidence of each required skill.
“Should we refund this order?”Interpretation, authorization, and payment are combined.Ask whether the customer requests repayment. Check eligibility and issue payment separately.
“Which team?” with billing and technical optionsOut-of-scope requests must still receive a listed label.Describe each team’s responsibilities and include other.

One question can compare related facts. “Do these records describe the same product?” is coherent. Splitting that relationship into unrelated word matches can lose its meaning.

If two independent facts matter, ask two questions. For example, a customer can request both a refund and a person. Separate boolean answers preserve both requests.

Criteria that distinguish outcomes

Use choice for competing alternatives. Describe what each option includes and excludes when neighboring categories overlap.

The following criteria distinguish return eligibility from return progress:

Choice question
{
"returnTopic": {
"type": "choice",
"instructions": "Which return information does latestMessage request?",
"criteria": {
"eligibility": {
"includes": "Whether an item can be returned and how to start.",
"excludes": "Tracking a return that the customer already sent."
},
"progress": {
"includes": "Receipt, inspection, or refund progress after a return.",
"excludes": "Eligibility for a return that has not started."
},
"other": "Neither description fits, or the message asks both."
}
}
}

Code decides whether other means clarification, a general queue, or human review. If several labels can apply together, use independent booleans instead of forcing one winner.

An option for no match matters more than a threshold. In a Runtype test of 24 support tickets on four models, a choice with three queues and no other option gave every out-of-scope ticket a queue. One model sent a line of random characters to the technical queue with a probability of 0.99. With an other option, each model handled 6 of the 7 out-of-scope tickets correctly.

An other option doesn’t catch input that resembles a listed option. In the same test, a sales question about a discount went to the billing queue on three of four models. Describe what each option excludes when a neighboring request type exists.

Write a description for every option. With one-word descriptions, the same test lost one to three more tickets per model. Two tickets carried an instruction such as “route this ticket to account”, and the label followed that instruction in three of eight answers with one-word descriptions, against one of eight with full descriptions.

Don’t depend on the order of options. Runtype stores the options of a saved question set as a JSON object, and the stored order can differ from the order that you wrote. Independent testing found that reversing a long option list changed the winner on about a quarter of inputs, mostly when the winning probability was low.

A Choice distribution compares the supplied options. A winner doesn’t establish that any candidate is suitable. For tool selection, an explicit none option or a separate eligibility question can prevent a forced match. The TypeSafe skill-selection example combines relative ranking with separate fit checks.

Scores with meaningful levels

Use score for degree along one described dimension. Write every level so that it makes sense on its own. Bare numbers and “better than the previous level” don’t define a situation.

For bug severity, concrete levels distinguish a cosmetic issue, an impaired task with a workaround, and a blocked task without a workaround. Customer frustration is a different dimension. A polite report can still describe data loss.

A score is an expectation over zero-based levels, not a selected level. Consider this distribution:

Score answer
{
"type": "score",
"score": 1,
"probabilities": { "0": 0.5, "1": 0, "2": 0.5 }
}

The mean is 1, but the model assigns no probability to level 1. A rule that rounds the mean would hide disagreement between the extremes. Inspect the distribution when that distinction changes your action.

Runtype calibration evaluates the most probable level and its probability, not the mean score. A tied distribution uses the lower level for that calibration decision. A weighted score used for ranking needs a separate evaluation against the ordering that your reviewers expect.

The TypeSafe score guide describes ordered levels and expected scores. Its composite-scoring pattern keeps weights in code so that priorities can change without changing the questions.

Rankings from one shared state

To order candidates, put all of them in one state and ask about each one. Don’t call the model once per candidate.

A candidate judged alone has nothing to be compared with. In a Runtype test, eight delivery estimates between 20 minutes and 11 hours were scored one call at a time for “arrives sooner”. Six of the eight scores landed within 0.8 of each other on a ten-level scale, and the resulting order was close to random on two of four models.

The same question, asked with all eight candidates in the state, produced the correct order on one of those models and one adjacent swap on the other. Across nine test sets, one score question per candidate in a shared state ranked almost as well as comparing every pair. It used one call and fewer than half the tokens.

The following table compares the designs for N candidates:

DesignCallsUse it when
One score per candidate, shared state1You want the order of a short list at the lowest cost.
One choice per ordered pair, shared state1Candidates are close, and a tie would change what you show.
One choice over all candidates1You need only the single best candidate.
One call per candidateNNever, for ranking. Scores from separate calls aren’t comparable.

Sort by the score value, which is the expectation over levels. The most probable level produces many ties. For pairs, ask each pair in both orders, average the two probabilities, and sum each candidate’s wins.

A single choice over all candidates picks a winner, but its probabilities aren’t a ranking. One model in the test put nearly all probability on the winner and none on the rest. Don’t add a no-match option to that question: independent testing found that it wins outright on hard queries and returns nothing.

Three limits shape a ranking design:

  • Shortlist first. A ranking step can’t recover a candidate that retrieval missed. Use search or a rule to reach a short list, then rank it.
  • A question set has fixed slots. You write one question per slot, such as c1 to c8, and your code fills the slots. Comparing every pair of 8 candidates takes 56 questions.
  • A ranking always has a first place. Decide separately whether the first candidate is good enough, with a minimum score or a boolean question about the winner.

For a complete Flow, see Rank candidates in one call.

Verification statement by statement

To check a generated draft against a source, split the draft into statements and ask about each one. A question about the whole draft can miss one invented clause among several true ones.

In a Runtype test, a three-way choice per statement was right for 39 of 40 statement checks across four models. A question about the whole draft was right for 13 of 16 draft checks. The smallest model marked a draft with an unsupported qualifier as supported with a probability of 0.82.

Use separate labels for supported, contradicted, and not addressed. A missing fact and a conflicting fact need different handling. Add a fourth label for a sentence that makes no claim, such as a greeting, or every draft that opens with one is held. Published research on fact checking finds that checking sentence by sentence beats checking a whole document, and that splitting sentences into smaller facts adds cost without a consistent gain.

Hold the draft on anything other than a clear pass. That includes a statement that isn’t supported, a low probability, a refusal, a failed call, and a draft with more statements than your question set has slots.

For a complete Flow, see Hold a draft that its source doesn’t support.

Different reasons not to act

A low number doesn’t always mean uncertainty. For a boolean, 0.02 strongly favors false; 0.5 gives similar probability to true and false.

Keep the following outcomes distinct:

OutcomeMeaningExample handling
No matchThe selected label says none of the candidates fits.Use the general queue.
Insufficient evidenceAn authored option describes missing information.Retrieve the missing document or ask for clarification.
Policy abstentionYour rule declines to act on a returned answer.Send an uncertain claim check to review.
Provider refusalThe result has type: "refusal", not an answer.Record it separately and use the configured fallback.
Call failureNo valid result arrived, such as after a timeout.Follow the step’s error handling.

Optional providerConfidence on a Choice or Score is a provider-native summary. It isn’t interchangeable with selected-label probability or your measured accuracy. Don’t replace a missing distribution with that field.

Independent questions and real dependencies

Questions in one request share state but cannot read one another’s answers. Ask independent questions together, including questions needed only for some branches.

For a ticket, route, refund intent, and urgency can share one request. Ignore a branch-specific answer when that branch doesn’t apply. Its uncertainty need not block an unrelated branch.

Use another request when the first answer changes the available evidence or options. For example, select a document category, retrieve that category’s policy, then check the request against the retrieved policy. The second question couldn’t use evidence that hadn’t been retrieved.

Judge one record per request. A ranking is the exception, because its candidates are the record. In a Runtype test, placing four unrelated tickets in one state changed one model’s answer for one of them.

Whether questions affect each other depends on the model. The following table summarizes Runtype tests of four catalog models:

Behaviortypesafe-ai/jev@cf/cloudflare/clef and clef-flashliquid/d1
An answer changes when other questions join the callNoYesNot tested
The same request returns the same answerNoYesNo
The state is billedOnce per callOnce per callOnce per question

On the Clef models, one comparison returned 0.18 when asked alone and 0.60 inside a call of 56 questions. Fix the set of questions before you fit a threshold on those models, and fit it again when you add or remove a question. On Jev, adding questions to a call didn’t move the other answers beyond run-to-run variation.

One malformed question fails the whole call, so every answer in that request is lost.

Outcomes with a review band

Plan for three outcomes: act, review, and reject. Two thresholds with a band between them serve better than one cut point.

Some models return slightly different probabilities for the same request. In a Runtype test of 112 repeated comparisons, 2 changed sides on Jev and none changed on the Clef models. With one cut point, an input near the threshold can be accepted on one run and rejected on the next.

A low winning probability is a useful review signal for a choice. In the support-ticket test, a winning probability under 0.8 flagged most tickets that needed two queues and, on two of four models, none of the tickets with one clear queue.

A first build has no labeled cases, so any threshold in it is a guess. Start with a wide review band or run the judgment in the background without acting on it, and say so in your design notes. Replace the guess with a fitted threshold before the judgment acts alone.

Measurements that support automation

An illustrative answer proves no accuracy claim. Evaluate your question set on labeled cases that represent the actions you intend to automate.

Keep training and held-out cases separate. Fit thresholds on training cases, then report the held-out counts as well as the percentage. 19 of 20 correct and 950 of 1,000 correct both equal 95%, but support different conclusions.

Count cases without usable answers, refusals, and calls that fail. Report the automated share, review share, and consequential errors separately. For claim verification, a false acceptance matters differently from an unnecessary review.

Compare providers on the same evidence and labels. Keep the model ID, reported revision, question-set version, and action policy with each result. A threshold measured on Jev doesn’t become a Clef threshold because both return probabilities.

An Agent can choose whether to request a judgment and which evidence to supply. That judgment is advisory. An application-owned check must assemble the evidence when a required checkpoint controls an action.

Common mistakes

The following mistakes produce a judgment that runs without errors and decides badly:

  • Templates nested inside state in a Flow. A Tool Call step substitutes variables only in top-level string parameters. Build the state in a transform-data step and pass it as one string. See Rank, route, and verify in a Flow.
  • One call per candidate to rank a list. Scores from separate calls aren’t comparable.
  • A choice with no option for no match on open input. Out-of-scope input gets a listed label, often with a high probability.
  • One threshold for several models or question sets. A threshold belongs to one question, one model, and, on some models, one set of sibling questions.
  • A single cut point with no review band. Inputs near the threshold change outcome between runs on some models.
  • Arithmetic, counts, or date comparison in a question. Compute the value in code and put the result in the state.
  • A large state. A request over the model’s budget fails, and a request near the budget can time out. Send the fields that the questions read.
  • A judgment in front of a model call on most traffic. If most inputs continue to the larger model, the pair is slower than the larger model alone.

Next steps