# Generation quality check

> The checks that measure whether generated agents and workflows are good enough to run.

Source: https://werker.cloud/docs/engineering/generation-check (updated 2026-11-30)

Werker's core bet is that workflows generated from a description are
good enough to run without editing. `pnpm eval:generation` measures
that.

## How it works

- **Cases** (`apps/worker/src/eval/cases.ts`): descriptions someone
  might type into `/new`.
- **Running:** each case is queued as a workflow generated from its
  description, for the workspace and model given (`--workspace`,
  `--model`, default `workspace-a` and `gpt-5.6-luna`; `--only`
  filters by name). A worker must be running. A case names the
  abilities it needs by their [registry](registry.md) id (`shell`,
  `classify`, `web` for the sandbox's network); it is skipped when the
  workspace's runs lack one.
- **Plan cases:** a case with `plan` (`plan-*`) is decided by the plan
  the generator saved: the schedule's fields, and the
  [registry](registry.md) ids it must list under needs and
  unsupported. The check then stops the run and removes the schedule.
- **Setup cases:** a case with `setup` (`setup-slack`) is decided by
  creation stopping before it saves anything, with each listed ability
  not ready (`runs.pause.setup`). The check then stops the run. Needs
  a workspace with no Slack connection.
- **Web cases:** `web-page-title` reads a page and
  `web-search-homepage` searches, through a connected web service or
  the sandbox's network; each is skipped when the workspace has
  neither.
- **Scoring:**
  - **Fixed checks:** strings the result must contain, where the
    answer is known (25 primes, largest 97; left-pad 1.3.0). When a
    case has them, they decide.
  - **Judge:** `classify@1` (Jev), asked whether the task was
    achieved, as the user would see it. It decides cases without fixed
    checks. For the impossible task it asks whether the result says
    the data is unavailable instead of inventing it; refusing at
    generation also passes. So does stopping to ask for what is
    missing: nothing is connected that could answer, so the check
    stops the run and passes the case without the judge.
  - **Files** (`files`): the run's steps must keep at least that many
    files.
  - **Asking** (`answer`): a step must stop for input instead of
    guessing. The check then answers it with `answer`, the run must
    finish, and the judge sees the task with the answer.
  - **Judge controls:** before scoring, the judge is given fixed
    results it must get right. The report shows how many it got right.
- **Output:** a PASS/FAIL table, and the full results (each run's
  result, error, steps and timing) in `data/evals/` (not in Git).
  Files the runs kept, such as a chart or a CSV, are saved beside the
  report in `data/evals/generation-<time>/<case>/`.

## Shaping and this check

The check queues its runs without shaping (`runs.shape` false), so
they plan at once and never stop for a brief
([shaping](ui.md#shaping-on-new)). No case covers the questions, the
brief or `look_up`.

`define_workflow` refuses a plan without `done`, each step is told
what done means and what was assumed, and asking is one round of at
most four questions. The cases that stop to ask, the impossible ones
and the plan cases (`plan-*`) read these.

## Saved work check

`pnpm --filter @werkerai/worker eval:saved-offers` checks what `/new`
offers before it makes something new
([decision models](decision-models.md)): each request in
`apps/worker/src/eval/saved-offers-cases.ts`, labelled by hand with
the saved items in `workspace-a` that would do it, is scored against
the workspace's saved work as creation scores it. It reports right
offers, wrong offers and fits missed at the 0.7 bar, and saves every
score in `data/evals/`. It calls only classify@1 and needs no worker.
The labels name workspace-a's saved items.

## Rendering check

`pnpm eval:rendering` renders each finished run's result from the
newest report in `data/evals/` with the run page's markdown component,
in a browser (Vitest browser mode,
`apps/app/src/lib/components/markdown/markdown.svelte.eval.ts`). It
calls no model and needs no worker. Per run it checks:

- every directive in the result is a registered one (others show as
  source text);
- every file shown with `::file[<path>]` or a ` ```file ` block is a
  file the run kept;
- every ` ```chart ` block can be drawn.

Across the report it checks that at least one run that kept files
shows one with a `::file` directive, which is what the step prompt
asks for. It is not part of `pnpm test` or CI.

## Factory coverage

The same `pnpm eval:generation` command also runs five model-only
factory cases through the public core API, Postgres queue and real
worker/runtime:

- `factory-delegation`: the lead asks a specialist for arithmetic with
  `ask_members`; check the specialist's reply, a distinct lead
  follow-up turn and the final reply published in the room.
- `factory-delegated-qa`: the specialist asks two separate questions.
  Each pause must appear in Decisions with the right factory, thread
  and pause generation before the eval answers it. Both answers must
  survive in the specialist's and lead's final results.
- `factory-thread-context`: give a specialist a fresh codename, then
  send a new message asking the lead to have it recalled. The second
  request does not repeat the codename, so the result depends on the
  room's earlier messages.
- `factory-room`: a lead and two specialists, each with its own
  codeword. First the user addresses both specialists and each must
  reply for itself. Then the lead must ask both in one `ask_members`
  call and report both codewords after both have replied.
- `factory-listening`: with reading along switched on, all three
  members join a room, then the user addresses only the lead. Both
  specialists must be given the message and post nothing.

The first four cases switch reading along off, so the turns they check
are only the ones addressed.

Run just the factory cases, or one case, with the existing filter:

```sh
pnpm eval:generation --only factory --model gpt-4o-mini
pnpm eval:generation --only factory-delegated-qa --timeout-min 5
```

A worker and the current database schema must be running. These cases
need no sandbox or classifier; a factory-only selection skips judge
controls.

Each case creates a fresh factory with a written-out lead and
specialists. Exact result checks also require evidence of the
delegated run and follow-up. The Q&A answers and codename are unique
to each invocation and recorded in the report.

`--timeout-min` is a per-factory-case deadline across its phases.
Unexpected questions, missing inbox entries, rejected answers, failed
runs, wrong results and missing delegation fail the case. On failure
or timeout the eval cancels only that thread's active runs, including
any follow-up queued by cancellation. Factories, threads and finished
runs remain available for inspection.

Factory evidence is saved as `factory_outcomes` in the same
`data/evals/generation-<time>.json` report: factory/thread IDs, run
statuses and results, questions and answers, messages and fixed-check
verdicts. Failed selected cases produce a nonzero exit status. These
cases do not cover live sandbox execution or browser rendering.

## Sandbox image check

`pnpm eval:images` (`apps/worker/src/eval/images.ts`) checks that work
which depends on what is installed gets a
[sandbox image](sandboxes.md) that has it. A worker must be running,
with a sandbox provider and the listed images probed. Options as for
`eval:generation` (`--workspace`, `--model`, `--only`,
`--timeout-min`). It calls no judge.

- **Cases** (`apps/worker/src/eval/images/cases.ts`): six
  descriptions.
- **A case passes** when its run finishes; its plan's image is one a
  probe found to have what the case uses (a word listed after "Not
  installed" does not count); the audit log's `sandbox.created` event
  names that same image; and the run kept the files and gave the
  values the case lists. A case is skipped when no listed image has
  what it uses.
- **Second run:** each case that passed is run again as the agent or
  workflow its plan was saved as, with no planning. Its sandbox must
  start from the image the first run's plan picked. Not done when the
  plan reused an agent saved before the run: running that agent again
  runs its own earlier task.
- **Factory** (`factory-data-team`): a factory is created with a brief
  that names Python with pandas, and its team is written from the
  brief. The member with the shell must be given an image found to
  have pandas, its turn's sandbox must start from that image, and the
  lead must report the number the analyst worked out (`RESULT=42925`).
  The factory is kept for inspection.
