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

# max_attempts

> Contract, placement, related fields and source examples for this Nika YAML field.

[Language reference](/reference/language/overview) / `max_attempts`

## Meaning and placement

### retry

Total attempts, counting the first try · integer ≥ 1 · the one required field of a `retry:` block. Engines honor it strictly and surface the LAST error if every attempt fails (spec/05-errors.md §Retry policy).

| Property        | Declaration                            |
| --------------- | -------------------------------------- |
| Requirement     | Required in this object                |
| Schema location | `/$defs/retry/properties/max_attempts` |
| type            | "integer"                              |
| minimum         | 1                                      |

**In the same object:** [backoff\_max\_ms](/reference/language/words/backoff_max_ms) · [backoff\_ms](/reference/language/words/backoff_ms) · [backoff\_strategy](/reference/language/words/backoff_strategy) · [jitter](/reference/language/words/jitter) · [on\_codes](/reference/language/words/on_codes)

[Schema source (use the pointer above)](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/schemas/workflow.schema.json)

## In a source template

Excerpt from `templates/fanout.nika.yaml`, source lines 120–129. This is a fragment, not a runnable workflow.

```yaml illustration theme={"system"}
      fail_fast: false
    timeout: "60s"                  # SLOT: per-iteration bound
    retry:
      max_attempts: 3
      backoff_strategy: exponential
      jitter: true
    on_error:
      recover: null                 # a failed item yields null at its index · the batch lives
    infer:                          # SLOT: the per-item job (any verb)
      max_tokens: 2000              # SLOT: the per-ITEM ceiling · think + answer · multiply by the fan width
```

### Templates containing this field

| Template                     | Source                                                                                                                               |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `templates/fanout.nika.yaml` | [Line 123](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/fanout.nika.yaml#L123) |

These are literal key occurrences in the source files, not an execution or conformance claim. [How to instantiate a template](/guides/templates).

## Contract and implementation

This page projects the named specification revision. Check [released engine status](/reference/status) and [the validation workflow](/guides/agent-authoring) before running a file. An optional field is not evidence that every engine supports every value.

Canonical identity: `language:word:max_attempts`. Spec revision: [`c5ebbb7b862b`](https://github.com/supernovae-st/nika-spec/tree/c5ebbb7b862b68bc6cf7235efba61173b844afc6).

[How documentation stays connected](/reference/knowledge-system).
