Skip to content

Evaluation harness (milk eval)

Runs scenario prompts against real agent backends — the claude CLI (driven inside a tmux session exactly as a human would), the actual milk binary (driven as a one-shot batch run consuming its machine-readable --output-format stream-json event stream), mimocode's mimo CLI (the same one-shot batch shape over mimo run --format json), or pi (the same one-shot batch shape over pi --mode json) — scores the responses with an LLM judge against a rubric, and reports token/cache/quality comparisons. This is for anyone validating milk against their own configured agents (which primary/escalation agent actually performs best on their real workloads, not just milk's own maintainers benchmarking milk internals), and for comparing against other harnesses/backends on the same scenarios. Measurement runs get the full toolkit: an experiment file defines the whole suite (adapters, scenarios, repetitions, judge, sandbox, budgets) in one YAML — the same request repeated against always-fresh sandboxed state seeded with your current agent set, verifying tokens, tool calls (count + full list) and time per run, with nth-run variance in the report. --scenarios defaults to eval/scenarios relative to your current working directory; --results defaults to ~/.milk/eval/results (the eval artifact home under the milk state root — outside the source tree, see docs/internal/eval-artifacts.md) — see Scenarios for where those defaults come from and how to point at your own directory instead.

milk eval is a subcommand of the main milk binary (cmd/milk/main.go mounts eval.Command()) — there is no separate milk-eval binary. Build with task build / task build:local like any other milk command.

Quick start

milk eval --list                                          # available adapters
milk eval run --agents claude-code,milk-tui                # run every scenario against both
milk eval run --agents milk-tui,mimo-code --category smoke # milk vs mimocode on the smoke check
milk eval run --agents milk-tui,pi --category smoke        # milk vs pi on the smoke check
milk eval run --agents claude-code --category smoke        # fast pipeline sanity check
milk eval run --experiment eval/experiments/metrics-testbed.yaml   # a whole suite from one file
milk eval report --results ~/.milk/eval/results/<run>     # re-print a saved report
milk eval report --results ~/.milk/eval/results/<run> --html  # self-contained HTML → <run>/report.html

Commands

milk eval run

Runs scenarios against one or more adapters, judges each turn, and prints + persists a comparison report.

Flag Default Description
--experiment (none) Experiment YAML file defining the full suite (adapters, scenarios, repetitions, judge, sandbox, budgets) — see Experiment files. Explicitly set flags override its fields.
--agents all registered Comma-separated adapter names. Supports per-adapter options — see below.
--scenarios eval/scenarios Directory of scenario YAML files.
--category (none) Filter to one category (smoke, code_generation, debugging, refactoring, …).
--multi-turn false Only run scenarios with multi_turn: true.
--repetitions 1 Run every scenario N times, fully isolated (fresh temp workdir, fresh sandbox per run) — for nth-run variance.
--isolate (none) Filesystem isolation for agent runs: auto|bwrap|off — see Filesystem isolation. Explicit flags override the experiment's isolate: field.
--results ~/.milk/eval/results Output directory (outside the source tree, under the milk state root); writes results.json.
--judge-agent primary agent Agent name from ~/.milk/config.json to use as the LLM judge instead of the primary agent — see Judging.

milk eval judge

Re-scores an existing results.json against the scenario rubrics without re-running the agents — useful after fixing a judge bug or rubric, or to try a different --judge-agent. A successful re-score overwrites each agent's scores, records any coverage gaps as missing_criteria, and clears a stale judge_error left by a previous failed judgment. Takes --results, --scenarios, --judge-agent (same meaning as above).

milk eval report

Regenerates the printed report from an existing results.json. --cache-only prints just the cache-hit analysis; --json emits machine-readable output; --html emits a self-contained HTML report (one file, no external assets, light/dark aware) — without -o it writes <results>/report.html; -o/--output writes to a file instead of stdout for every format.

milk eval --list

Prints registered adapter names and a usage hint. New adapters register themselves via eval.Register(name, factory) in an init(), same pattern as eval/adapter_claude.go / eval/adapter_milk.go.


Experiment files

An experiment file defines the full evaluation suite in one YAML file — adapters, scenario selection, repetitions, judge, sandboxing and metric budgets — so a complete, repeatable run needs no external scripting:

milk eval run --experiment eval/experiments/metrics-testbed.yaml

Explicitly set CLI flags override the experiment's fields one by one (e.g. --repetitions 5 on the command line beats repetitions: 3 in the file). ~/ is expanded in both path fields. Relative scenario paths resolve against the experiment file's directory first (an experiment is self-contained), falling back to the working directory; relative result paths behave like the --results flag (working directory). Run outputs default outside the source tree, under the eval artifact home (~/.milk/eval/results/<name>, i.e. <milk state root>/eval/results/<name> — see docs/internal/eval-artifacts.md).

name: metrics-testbed
description: fixed request, repeated                               # optional, shown nowhere yet
agents:                                                           # adapter specs, same bracket syntax as --agents
  - milk-tui
scenarios: testbed-scenarios                                      # scenario dir (default eval/scenarios)
select:                                                           # optional filters
  category: metrics                                               # one category
  names: [fixed-request]                                          # exact scenario names (unknown names = error)
  multi_turn: false                                               # like --multi-turn
