Skip to content
Context docs
Build

Agent judge

An agent judge is a criterion graded by an agent that can open files, for answers a model can’t grade from text alone.

An LLM judge reads the agent’s answer as text. An agent judge is an agent of its own: it opens the files involved, looks through them, and then gives a pass or fail or a score. Use it when the answer is a file, such as a spreadsheet, a report or code, or when grading means comparing against an expected file.

You can use an agent judge in two places: as a criterion on a dataset, which grades benchmark runs, and as a shared criterion that a monitor binds, which grades live requests. Both need the task engine your deployment uses by default; see Criteria. The monitor version also needs monitoring, which your administrator turns on.

Pick a model

An agent judge runs only on models your deployment’s agents can run. List them:

TerminalCode
context evals models list --agent "$AGENT_ID" | jq -r '.judges.agentModels[].id'

A model that isn’t on this list is refused when you save, with a message that names it.

On a dataset

Give a dataset task expected files, and add an agent_judge criterion that compares the answer against them. Only an agent judge or a Python check can open expected files. While a dataset task has expected files, it and its dataset may carry only those kinds. Set the criteria first (criteria set replaces the whole set), then attach the file. Save this as criteria.json:

JSONCode
{ "definitions": [ { "name": "Totals match the expected workbook", "kind": "agent_judge", "weight": 2, "outputType": "boolean", "instructions": "Open the expected workbook and the workbook the agent made. Pass if every monthly total matches.", "modelOverride": "<provider>/<model>" } ] }
TerminalCode
context evals criteria set --dataset "$DATASET_ID" -f criteria.json

Then add a dataset task (the CLI calls it an item), upload the expected file and attach it:

TerminalCode
ITEM_ID=$(context evals datasets items create --dataset "$DATASET_ID" --prompt "Build the monthly refund workbook for October." | jq -r .id) FILE_ID=$(context evals file upload expected.xlsx --dataset "$DATASET_ID" --pick fileId) context evals datasets items update "$ITEM_ID" --expected-file-id "$FILE_ID"

Expected files are never shown to the agent being tested, and an LLM judge can’t be added while a dataset task has them.

The fields are the same as an llm_judge criterion, and outputType is boolean or float. modelOverride: null uses the benchmark’s judge model, but only if an agent judge can run it; otherwise saving is refused. A dataset you import can carry the same criterion as a Markdown file, with needs_files: true in its front matter.

Each agent judge runs a task of its own, so it is slower than an LLM judge and is charged like any other task. --judge-concurrency on evals benchmark run create sets how many run at once.

On a monitor

A monitor binds an agent judge from your organization’s shared library. An agent judge grades monitors that target an agent, a skill, an applet or traces. On workflow targets it does not run. Save it as refund-files.json:

JSONCode
{ "kind": "agent", "name": "Refund letter is complete", "instructions": "Open the letter the agent wrote. Pass if it names the order, the amount and the refund date.", "model": "<provider>/<model>", "outputType": "BOOLEAN", "python": false }
TerminalCode
BINDING=$(context evals criteria share -f refund-files.json --pick binding)

--pick binding prints {kind, criterionId, weight}; put it in the criteria list of your monitor file. Running share again with the same name updates the criterion instead of adding another. With outputType: "FLOAT", the judge gives a score from 0 to 1 that passes at passMark (default 0.7). Set python: true to let the judge run Python on a copy of the files; it can never change the originals or reach the network.

The judge works in the task’s own sandbox when the request ends, and has 10 minutes. It grades only tasks on the task engine your deployment uses by default. Its cost is charged to the monitor’s payer.

When a judge gives no verdict

A check with no verdict is left out of the score and reads as one of these, among others:

MessageWhat happened
Couldn’t be judged: the judge filed no verdict in its timeThe monitor’s judge ran out of time.
Files changed under the judge, so its verdict is not keptThe files changed while it was grading.
The next message arrived before the judge finished, so this turn was not gradedThe person kept the conversation going.
Couldn’t be judged: no agent judge was started for this requestThe request wasn’t sampled, the task wasn’t on the default task engine, or the monitor targets a workflow, where an agent judge does not run.