Skip to content
Search docs
Search the docs and jump to the section
Sign in

Scores

A judge answers a workspace's question about a sample of its finished runs, pass or fail, and the results are shown. A run can finish as done while its setup is broken (known limits); a score is a signal about how a run went beyond its final status.

Definitions

A score definition (observability.score_definitions, per workspace under row-level security) has:

  • Name and question: a yes-or-no question about one run, in plain language. Yes is a pass.
  • Scope: every run, or the runs of one agent, workflow or factory. An agent's runs are its own runs, workflow runs with a step it does, and its turns as a factory member (in_scope in packages/db/src/scores.ts).
  • Sample: 0 to 100% of the runs in scope.
  • On or off.

Every workspace is given two built-in definitions the first time its scores are read or one of its runs finishes (builtin_scores in packages/domain/src/scores.ts), each at 25% and on. They can be edited or switched off, not deleted:

NameQuestion
Did what was askedDid the run do what was asked, as the person who asked for it would judge the result? Then, for a team room: staying quiet when told the message is not for it, or handing work to members when asked to coordinate them, counts; only saying work is pending, when an answer was asked for, does not.
Reported its problemsDid the run report every failing tool, missing access or wrong instruction it met, instead of quietly working around it? Yes if it met none.

Changing a definition or scoring past runs needs the configure:settings permission; seeing scores needs view:run. Each save is a score.saved audit event and each request to score past runs a score.backfill_queued event (the name, scope kind, sample and on or off; not the question).

When a run is scored

  • When it finishes as done or failed (never cancelled, and never a factory member's turn that only read a message it was not sent): the worker, after the run's result is committed (finish in packages/runtime/src/run/finish.ts), queues the run for each enabled definition whose scope it is in and whose sample takes it (queue_run_scores in packages/runtime/src/scores/queue.ts).
  • Sampling is a hash of the run's ID and the definition's ID compared with the rate (score_sampled in packages/rules/src/scores.ts), so a retried or re-claimed run gets the same answer and two definitions sample different runs.
  • Past runs: "Score the last N runs" on a definition (N up to 200) queues its last N scorable runs in scope, whatever the sample. Runs that already have a verdict are skipped; runs that could not be scored are tried again. The web app only inserts queue rows; it never opens a key.
  • Once per run and definition: run_scores has one row per run and definition and is both the queue and the results. Queuing again does nothing, and a verdict is stored only on a row that is still queued, so the first verdict stands.
  • Judging is a second loop in every worker (start_scoring in packages/runtime/src/scores/loop.ts), one score at a time, woken by the run_scores_queued notification and a 60-second poll. It claims a row across workspaces through claim_next_run_score (SECURITY DEFINER, as claim_next_run is) with a 5-minute lease, so a score whose worker died is claimed again. It never touches the run.

The judge

classify@1, the workspace's bound classifier, called with the bound connection's own key (workspace_judge in packages/runtime/src/scores/judge.ts). The generation check measures it.

  • It is asked, in one call, whether the answer to the definition's question is yes (a probability; 0.5 or more is a pass), which one of eight fixed statements best explains a yes, and which a no (score_reasons in packages/domain/src/scores.ts). The verdict keeps the statement for its own answer (score_verdict in packages/rules/src/scores.ts).
  • For a room turn, the yes-or-no question also says what one is: a member may be told a message is not for it and to stay quiet, or asked to coordinate by handing work to others (score_questions). That is context for any question; only "Did what was asked" says it counts as doing what was asked.
  • One cut at 0.5, no "unsure". A verdict is a pass or a fail at 0.5, with its probability shown in the reason.
  • The reason is one of eight sentences with the probability, such as "The result does not do what the task asked, or part of it is missing. (12% yes)".
  • No judge: a workspace without classify@1 bound, or whose bound connection cannot serve it, gets not_scored with "Not scored: no judge available (…)". A judge that fails, answers nothing usable or takes longer than 90 seconds also leaves not_scored with why. None of this fails, delays or changes the run.

What the judge sees

Built only from what is stored, by score_evidence (packages/rules/src/decisions/score-evidence.ts). By default the judge sees the request (the task, or a room turn's turn), the status, the result and the error. With "Include what the run did" on (score_definitions.include_trace) it also sees the steps and the trace rows below: at most about 33,000 characters as JSON.

  • "Reported its problems" has it on and "Did what was asked" off; a workspace's own score has it off unless the form's switch is on. On "Did what was asked", 30 random runs and 6 known-bad ones, the request and result alone got 32 of 36 right and caught all 8 that should fail (decision models).
  • Code answers what the run's status already says: "Did what was asked" fails a failed run without a judge call (score_by_code in packages/rules/src/scores.ts; judge "the run status", no cost).
PartFromLimit
Taskruns.instructions2,000 characters: the first and last 1,000; empty for a room turn
Room turnfactory_turns, factory_messagesthe message answered 1,500, the directive 600, 5 member replies of 600
Status, resultruns.status, runs.result3,000 characters
Errorruns.error500 characters
Stepsruns.workflow, run_steps8 steps: task 300, report 600, reason 200, and 3 lines of what it worked around
Trace countsrun_spansturns, tool calls, failed tool calls
Failed callsrun_spans where is_errorfirst 8: tool, error (300), exit code, step
Repeated callsrun_spans with the same tool and inputtop 5 of those made 3 times or more
Tool outputrun_spans that succeededthe latest 6: tool, output (300)
Final answerthe last turn's visible text1,500 characters
  • A room turn (a run with a factory_turns row) is judged on what it was asked, read by read_turn_request (packages/db/src/rooms/turn-prompts.ts): the message it answered (for a follow-up, the one the first turn of its chain answered), the directive it was given (the same texts its prompt was built from) and, for a follow-up, the members' replies from the same query that built its prompt.
  • A step's "worked around" lines are its own account (run_steps.account), when it gave one.
  • Every text is passed through the trace's redaction before it is sent (redact_value in packages/runtime/src/redact.ts): JWT-shaped strings, provider keys and a credential after its label become [REDACTED].
  • The judge does not see files, whole transcripts, tool output beyond the first 300 characters of the latest 6 successful calls and of 8 failures, thinking, the audit log or other runs.

Cost

The judge's tokens and cost are stored on the verdict (run_scores.input_tokens, output_tokens, cost_usd) when the provider reports them, and nowhere else: not in run_usage, not in run_spans. A run's cost, Admin → Usage and Observability → Costs do not include judging. It is shown as "Judging cost" on Observability → Scores and per verdict on the run's page.

Where it shows

  • Observability → Scores (/observability?tab=scores, apps/app/src/lib/components/scores/view.svelte): pass rate, runs scored and judging cost, then each definition with its newest 20 failing runs. Adding, editing and scoring past runs need configure:settings.
  • A run's page: a Scores card (apps/app/src/lib/components/scores/run-scores.svelte) once the run is done or failed and has been queued for at least one score.

Limits

  • A worker that dies between committing a run's result and queuing its scores leaves that run unscored; "Score the last N runs" picks it up.
  • Verdicts are not checked against known answers (the generation check's judge controls are not applied here).
  • Each definition is one classifier call per run; several definitions on one run are not combined into one call.
  • Definitions cannot be deleted, and editing a question does not re-score runs. A verdict keeps the question it was asked.
  • No retention: verdicts are kept as long as their run.
This page as markdown apps/site/src/content/docs/engineering/scores.md