repetitions: 3                                                    # N fully isolated runs per scenario (default 1)
judge_agent: ""                                                   # "" = primary agent
results: ~/.milk/eval/results/metrics-testbed                     # default: ~/.milk/eval/results/<name>
sandbox:                                                          # see Sandboxed runs
  mode: fresh                                                     # fresh | off (default off)
  seed: config                                                    # config (default) | none
  allow_tools: true                                               # let batch runs execute mutating tools
  milk_binary: ""                                                 # optional: pin the milk binary to drive
isolate: off                                                      # filesystem isolation: auto | bwrap | off (default off) — see Filesystem isolation
budget:                                                           # metric thresholds asserted per run (see Metric budgets)
  max_input_tokens: 100000
  max_output_tokens: 20000
  max_tool_calls: 30
  max_duration: 5m
versions:                                                         # optional: milk version matrix (see Comparing milk versions)
  - label: head                                                   # report column (keep short; default: the ref / binary basename)
    ref: HEAD                                                     # git ref built on demand (cached per commit)
  - label: v0.8.0
    ref: v0.8.0

A working example lives at eval/experiments/metrics-testbed.yaml (with its request scenario under eval/experiments/testbed-scenarios/) — the run-from-the-same-request testbed: one fixed request, repeated N times against always-fresh sandboxed state seeded with your current agent set, verifying tokens, tool calls and time per run and their variance across runs. Keep that example pristine: for your own comparisons, copy it into ~/.milk/eval/experiments/ (machine-local, outside the repo) and edit your copy — what belongs in the repo versus machine-local is defined in docs/internal/eval-artifacts.md.


Sandboxed runs

Without sandboxing, every milk-tui run lives in the real ~/.milk state root — and the nth run then sees the first run's sessions, percept memory, and prompt history, exactly what a measurement run must not. sandbox.mode: fresh (or the milk-tui[--sandbox] adapter option) gives every adapter start a brand-new state root (a milk-eval-home-* temp dir, removed on adapter stop — one per scenario run, one per repetition):

  • seeded with your current agent set (seed: config, the default): the fresh root's config.json is a verbatim copy of your current one (~/.milk/config.json, honoring --config-root/$MILK_CONFIG_ROOT) — same agents, settings and routing, none of the state (sessions, memory, history, jobs, otel, mcp_oauth all start empty).
  • seed: none seeds nothing — milk starts from first-run defaults.
  • allow_tools: true additionally writes dangerously_skip_permissions: true onto every seeded agent: batch runs have no interactive permission ask, so mutating tools (bash, edit_file, write_file, …) are otherwise denied ("requires permission — run interactively or enable skip-permissions") and a code-editing request silently degrades to read-only. Only the sandbox's seeded copy is modified — your live config is never touched.
  • milk_binary: pins the binary the adapter drives (default ~/.local/bin/milk — run task build after code changes, or the harness silently scores a stale binary).

Per-adapter pseudo-flags do the same without an experiment file: milk-tui[--sandbox], milk-tui[--sandbox-seed,/path/config.json], milk-tui[--allow-tools], milk-tui[--milk-bin,/path/to/milk], milk-tui[--label,<name>]. Explicit pseudo-flags win over experiment values.

