---
name: improve-classify
description: "Read one deployed version's eval baseline, tool errors, annotations, feedback, judgements and observations, group them into ranked failure modes, and have the owner pick one to fix. Use after improve-select."
metadata:
  min-cli-version: "0.87.0"
  next: "improve-baseline"
---

# Improve: classify

Turn what the platform recorded about one version into failure modes the owner can choose from. You need the version id and commit from `improve-select`.

Nothing in this step writes outside `runs/improve/`. Speak only from records you read here: never invent a count, a cause or a quote.

## 1. Read the signals

Read the six signals for the version over the last 14 days, each into its own file. Never print a list: read the files with `jq`.

```sh
V=<version-id>; D=runs/improve/$V; mkdir -p $D
introspection eval baseline show --runtime $V -o json > $D/baseline.json
for family in feedback judgement observation; do
  introspection events list --event-name introspection.$family --filter runtime_id=$V \
    --lookback 14d --page-all -o json > $D/$family.json
done
introspection conversations list --filter runtime_id=$V --lookback 14d --page-all \
  --query "[].id" -o json > $D/conversations.json
for c in $(jq -r '.[]' $D/conversations.json); do
  introspection events list --event-name introspection.feedback --filter conversation_id=$c \
    --lookback 14d -o json
done | jq -s 'add | unique_by(.id)' > $D/feedback-by-conversation.json
introspection conversations export --filter runtime_id=$V --lookback 14d \
  --include annotations --include comments \
  --query "(status.code == 'Error' && attributes.gen_ai.tool.call.id || annotation) && {conversation: attributes.gen_ai.conversation.id, tool: attributes.gen_ai.tool.name, error: status.code == 'Error' && (status.message || attributes.error.type) || null, annotation: annotation}" \
  > $D/spans.jsonl
```

- **Eval baseline:** the cases failing at the version's commit, with their failing criteria's reasoning. A suite without a baseline is fine: say there is none and go on.
- **Tool errors and annotations:** the rows of `spans.jsonl`, one per failed tool call or annotated span.
- **Feedback:** the negative ones, from `feedback.json` and `feedback-by-conversation.json` by `id` (feedback a client saved without the version still names its conversation). A comment is the owner's or user's own words: quote it, and take any value it gives as theirs. **Judgements:** the failing ones. **Observations:** each one's `payload.lens` and `payload.summary`.

A command that fails: name the signal you couldn't read and go on with the others.

## 2. Group them into failure modes

Read every record and group them into failure modes someone can act on, never "bad quality". A mode is what the agent did wrong, in one sentence that holds for every record in it, such as "Calls the search tool without the required date range", and one fix would address all of it: records that would need different fixes are different modes.

For each mode, keep in `runs/improve/<version-id>/modes.md`:

- its name and that one-sentence definition;
- the signals it comes from;
- its number of conversations: distinct conversation ids among its records, plus one per failing baseline case;
- its conversation ids, so drafting its cases reads only those;
- one quote from a record that shows it;
- **From the baseline:** yes when a failing baseline case shows this mode, with the case's id.

A record that fits no mode stays out. A mode needs at least one record.

## 3. Rank them

Rank by severity first, then by number of conversations. Severity is what the failure costs the person it happened to: a wrong or harmful result, or a lost task, ranks above a slower or clumsier one that still got there. A rare severe mode ranks above a frequent mild one.

## 4. Ask the owner which to fix

Show the ranked modes in a short table: rank, name, signals, number of conversations, and "baseline" when it comes from the baseline. Then ask with `ask_user_question` exactly "Which failure modes should we fix?", with no other sentence: the table already says which ranks first. Set `multiSelect: true` only with two or more modes; a single mode is one option and a single choice, and an option that isn't a mode (such as "leave it") never goes in a multi-select. The options are the top four modes in rank order, each label the mode's name, an em dash, its definition and its conversations, with no description: `Edits reported done but not applied — says every change is in when some aren't · 6 conversations`. The owner picks one to four; they are fixed together, in one pass.

No signal reported anything: say the version looks clean over the 14 days and name what you read. Then ask with `ask_user_question` how to get more to read, with these options in this order:

1. **Share some conversations:** the owner points you at conversations or examples where the agent went wrong.
2. **Simulate some conversations:** run `improve-simulate`, then read its conversations here.
3. **Stop here.**

## Done when

- Every signal was read, or the one that couldn't be is named.
- The owner saw the ranked modes with their counts and picked one to four.

Then go straight on with `improve-baseline`, with the chosen modes from `modes.md`.
