Skip to content

Evaluate and compare

Measure the same policy your app runs against your own labeled cases, compare models and prompts, and record which one you picked. Your coding agent can do all of this through the s1flow Skill; this page is the reference behind it.

Install the evaluation tools

Install these in your development environment, not in the production image:

Extra What it adds
eval numpy, scipy and scikit-learn for evaluation, comparison and reports
llm LiteLLM, to compare against LLMs
images Pillow, for preparing images
otel the OpenTelemetry API, for optional tracing spans
uv tool install "s1flow[eval]"

The commands

s1flow init --task ticket-bug
# Fill in tasks/ticket-bug/task.py and add labeled data in the generated s1flow/ project.
s1flow cases check ticket-bug
s1flow run ticket-bug
s1flow report ticket-bug
s1flow adopt ticket-bug MODEL --reason "why this candidate" --json   # the new version is current
# open a pull request with the change: merging releases it

The first s1flow run on a task holds out its test share and writes tasks/<task>/split.json; commit it with task.py, because adopt reads that file and refuses without it. No other command writes it. Cases added later are placed by a hash of their ID, so the file never moves. With too few labelled cases to hold out a test share, run still asks the models and writes the file on a later run.

s1flow init creates an s1flow/ project and nothing else. With --skill it also writes the Agent Skill (or install it as a plugin, as Get started shows). The project's line-up compares four decision models that all work with a single key, OPENROUTER_API_KEY ($0.01 to $0.05 per 1,000 calls on issue-sized inputs). Cases can come from GitHub issues, app logs or labels you already have. Fetching cases from GitHub (the Skill's scripts/github.py) needs the gh CLI, installed and signed in.

A Task defines an evaluation: the data, how to read the label, the question, the objective, the constraints and how to split the cases. Reuse your app's own input-preparation function, or replay the inputs your app actually sent. Don't deploy task.py with your app. Evaluation and the runtime share the question types, answer validation and decision rules; metrics belong to evaluation alone.

Compare candidates

s1flow report shows every model and question variant side by side, using only the development cases. A variant is another wording of the question, written in task.py as variants={"strict": Boolean(instructions="...")} and run as model/strict (the Skill writes them from the mistakes: Feedback and improvement). The terminal shows the candidates ordered by the task's objective, with the ones it cannot tell apart at the top marked = (ordered by tiebreak in task.py, or by name without one); it marks no pick. --json adds every metric of each candidate with the same candidate IDs and numbers, so a person, or an agent acting for them, can choose based on their own criteria. The final test-set result comes only when you adopt a candidate.

adopt --reason records the choice and makes it current in your working tree; it goes live when the pull request that carries it merges (see Policies, evidence and releases).

s1flow report ticket-bug --out DIR saves DIR/comparison.json, a full snapshot of the development results including the chart data, and DIR/questions/<variant>.md and .json for each question variant. s1flow report --from DIR/comparison.json reads that snapshot offline, without rescoring or rechecking anything. The snapshot keeps the source and date, provider and model, the declared and recorded concurrency, and where latency and cost figures came from: billed, list price, or shown as estimated, mixed or unknown. Unknown values stay unknown. Text and JSON output both support --limit, --offset and exact --candidate model[:version][/variant] selectors.

Charts

To look at the results in a browser, render a local page with the bundled renderer, which needs only the standard library:

python <skill>/scripts/charts.py comparison.json --out comparison.html

It reads only the saved snapshot, so it doesn't import the evaluation tools, call a model, rescore or adopt anything. The page opens on a table of every compared candidate. Its columns are the task's own objectives, the metrics the question type has (precision, recall and F1; macro-F1; MAE and QWK; mean IoU; accuracy), API cost and p90 latency; any other metric in the snapshot is a click away. Each cell has a bar from the worst value to the best, the best in each column is highlighted, and a column header sorts by it. A ◆ marks a candidate that no other candidate matches or beats on every measure shown: the ones worth weighing, with no weights and no pick. Below the table, a trade-off chart plots any two measures. The candidates not compared and why, the probability curves and how everything was measured are folded away. Charts export as SVG or PNG with their source and sample size.

Score questions (levels 0 to L-1) are read by their expected level: MAE (the default objective) and QWK, beside the shared metrics. Box questions get the shared metrics and a confidence selection curve; a case whose picture has no target is labelled False, and is right when the model answers with no box (its IoU counts as 1, and as 0 when only one of the label and the answer is a box). A value read from the state (Text, Number, Date) is right when it equals the label, or when nothing is read on a case labelled False (no value there): the report shows the accuracy on the cases with a value and on those with none apart, and how sure an answer is comes from the model's p_null and confidence. A RangeEstimate is read by its mean error (the default objective, MeanError()), counts as right within half a step of the label (1% of the range when it has no step), and is as sure as its p10 - p90 interval is narrow. A MultiChoice is labelled with the list of the options that apply ([] for none) and is right when the options chosen are exactly those; its probability is that of the whole set, each option's own yes or no multiplied. OptionF1() is the objective that counts every option of every case, where accuracy counts a case with one option off as wrong. A Boxes task is labelled with the list of every instance's box ([] for none) and is right when each of them has an answer box of its own at the IoU bar and no answer box is left over; BoxF1() counts box by box, and the report adds how far the number of boxes is off. A policy holds these six like any other type. Yes/no questions add precision/recall and calibration charts. Choice questions get a curve of the selected answer's probability when the model returns a real distribution. A provider's own confidence score is treated as a separate signal, and no probability curve is drawn when the signal it needs isn't available.

Thresholds and intervals

For yes/no questions (and choice questions with a positive option), an objective that sets the rule (Accuracy, F1, ExpectedLoss, Recall, Loss, or a custom one through sets=) picks a threshold on the training side of each development fold. Reports keep three things apart: raw metrics, cross-validated metrics with a tuned threshold, and the held-out final result. Tuning a threshold is not the same as calibrating probabilities. Candidates whose intervals overlap are grouped together, to err on the side of caution. That doesn't prove they are equivalent, in practice or statistically. An unknown measurement never counts as meeting a cost or latency limit you set.

The ranking only orders candidates with an answer to every case; the JSON candidates keep the ones whose evidence differs or is incomplete, and say where each falls short.

When old results stop counting

Before reusing a result, s1flow checks the exact input that was sent, the question, the connection actually used, the model ID and the implementation. Editing an input under the same case ID, or changing the endpoint or options, means the old response is no longer reused. You can correct a label without asking the model again for an unchanged input, but earlier evaluation results no longer match.

Changing concurrency also invalidates earlier performance numbers. The raw answers can still be reused, but old timings aren't reported as if they were measured at the new concurrency; use run --fresh to measure again.

A custom provider used in evaluation must declare a provider_revision in its trusted ModelSpec or TOML entry, naming the commit or package version of your implementation. The Client and policies that haven't been evaluated don't need it. Keeping the revision accurate is up to you; it isn't a signature, and it proves nothing about a remote model's weights.