> ## 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](https://docs.nika.sh/reference/language/overview.md) / `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](https://docs.nika.sh/reference/language/words/backoff_max_ms.md) · [backoff\_ms](https://docs.nika.sh/reference/language/words/backoff_ms.md) · [backoff\_strategy](https://docs.nika.sh/reference/language/words/backoff_strategy.md) · [jitter](https://docs.nika.sh/reference/language/words/jitter.md) · [on\_codes](https://docs.nika.sh/reference/language/words/on_codes.md)

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

## In a source template

Excerpt from `templates/fanout.nika`, source lines 116–125. 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)
      # a reasoning model needs 16384 here, or a documented run.reasoning.effort: low
```

### Templates containing this field

| Template | Source |
| - | - |
| `templates/fanout.nika` | [Line 119](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/fanout.nika#L119) |
| `templates/recover-optional-file.nika` | [Line 32](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/recover-optional-file.nika#L32) |

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

## Contract and implementation

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

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

[How documentation stays connected](https://docs.nika.sh/reference/knowledge-system.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.