# A second scorer

> How to have a separate decision model score the changed blocks in place of the review model, and what changes when you do.

Web page: https://visto-ai.com/docs/second-scorer/

By default the review model both finds problems and scores the changed blocks. You can instead name a separate decision model to score the blocks, while the review model keeps writing the findings. The scorer is off unless you write the `scorer` block.

The adapter speaks OpenRouter's decisions endpoint and was built for the Jev decision model. For each block it asks thirteen yes-or-no questions, such as whether the block changes how money or time is computed, a database table, or which records a user may reach, and combines the answers into a score and a category on the same 0–100% scale (see [The score](https://visto-ai.com/docs/the-score/)). It sends four blocks to a request.

## Turn it on

```yaml
scorer:
  baseUrl: https://openrouter.ai/api/alpha   # the default; only the config file sets it
  apiKey: { env: SCORER_API_KEY }
  model: vendor/decision-model
  timeoutSeconds: 60                          # seconds for one call, at most 300

repositories:
  defaults:
    score:
      threshold: 70   # must be written when a scorer is named
```

| Key | Default | Notes |
|---|---|---|
| `scorer.baseUrl` | `https://openrouter.ai/api/alpha` | Any `http` or `https` address. The key is sent there, so only the config file sets it |
| `scorer.apiKey` | none, required | The environment variable that holds the key |
| `scorer.model` | none, required | The decision model to call |
| `scorer.timeoutSeconds` | `60` | At most 300 |

[config.example.yml](https://raw.githubusercontent.com/visto-ai/visto-ai/0faf484aa43f4fcdc1f30c1d5c056ea26c1c0d32/config.example.yml) shows the keys with a placeholder model name.

**You must write the score threshold** under `repositories.defaults.score.threshold` when a scorer is named, and you should choose it from a [backtest](https://visto-ai.com/docs/backtest/) run with the scorer: its scores need not fall where the review model's do.

## What changes

- **The reviewed code goes to one more provider.** It is also sent to the scorer's endpoint.
- **The review model gives no block scores.** It is given [contract/review-contract-scorer.md](https://raw.githubusercontent.com/visto-ai/visto-ai/0faf484aa43f4fcdc1f30c1d5c056ea26c1c0d32/contract/review-contract-scorer.md) in place of the review contract: it writes the findings and each file's change summary, and scores only a file that moved with no content change.
- **The scorer answers for blocks only.** It never gives a whole-file score. A file moved to another directory with no content change is still scored by the review model, from its old and new path.
- **A file the scorer fails on goes to a person.** A block the scorer fails on or leaves out has no score, so its file counts as 100%.
- **Scores have their own history.** The scorer's scores and the review model's are kept apart. Naming a scorer, or dropping it, scores every open pull request's blocks afresh, once (see [Scores across reviews](https://visto-ai.com/docs/scores-across-reviews/)).

The endpoint is marked alpha by its provider.

## Change it from the UI

Once the service has started, an admin can switch the scorer off, and change its model and time limit, in the UI's Settings, under Model. Whether it is on is read at the next start; its model and time limit at the next review. Its endpoint and key are set only in the config file, and shown read only in the UI. Switching the scorer on from Settings therefore needs the file to write `scorer.apiKey` already (see [Configuration](https://visto-ai.com/docs/configuration/)).

## Measuring it

- `npm run eval:backtest` records which scorer was used for a run.
- `npm run eval:score-noise` refuses to compare two runs made with different scorers.
- The scorer's cost counts towards `--max-cost` only when its provider reports a cost with each answer.
- The `--memory` and `--lessons` options of the eval commands cannot be used with a scorer in the config: the score would not come from the model that is shown them.

## Related

- [The score](https://visto-ai.com/docs/the-score/): the bands and the threshold.
- [Backtest](https://visto-ai.com/docs/backtest/): choosing a threshold from your history.
- [Configuration](https://visto-ai.com/docs/configuration/): which settings the UI edits.