Two caveats: claude-code has no sandbox support (it drives a tmux session against the real ~/.claude; an experiment's sandbox: section is skipped for it with a note), and MCP servers needing OAuth are not seeded — their tokens live in the (empty) state root, so the run warns not authorized and continues without them.


Filesystem isolation

A temp workdir and a fresh state root are state boundaries, not filesystem ones: nothing stops an agent from writing anywhere else on the machine — and nothing detects it (issue #355 records a real incident: scoring agents escaping into the live checkout across repetitions, one escape chain committed as legitimate-looking work). isolate: wraps every agent process of every adapter in the comparison in a bubblewrap sandbox (Linux):

isolate: auto                    # auto | bwrap | off (default off)

or milk eval run --isolate=auto (explicit flags override the experiment's field).

Mode Behavior
off / unset Uncontained — the historical behavior.
auto bubblewrap where it works; otherwise a loud warning and an uncontained run (macOS, Windows, kernels without user namespaces).
bwrap Required: fail closed when bubblewrap is missing or unusable — never silently uncontained.

The shape is read-only by default, enumerate the writes (eval/isolate.go):

  • the whole filesystem is mounted read-only — agent binaries, git identity, $HOME config, other repos all stay visible (nothing is hidden from the agent, so the evaluation stays pure: no prompt or context changes), just unwritable;
  • writable: the scenario workdir, a fresh per-run /tmp scratch (tmpfs, gone with the run), and the adapter's own state root — milk's MILK_CONFIG_ROOT/sandbox root, mimo's ~/.mimocode, pi's ~/.pi, claude-code's ~/.claude + ~/.claude.json. State semantics are deliberately unchanged, so sandboxed and non-sandboxed baselines stay comparable (constraint: never measure a different thing);
  • the network namespace is shared on purpose — localhost model servers keep working;
  • the judge and the harness run outside the sandbox.

The mode is resolved once per run (one real probe — a bare bwrap binary on PATH is not enough; kernels with user namespaces disabled fail every run) and handed to every adapter alike, so a comparison is never half-sandboxed. Degradation is always reported: "unsandboxed" is a visible fact in the run log, never an assumption. A surface missing from the writable list fails loudly (tool errors caught in testing) instead of silently escaping — the allowlist only ever grows from observed, reproducible needs. file_changes in results remains the workdir snapshot: isolation prevents escapes rather than reporting them.

Rejected alternatives are recorded in issue #355 so they aren't re-proposed: prompt-level guardrails (contaminate the evaluation), worktree git status guards (too narrow, false-positive on the operator's own edits), tool-trail write tripwires (block legitimate surfaces), path concealment (agents can ls ~ regardless).


Comparing milk versions

The version matrix runs the same suite against several milk binaries side by side — one labeled milk-tui adapter per version — so a single run compares their effectiveness (judge scores, tokens, tool calls, time) on identical scenarios, judge, budgets and fresh sandboxes. Declare it in the experiment file:

versions:
  - label: head            # report column / results.json key (default: the ref or binary basename)
    ref: HEAD              # git ref (tag / branch / commit) built on demand
  - label: v0.8.0
    ref: v0.8.0
  - label: patched
    milk_binary: ~/bin/milk-patched   # prebuilt binary instead (wins over ref)
  • ref: builds ./cmd/milk via go build in a throwaway git worktree of the milk repo (found via the current working directory) and caches the binary under ~/.cache/milk-eval-builds/, keyed by the resolved commit — re-runs skip the build; a moving branch rebuilds when its commit changes. Build failures (e.g. an old ref with a different toolchain) surface with the compiler's output before any scenario runs.
  • milk_binary: drives a prebuilt binary as-is (~ is expanded) — anything from task build output to a CI artifact.
  • Labels must be unique (they name the report columns and the results.json keys — two adapters sharing one would overwrite each other's data).
  • versions combines with agents — e.g. a claude-code baseline column alongside the version columns — and with repetitions (each version × each repetition fully isolated) and budget: (asserted per version per run).
  • The report is the usual per-agent comparison with versions as columns (Weighted Score, Tokens, Tool calls, Duration, Budget per version), plus Repetition Statistics per version when repeating.

Without an experiment file the same shape works through the adapter pseudo-flags (each milk-tui becomes its own column):

milk eval run --category smoke --results /tmp/cmp \
  --agents 'milk-tui[--label,head,--milk-bin,~/.local/bin/milk],milk-tui[--label,v0.8.0,--milk-bin,/tmp/milk-v080]'

Metric budgets

The automated verify half of an evaluation: every run's metrics are checked against thresholds, whatever the judge scores. Budgets come from the experiment file's budget: block (defaults for every scenario) and an optional per-scenario budget: block, which wins field-by-field. Zero/omitted = no limit. For multi-turn scenarios every metric is the scenario's total across its turns.

YAML key Checks Run metric
max_input_tokens input tokens ≤ N sum of tokens.input_tokens
max_output_tokens output tokens ≤ N sum of tokens.output_tokens
max_total_tokens in+out ≤ N sum of both
max_tool_calls / min_tool_calls tool-call count within bounds len(tool_calls)
max_num_turns model iterations ≤ N num_turns (absent = not checked)
max_duration wall time ≤ duration string ("90s", "2m30s"); max_duration_ms for the integer form turn duration

Verdicts render per scenario (Budget [milk-tui]: PASS / FAIL — tool calls 25 > max_tool_calls 20), as a Budget row in the metrics table, and as N/M pass in the repetition statistics; results.json carries the full verdict per run (agents[].budget).


Cost accounting

Every adapter fills RunResult.CostUSD, but by different means — know which source produced the cost column you are reading:

adapter source
mimo-code reported — mimo's own per-step cost events
pi reported — pi's catalog-derived per-message usage.cost.total (same models.dev xiaomi prices as the builtin table)
claude-code reported — Claude Code's total_cost_usd result line (session-cumulative; the adapter records each turn's delta)
milk-tui computed — eval's pricing table over the turn's token usage

Milk itself carries no price data anywhere (its stream-json total_cost_usd field is ratified but reserved — emitted only once milk has a pricing table), so eval prices milk turns: the result's per-model model_usage buckets when present (an escalation hop can be a different model than the primary), falling back to the init-reported model over the total tokens.

Built-in prices are $/1M tokens for the models this project benchmarks, taken from the models.dev xiaomi catalog (fetched 2026-10-28): mimo-v2.6-flash input 0.14 / output 0.28 / cache_read 0.0028, mimo-v2.6-pro 0.435 / 0.87 / 0.0036, mimo-v2.6-pro-ultraspeed 4.35 / 8.7 / 0.036 (cache_create 0 for all — their endpoints never report cache-write tokens). The pro row was independently cross-checked by least-squares over mimo-code's own reported costs across 24 recorded runs (reproduced to <0.2% typical error), so computed milk costs and reported mimo costs are directly comparable. Override or extend per experiment — keys are model names, exact or path-qualified:

pricing:
  mimo-v2.6-pro: {input: 0.435, output: 0.87, cache_read: 0.0036}
  my-local-model: {input: 0, output: 0}   # known-free stays $0 on purpose

An unknown model costs $0 — never a fabricated figure — which looks exactly like the pre-pricing column: read $0.000 as unpriced, not free. Prices go stale; pricing: wins per model, and computed milk costs are estimates (list price × token counts, no provider-specific adjustments).


Scenarios

The default scenarios ship as YAML files under eval/scenarios/ in the milk repo — there's nothing to install or generate, they're just checked-in examples you can read, copy, or run as-is. --scenarios (see Commands) resolves relative to your current working directory and defaults to eval/scenarios, so running milk eval run from the repo root picks them up automatically; --results defaults outside the source tree, under ~/.milk/eval/results. Running from elsewhere, or want your own scenario set entirely (a different directory, a different repo, scenarios specific to your own project)? Pass --scenarios <path> — any directory with the same file format works, the default is just a convenient starting point, not a requirement.

A file starting with _ (e.g. _base.yaml) is a shared-defaults file, not an executable scenario — it's skipped when loading, and its default_scoring/default_weight backfill any rubric criterion that omits them in the same directory.

A file holds either one scenario (flat) or several under a scenarios: list; a top-level category: is inherited by every scenario in the file unless overridden per-scenario.

Field reference

Matches Scenario in eval/scenario.go — that struct is the source of truth; this table is a convenience.

Field YAML key Type Notes
Name name string Scenario identifier, shown in reports.
Description description string Human-readable summary — shown in reports, never sent to the agent.
Category category string Inherited from the file's top-level category: if omitted per-scenario. Filter with --category.
Difficulty difficulty easy | medium | hard Informational only — not enforced, not scored.
MultiTurn multi_turn bool Must be true for turns: to take effect, and to be selected by --multi-turn.
Setup.Files setup.files list of {path, content} Files written into the scenario's temp workdir before the first turn — see Adapters for how each adapter's workdir is created.
Prompt prompt string Single-turn shorthand. Ignored once turns: is set.
Turns turns list of {prompt, rubric} Multi-turn steps, sent in order as separate turns in the same adapter session (same conversation — a persistent tmux session for claude-code, milk's default session continuation across one-shot batch runs for milk-tui, the first turn's captured session resumed via -s for mimo-code, the workdir's session resumed via --continue for pi).
Rubric rubric list of criteria Top-level rubric for single-turn scenarios (i.e. those using prompt:, not turns:).
Expected expected → {contains, files_changed} — Parsed but not currently consumed — see caveat below.
CacheExpect cache_expect → {min_cache_hit_rate_after_turn1, no_cache_recreate_after_turn1} — Automated cache-reuse assertions for multi-turn scenarios — see Multi-turn example.
Budget budget → {max_input_tokens, max_output_tokens, max_total_tokens, max_tool_calls, min_tool_calls, max_num_turns, max_duration} — Per-scenario metric budget, winning field-by-field over the experiment's budget: — see Metric budgets.

Each rubric criterion (rubric: items, top-level or per-turn):

Field YAML key Type Notes
Criterion criterion string Dimension name, e.g. correctness, efficiency — shown as its own report column.
Description description string Given to the LLM judge as the scoring instruction for this dimension.
Weight weight int Relative weight in WeightedScore. Backfilled from _base.yaml's default_weight if omitted.
Scoring scoring binary | scale_1_5 binary: judge returns 0.0 or 1.0. scale_1_5: judge returns 1.0–5.0. Backfilled from _base.yaml's default_scoring if omitted.

expected is currently a no-op. The YAML parses (Contains []string, FilesChanged []FileExpect{Path, Contains}) but nothing in eval/harness.go or eval/judge.go reads scenario.Expected — no automated pass/fail assertion is actually checked against it today. Scoring is entirely LLM-judge-driven. Don't rely on expected: doing anything until this is wired up; the LLM judge's rubric is the only thing currently gating a score.

_base.yaml — shared defaults

# Shared rubric defaults applied to all scenarios in this directory.
# Scenarios can override these per-criterion.
default_scoring: scale_1_5
default_weight: 1

Applied per rubric criterion that omits scoring/weight — see applyBaseDefaults in eval/harness.go.

Single-turn example

eval/scenarios/code_generation.yaml's fix-typo — the shape every single-turn scenario in code_generation.yaml and debugging.yaml follows:

category: code_generation

scenarios:
  - name: fix-typo
    description: >
      Agent must find and fix a typo in a README file. The word "projcet"
      should be corrected to "project".
    difficulty: easy
    setup:
      files:
        - path: README.md
          content: |
            # My Projcet

            This is a sample projcet that does amazing things.

            ## Installation

            Clone the repo and run `make install`.
    prompt: >
      There's a typo in README.md — the word "projcet" should be "project".
      Please fix it.
    rubric:
      - criterion: correctness
        description: >
          Did the agent replace "projcet" with "project" in both occurrences?
        weight: 3
        scoring: binary
      - criterion: efficiency
        description: >
          Did the agent use a minimal number of tool calls (read + edit, or a
          single edit)?
        weight: 1
        scoring: scale_1_5

Multi-turn example (with cache_expect)

eval/scenarios/refactoring.yaml's add-validation — multi_turn: true, a turns: list instead of prompt:/rubric:, and cache_expect asserting the adapter's own conversation cache reuses context from turn 2 onward (a different concern from --cache-cooldown, which is about cross-run reproducibility, not within-session reuse):

category: refactoring

scenarios:
  - name: add-validation
    description: >
      Agent adds validation to a config loader, then refactors the validation
      into a separate function. Two turns; tests that the second turn benefits
      from cached context.
    difficulty: easy
    multi_turn: true
    cache_expect:
      min_cache_hit_rate_after_turn1: 0.3
      no_cache_recreate_after_turn1: true
    setup:
      files:
        - path: config/config.go
          content: |
            package config
            # ... (see the real file for the full Load() implementation)
    turns:
      - prompt: >
          Add validation to the `Load` function in config/config.go:
          port must be between 1 and 65535, host must not be empty,
          and db_url must not be empty. Return an error describing
          all validation failures.
        rubric:
          - criterion: correctness
            description: >
              Does the validation check port range, non-empty host, and
              non-empty db_url?
            weight: 3
            scoring: binary
          - criterion: error_messages
            description: >
              Does the error message list all validation failures, not just
              the first one?
            weight: 2
            scoring: scale_1_5

      - prompt: >
          Refactor: extract the validation logic into a separate
          `Validate(*Config) error` function. Add validation for api_key
          (must not be empty). Keep the error accumulation pattern.
        rubric:
          - criterion: correctness
            description: >
              Is validation extracted into a standalone Validate function
              that is called from Load?
            weight: 3
            scoring: binary
          - criterion: completeness
            description: >
              Does Validate also check api_key is non-empty?
            weight: 2
            scoring: binary

Current scenarios

Everything that ships in eval/scenarios/ today:

File Scenario Category Difficulty Turns Notable fields
smoke.yaml say-pong smoke easy 1 Minimal pipeline sanity check — no real code editing.
code_generation.yaml fix-typo code_generation easy 1 setup.files
code_generation.yaml add-function code_generation medium 1 setup.files
code_generation.yaml write-test code_generation medium 1 setup.files
debugging.yaml fix-nil-pointer debugging medium 1 setup.files
debugging.yaml fix-off-by-one debugging easy 1 setup.files
refactoring.yaml iterative-refactor refactoring medium 3 multi_turn, cache_expect
refactoring.yaml add-validation refactoring easy 2 multi_turn, cache_expect

None of the shipped scenarios use expected: (see the no-op caveat above). iterative-refactor is the fullest multi-turn example (3 turns, higher min_cache_hit_rate_after_turn1) if add-validation above isn't enough — read it directly in eval/scenarios/refactoring.yaml.


Adapters

Adapter Drives Requires
claude-code The claude CLI, launched inside a fresh tmux session per scenario, in a throwaway git-initialized temp workdir. Reads Claude Code's own transcript JSONL for the response, token usage, and tool calls. claude CLI on PATH, logged in
milk-tui The installed ~/.local/bin/milk binary (built via task build, or pinned with --milk-bin/sandbox.milk_binary), spawned per turn as milk [flags] "<prompt>" --output-format stream-json; the adapter consumes the batch JSONL event stream (ADR-0050) for the response, token usage, and tool calls — no session-file scraping. Tool calls come from the stream's tool_use/tool_result message pairs (local-provider turns; a claude-cli turn inside milk emits none). milk built and configured (~/.milk/config.json)
mimo-code The installed mimo (mimocode) CLI, spawned per turn as mimo run --format json --yolo [-s <sessionID>] -- "<prompt>" in the scenario workdir; the adapter consumes the JSONL event stream for the response (the final assistant message), token usage (summed over the run's step_finish events, reasoning folded into output), cost (populated — mimo reports it per step), and tool calls (deduped by callID; mimo re-emits each completed call). Multi-turn turns resume the first turn's captured session via -s. mimo on PATH (mimocode install) with configured providers
pi The installed pi CLI, spawned per turn as pi --mode json [--continue] [--model …] -- "<prompt>" in the scenario workdir; the adapter consumes the JSONL event stream (pi's docs/json.md contract) for the response (the final assistant message's text), model identity, token usage (summed over assistant message_end events — pi's output already includes reasoning, input excludes cacheRead), cost (populated — pi reports catalog-derived usage.cost.total per message), and tool calls (tool_execution_start/_end pairs keyed by toolCallId). Multi-turn turns resume the workdir's own session via --continue (pi keys sessions per directory, like milk — no session id to capture); turn 1 of each scenario never passes it. No approval flag is needed: json mode executes mutating tools without an interactive ask. pi on PATH with a configured model (pi[--model,provider/id])

The claude-code adapter types the prompt into the target program's interactive prompt via tmux send-keys/send-enter — the same input path a human would use, not an API shortcut — then polls for turn completion (Claude Code: transcript reaches the text block of a stop_reason: "end_turn" response, or any non-assistant record after one). Claude Code writes one transcript line per content block, each repeating the response's usage, so token usage is counted once per message.id. The milk-tui adapter instead runs milk headlessly per turn and waits on the stream's terminal result event, which carries the response, usage/model_usage (incl. cache_read/cache_creation), num_turns, ttft_ms, output_tokens_per_second and route_history directly — with the run's init route.reason recorded per hop as route_reasons, the result's model_usage key set as models_used (the billing truth when an escalation hop ran a different model than the session primary) and the optional payload (first-request payload composition — system/tools/message bytes plus the effective tool_description_tier diet, issue #462's meter) captured as payload; tool calls are collected from the turn's tool_use/tool_result message pairs. The mimo-code adapter follows milk-tui's headless shape against mimocode: one mimo run --format json process per turn, the response taken from the final assistant message's text events (earlier pre-tool narration is excluded), usage summed from the per-step step_finish tokens (with reasoning folded into output tokens — thinking bills as output in Anthropic-style usage too), the run's cost summed into CostUSD, and tool_use events deduped by callID into the tool-call list. The pi adapter is the same headless shape against pi: one pi --mode json process per turn, the response taken from the last assistant message_end's text blocks (earlier narration excluded, thinking blocks never joined), usage summed over assistant message_end events (pi's output already contains reasoning — it is not added again — and input excludes cacheRead, which is summed separately), agent_settled required as the terminal event (a truncated stream returns the partial run with the error), and tool_execution_start/_end pairs joined by toolCallId into the tool-call list.

Per-adapter options

--agents supports a bracket syntax to pass adapter-specific options: name[opt1,val1,opt2,val2,...]. Commas inside brackets don't split across adapters — --agents "claude-code[--cache-cooldown,5m],milk-tui[--agent,mimo-local]" is two adapters, not four.

Adapter Option Example Effect
milk-tui any milk CLI flag milk-tui[--agent,mimo-local] Forwarded verbatim onto the milk launch command — e.g. pin the primary or escalation agent for this eval run without touching ~/.milk/config.json.
milk-tui --sandbox milk-tui[--sandbox] Fresh milk state root per run, seeded with the current config — see Sandboxed runs.
milk-tui --sandbox-seed <path> milk-tui[--sandbox-seed,cfg.json] Sandbox seeded from an explicit config.json (implies --sandbox).
milk-tui --allow-tools milk-tui[--allow-tools] Seed the sandbox with dangerously_skip_permissions on every agent so batch runs may execute mutating tools.
milk-tui --milk-bin <path> milk-tui[--milk-bin,./milk] Pin the milk binary to drive (adapter pseudo-flag — never forwarded to milk).
claude-code --cache-cooldown <duration> claude-code[--cache-cooldown,5m] Before starting a new session, wait until at least <duration> has elapsed since the last claude-code turn completed — anywhere, including in a previous milk eval run invocation (state persists to ~/.milk/eval-claude-cache-activity). Opt-in; omit for unchanged (possibly cache-warm) behavior. See Prompt caching.
claude-code any other flag claude-code[--append-system-prompt,"..."] Forwarded verbatim onto the claude launch command.
mimo-code any mimo run flag mimo-code[-m,anthropic/claude-sonnet-4-5] Forwarded verbatim onto the mimo run command — e.g. pin the model or agent for this eval run without touching mimocode's config.
mimo-code --mimo-bin <path> mimo-code[--mimo-bin,./mimo] Pin the mimo binary to drive (adapter pseudo-flag — never forwarded to mimo).
mimo-code --no-yolo mimo-code[--no-yolo] Drop the default --yolo from the spawn. Batch runs have no one to answer a permission ask, so removing it lets mimo's own permission defaults deny mutating tools.
pi any pi flag pi[--model,xiaomi/mimo-v2.6-flash] Forwarded verbatim onto the pi command — pin the model (do it: pi's default model resolution may pick something other than what the comparison wants) or append prompts/system-prompt flags without touching pi's config.
pi --pi-bin <path> pi[--pi-bin,./pi] Pin the pi binary to drive (adapter pseudo-flag — never forwarded to pi).

Prompt caching and --cache-cooldown

Claude Code's tool-definitions/system-prompt block is cached server-side (Anthropic prompt caching) independent of workdir or session — a fresh temp dir does not force a cache miss, and neither does varying the prompt text, because caching is a prefix match and both of those live after the cached prefix in the request (tools → system → messages). Back-to-back claude-code runs will therefore show cache_read tokens on that layer for as long as the cache's ~5-minute TTL hasn't expired, which makes token counts vary depending purely on when a run happens relative to other claude-code activity — not on anything the scenario or adapter did differently.

If you want reproducible, TTL-independent measurements, add --cache-cooldown <duration> (e.g. 5m, matching the TTL) to the claude-code adapter spec. It's opt-in — real usage benefits from this caching, so forcing every run cold isn't "more correct," just more comparable run-to-run.


Judging

eval.NewJudgeFromConfig resolves the judge model from ~/.milk/config.json — by default the same primary agent milk itself uses (cfg.ActiveAgent()); pass --judge-agent <name> to point it at a different configured agent instead.

Self-evaluation bias: if you run --agents milk-tui where milk-tui's own primary agent is the same model as the default judge, that model is scoring its own output. This isn't an issue for claude-code runs (different model), but for milk-tui runs consider --judge-agent pointed at an independent, ideally stronger model.

The judge prompt asks for a JSON array of {criterion, score, reasoning} and tolerates two categories of malformed LLM output: markdown code fences around the array, and literal (unescaped) \" characters inside reasoning text — parseJudgeScores repairs the latter before giving up.

A parseable reply that skips rubric criteria gets the same re-ask treatment: the judge is corrected with the missing criterion names and retried (up to the same 3 attempts), and if it stays partial the scores it did return are kept, with the gaps recorded as missing_criteria per agent in results.json. Criterion names echoed back with the rubric text attached — e.g. proportional (binary, weight 2): <full description> — are snapped back to the canonical criterion name before that coverage check (longest-prefix match at a word boundary), so a glued echo neither burns a retry nor drops its score out of WeightedScore (observed live: one routing-reps cell reported a phantom proportional gap while its returned score was silently unweighted — both fixed by the snap). The report renders each missing criterion as — — never a fabricated 0.0, since a genuine 0.0 is real data and renders normally — and marks that agent's weighted score with *: WeightedScore renormalizes over the returned criteria only, because missing criteria drop out of both the numerator and the denominator of the weighted average. A per-scenario ⚠ partial rubric for <agent> warning line names the dropped criteria.

An empty reply — parseable, but not a single score (e.g. every attempt answers []) — is missing data, not a zero: the harness converts it to a judge_error the same way as a hard parse failure (unless the scenario has no rubric at all, where the judge was never asked). Every cell in results.json carries an explicit judged marker (normalized on every write; files from before the field infer it from their judge_error/scores), so consumers never have to infer "not scored" from weighted_score: 0 + scores: [] — the inference that once let a single unjudged cell fake a −2.2-point arm regression in a hand-rolled aggregate (issue #479).


Reports

GenerateReport prints per-scenario tables (correctness/etc. scores, Weighted Score) and per-agent metrics (Tokens (in/out), Cache (create/read), Cache hit rate, Cost USD, Duration, Tool calls, Budget), followed by each agent's tool-call list in call order (Tools [milk-tui] (5): read_file, edit_file, bash), the per-turn routing attribution (Routing [milk-tui]: T1 escalation/mimo-v2.6-pro (model classifier) → T2 primary/mimo-v2.6-flash (short prompt (local))), the first-request payload composition when the run's milk build reports it (Payload [milk-tui]: ~7.7k tok first request — system 8.7k B, tools 20.7k B, msgs 10.0k B (diet: full) — the meter a with/without tool_description_tier comparison reads) and the budget verdict (Budget [milk-tui]: PASS / FAIL — <violations>), then an aggregate section (by weighted score, and by cost-efficiency). The quality averages are judged-only, and the section states the coverage they were computed over per arm (Judged cells: milk 13/13 | pi 12/13); whenever any cell is unjudged the winner line is followed by ⚠ incomplete judging — aggregates and winner cover judged cells only: <agent> <n>/<m> judged (missing: <scenario>), and a run with zero judged cells prints Overall winner: none — no judged cells in this run instead of a nameless line. Winner lines are tie-aware: equal top scores render as Winner: pi (score tie — cost tie-break) — a cost tie-break is not a quality win — and the overall line always shows both means (Overall winner: milk (2.53 vs 2.52 — gap below display precision)), so a gap the one-decimal table hides can never crown an unexplained winner. With repetitions > 1 (or --repetitions), each run is its own labeled section (Scenario: fixed-request (run 2/3)) and a Repetition Statistics section summarizes nth-run variance per scenario as mean ± sd (Weighted score, Tokens in/out, Tool calls, Duration) plus the budget pass rate (2/3 pass). GenerateCacheReport (--cache-only) prints just the cache analysis. GenerateJSON (--json) is the same data as a machine-readable structure — see ScenarioResult/AgentResult in eval/scenario.go and eval/harness.go; per-turn results carry the full tool-call list (name/args/result), model, num_turns, ttft_ms, output_tokens_per_second, stop_reason, route_history plus route_reasons (the router's decision reason per hop), models_used (the models that billed the turn) and payload (first-request system_bytes/tools_bytes/messages_bytes + diet — absent on older runs and non-HTTP providers), and each run carries its budget verdict. GenerateHTML (--html) is the same content as a single self-contained HTML file: real tables built on the shared score-grid model (so ERR/—/* cells match the text report exactly), judge reasoning collapsed per agent, repetition statistics and aggregates included — generated into <results>/report.html by default so it lands next to its results.json.

Real output shape (from milk's own report-generator test fixture, not a live run — trimmed to one scenario):

=== Agent Evaluation Report ===

Scenario: fix-typo-in-readme
Category: code_generation | Difficulty: easy

                     claude-code    milk-tui
────────────────────────────────────────────
         correctness         1.0         1.0
          efficiency         3.0         4.0
────────────────────────────────────────────
      Weighted Score         3.6         4.2

Winner: milk-tui

                     claude-code    milk-tui
────────────────────────────────────────────
     Tokens (in/out)   25,477/18   1,200/340
 Cache (create/read)    25,477/0         0/0
      Cache hit rate        0.0%        0.0%
            Cost USD      $0.096      $0.001
            Duration        2.5s        2.1s
          Tool calls           1           2

=== Aggregate Evaluation Report ===
...
By cost-efficiency (quality per dollar):
                     claude-code    milk-tui
────────────────────────────────────────────
   Avg cost/scenario      $0.180      $0.002
      Quality/dollar        20.9     2,050.0
      Cache hit rate       25.0%       27.9%

Overall winner: milk-tui (4.20 vs 3.60) (90x cheaper)

(Cost USD is $0.001-ish here only because the fixture's numbers are illustrative — see the caveat below; token/cache columns are the reliable comparison today.)

Cost USD is computed per adapter (see Cost accounting and the limitation below): milk-tui prices each model_usage bucket, claude-code reports Claude Code's own total_cost_usd as a per-turn delta, mimo-code uses mimo's reported per-step cost, pi uses pi's catalog-derived per-message cost. A $0.000 cell means the model has no configured price — not that the run was free.


Known limitations

  • milk-tui shells to the installed binary (~/.local/bin/milk), not whatever's in your working tree — run task build after code changes before evaluating, or the harness silently scores a stale binary (or pin one with --milk-bin / sandbox.milk_binary, or let versions: ref: build the exact commits — see Comparing milk versions).
  • CostUSD is computed from a pricing table (see Cost accounting) — milk-tui prices each model_usage bucket against the built-in table (or an experiment pricing: override), claude-code reports Claude Code's own total_cost_usd (as a per-turn delta), mimo-code uses mimo's reported per-step cost, and pi uses pi's reported catalog-derived cost. A $0.000 cell means the model has no configured price (e.g. an arbitrary local endpoint) — not that the run was free; token counts and cache columns remain the model-independent comparison.
  • --cache-cooldown is claude-code-only — milk-tui doesn't exhibit this caching behavior (no Anthropic-style prompt cache in the local-model path), so there's nothing for it to control there.
  • expected: is a no-op (see Scenarios) — it parses but nothing checks it. Scoring is entirely LLM-judge-driven today (metric budget:, by contrast, is enforced — see Metric budgets).
  • Tool-call args/results are the stored trail's — captured size-capped (2000 chars per arg payload, 8KB per result, older results cleared under a 256KB per-turn budget), so a list built from the trail can show cleared-result gaps on tool-heavy turns.
  • claude-code, mimo-code and pi are not sandboxed — sandbox: applies to milk-tui only (see Sandboxed runs); claude-code turns also report tool calls from Claude Code's transcript, not milk's trail. mimo-code runs against the live ~/.mimocode state root (each scenario still starts a fresh mimo session — the adapter resets its -s resume key per scenario), and its RunResult.Model stays empty because mimo's event stream carries no model identity — the model shows blank in the report instead of being guessed. pi runs against the live ~/.pi state root (each scenario starts a fresh session because the adapter's workdir-keyed --continue gate resets per scenario); pi's RunResult.Model is filled from the assistant message_end.
  • Older milk-tui binaries under-report tools — the tool-trail expansion and real num_turns shipped together with versions:, so a column built before them reports Tool calls 0 / num_turns 1 even when the model called tools. For version comparisons spanning that boundary, read tool metrics as a lower bound and fall back to the judge and file_changes for ground truth (observed comparing v0.7.0/v0.8.0 against current).
  • Judge parse failures are retried, then terminal — malformed judge JSON (e.g. an unescaped quote inside reasoning, a trailing comma) is first salvaged by repair passes and, if still unparseable, re-judged up to 2 more times with an explicit correction ("output only the JSON array, escape all quotes"). A turn is scored ERR and dropped from the stats only when all 3 attempts fail to parse.
  • Judge silence is ERR, never a 0 — a parseable-but-empty judge reply (every attempt returns []) used to be recorded as weighted_score: 0 with scores: [], which external aggregation read as real data (issue #479). The harness now converts it to a judge_error, cells carry the explicit judged flag, the aggregate prints Judged cells: <arm> <n>/<m> per arm, and incomplete judging appends the ⚠ incomplete judging guardrail after the winner line (text and HTML); --json aggregate entries carry judged_scenarios/total_scenarios.
  • Judge coverage gaps are retried, then flagged — a parseable reply that omits rubric criteria is re-asked with the missing names; if still partial after 3 attempts the judgment is kept (coverage loss is data, not a failed turn) and the gap surfaces as missing_criteria, — cells and a * on the weighted score. results.json files written before this shipped lack the field — their tables still render unscored cells as — (the presence check is independent of the field), but only new runs get the ⚠ partial rubric warning line. A related failure mode is closed at parse time: criterion names that echo the rubric line (name (scoring): description) are snapped to the canonical criterion, so they score normally instead of flagging a phantom gap and silently dropping their weight.
  • Runs are scoped, not sandboxed from the machine — the workdir isolation (setup: / fresh temp dir, fresh sandbox: state per run for milk-tui) bounds what a scenario invites an agent to touch, not what it can touch: agents run with real tools and can read or write absolute paths outside their working directory (observed: agents editing the live milk checkout during routing scenarios, and cross-repetition contamination). file_changes therefore reports the working directory only; an escape is invisible there. Real containment is tracked in #355; until it lands, don't run scenarios whose prompts point at a real repository you care about (the seeded scenarios avoid exactly this), and treat file_changes as a lower bound.