> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Turn on in-flow classification

> Classify failures during the run itself, so every failed run carries a category, reasoning, and a triage action by the time the CLI exits.

In-flow classification runs the
[results classification](/docs/reliability/failure-analysis) agent inside
`momentic run`, at the moment a run exhausts its retries. Every failed run
leaves the CLI already carrying a category, reasoning, and a triage action; no
separate classification pass, and nothing to re-run in a later CI step. Prefer
this over invoking
[`momentic ai classify`](/docs/cli-reference/momentic/commands/ai#classify)
afterwards.

## Enable it

Turn it on in `momentic.config.yaml`:

```yaml momentic.config.yaml theme={null}
ai:
  classification: true
```

The toggle is versioned with your tests and applies to local and CI runs. See
the [AI configuration reference](/docs/configuration/ai#ai-classification) for every
field.

## What happens on a failure

When a run fails after all retries, the CLI shows a `Classifying failure` step
and the agent inspects the failed step, screenshots, error details, evidence
from past runs, and [git context](/docs/reliability/failure-analysis#git-context)
when available. The verdict is written into the run's results:

* The category, reasoning, confidence, and recoverability appear in the CLI
  output and in the run viewer's failure details.
* The category's configured action (**heal**, **warn**, or **fail**) is attached
  to the run, so downstream steps such as
  [`momentic ai triage`](/docs/guides/auto-heal/in-ci) and
  [`momentic results check`](/docs/cli-reference/momentic/commands/results) can act
  on it without re-classifying.
* With [failure recovery](/docs/reliability/failure-recovery) enabled, a failure the
  classifier judges one-time recoverable triggers an in-run recovery attempt
  guided by its reasoning.

Failure categories, their actions, and the optional custom prompt stay
cloud-managed in
[Settings > Classification](https://app.momentic.ai/settings/classification).

## Let the verdict gate CI

By default the classifier only records a category: every failed test still fails
CI. Set `overrideExitCode: true` so failures routed to **heal** or **warn** exit
`0`, keeping the job passing while the failure is repaired or reported. Failures
routed to **fail** (for example `BUG`) still exit `1`.

```yaml momentic.config.yaml theme={null}
ai:
  classification:
    enabled: true
    overrideExitCode: true
```

To opt in for a single invocation instead, pass
[`--classify-override-exit-code`](/docs/cli-reference/momentic/commands/run) to
`momentic run`. To skip classification for one invocation, pass `--no-classify`.

## In-flow vs `momentic ai classify`

`momentic ai classify` runs the same agent as a separate command against
already-finished runs. Prefer the config-driven in-flow setup for CI:

* No extra CI step, API round trip, or run selector to wire up; the verdict is
  part of the run result the moment `momentic run` exits.
* The exit-code override can only be applied while the run is still deciding its
  exit code, so `overrideExitCode` works only in-flow.
* Verdicts are saved automatically; `ai classify` persists only with `--save`.

Reach for `ai classify` when you want to re-classify a past run, classify runs
from an older CLI version, batch-classify a run group or commit, or ask
follow-up questions with `--interactive`.
