# AI judgement (/docs/nodes/ai-judgement)



The **AI judgement** node asks a model to judge something a rule cannot: the tone of a message, the category of a ticket, whether a statement holds. It returns **typed answers with a confidence**, so the flow can refuse to act on a shaky one.

## When to use it [#when-to-use-it]

* Classify free text: tickets, claims, messages.
* Add a judgement to a decision while keeping it auditable.

## How it works [#how-it-works]

<Diagram node="ai-judgement" kind="anatomy" />

1. The **state mapping** builds the text the model reads. Anything the model sees comes through here. An empty state fails the node.
2. The model answers each **question**. There are five types: `noul` (does a statement hold, yes or no), `choice` (pick one option from a list), `score` (a position on a rubric), `json` (an object with a shape you declare) and `text` (free text, see below).
3. Each answer is stored as `{ type, value, answered, confidence, ... }`. A question the model did not answer is kept as `answered: false` instead of disappearing.

## Free-text answers [#free-text-answers]

A `text` question returns plain prose instead of a typed value: a custom comment on the output, or the reason a result came out the way it did, in natural language. It is read as `vars.judge.why.value`, a string.

* It is only available with the **OpenAI** and **Anthropic** providers. TypeSafe answers typed questions only, so a text question on it is an error in Checks and blocks publishing.
* It carries no confidence, so there is nothing to branch on. Use it for what a person reads (an explanation, a note on the response), and keep routing on the typed questions.

## Ports [#ports]

| Port      | Taken when                                                                                                                                                 |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Success` | The model answered.                                                                                                                                        |
| `Error`   | The call failed and the node is set to continue with a fallback. If Error is not connected, the run carries on through Success with the fallback in place. |

## Configuration [#configuration]

| Field                         | What it does                                                                                                                       |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| Name                          | Label shown on the canvas and in the trace.                                                                                        |
| State                         | The expression that builds the text to judge.                                                                                      |
| Questions                     | An id, a type and the instructions for each. Choice questions list options; score questions list rubric levels, lowest to highest. |
| Model                         | Optional model alias. Defaults to the adapter's default.                                                                           |
| Credential                    | The stored credential used to reach the provider.                                                                                  |
| Timeout, retries, on error    | Same reliability settings as an API call. A fallback keeps the flow going.                                                         |
| Record the state in the trace | Off by default, because the state usually carries personal data.                                                                   |

## What it writes [#what-it-writes]

One object under your variable (`ai` by default), with one entry per question: `vars.judge.category.value`, `vars.judge.category.confidence`. The trace marks the step `deterministic: false` and stores a fingerprint of the state so a replay can tell whether the same text went in.

## In a real flow [#in-a-real-flow]

<Diagram node="ai-judgement" kind="example" />

The ticket text is classified. A condition acts on the answer only when the confidence is high enough; otherwise, or when the model fails, a person reviews it.

## When it fails [#when-it-fails]

* The model cannot answer, times out or is disabled: the run fails (`AI_FAILED`, `UPSTREAM_TIMEOUT`, `AI_DISABLED`), unless on-error is set to continue with a fallback.
* No state, no questions, duplicate question ids, a choice without options or a score without rubric are errors in Checks.

## Good to know [#good-to-know]

* A model asked twice may answer differently. This is the one node where a run is not reproducible, which is why the answer is recorded as data.
* Branch on `confidence` to stay honest about a low-quality judgement.

## Related [#related]

* [The trace](/docs/concepts/trace)
* [API call](/docs/nodes/api-call)
