> ## 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_turns

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

[Language reference](https://docs.nika.sh/reference/language/overview.md) / `max_turns`

## Meaning and placement

### agent

Loop limit · a literal integer from 1 to 1000 · default 10 (spec/02-verbs.md §agent).

| Property | Declaration |
| - | - |
| Requirement | Optional in this object |
| Schema location | `/$defs/agent/properties/max_turns` |
| type | `"integer"` |
| minimum | `1` |
| maximum | `1000` |

**In the same object:** [images](https://docs.nika.sh/reference/language/words/images.md) · [max\_tokens\_total](https://docs.nika.sh/reference/language/words/max_tokens_total.md) · [model](https://docs.nika.sh/reference/language/words/model.md) · [prompt](https://docs.nika.sh/reference/language/words/prompt.md) · [schema](https://docs.nika.sh/reference/language/words/schema.md) · [skills](https://docs.nika.sh/reference/language/words/skills.md) · [system](https://docs.nika.sh/reference/language/words/system.md) · [temperature](https://docs.nika.sh/reference/language/words/temperature.md) · [tools](https://docs.nika.sh/reference/language/words/tools.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/agent-loop.nika`, source lines 97–106. This is a fragment, not a runnable workflow.

```yaml illustration theme={"system"}
        # boundary` — measured, mid-loop, after the turns are paid for.
        - "nika:jq"
        - "nika:done"               # explicit completion · loop-owned
      max_turns: 15                 # SLOT: the loop bound
      max_tokens_total: 80000       # SLOT: cumulative input + output tokens
      schema:                       # SLOT: the typed final-message contract
        # Closed on purpose: declare every allowed result field here.
        # Keep extra fields out of the result; schema repair is bounded,
        # and exhausting that allowance is a failure.
        type: object
```

### Templates containing this field

| Template | Source |
| - | - |
| `templates/agent-loop.nika` | [Line 100](https://github.com/supernovae-st/nika-spec/blob/4e259e5b8012fcdf92f094142a52dfef24099b85/templates/agent-loop.nika#L100) |

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_turns`. 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.