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

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

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

## Meaning and placement

### agent

Cumulative token budget across every turn of the loop · the SPEND ceiling, where `max_turns` is the step ceiling. Default is engine-configurable (spec/02-verbs.md §agent).

| Property        | Declaration                                |
| --------------- | ------------------------------------------ |
| Requirement     | Optional in this object                    |
| Schema location | `/$defs/agent/properties/max_tokens_total` |
| type            | \["integer", "string"]                     |

**In the same object:** [max\_turns](/reference/language/words/max_turns) · [model](/reference/language/words/model) · [prompt](/reference/language/words/prompt) · [schema](/reference/language/words/schema) · [skills](/reference/language/words/skills) · [system](/reference/language/words/system) · [temperature](/reference/language/words/temperature) · [tools](/reference/language/words/tools)

[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/agent-loop.nika.yaml`, source lines 108–117. This is a fragment, not a runnable workflow.

```yaml illustration theme={"system"}
        - "nika:jq"
        - "nika:done"               # the early-exit sentinel · loop-owned
      max_turns: 15                 # SLOT: the loop bound
      max_tokens_total: 80000       # SLOT: the spend bound
      schema:                       # SLOT: the typed final-message contract
        # Closed on purpose (`check` hints `strictness` on an open object):
        # on 0.118.7 an extra key through `nika:done` is a verdict (above),
        # so every field the answer may carry is named HERE, not in the prompt.
        # Measured on a real seat with the goal bound in: it computed the
        # answer and died on one key it added beside `findings`. On 0.118.7
```

### Templates containing this field

| Template                         | Source                                                                                                                                   |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `templates/agent-loop.nika.yaml` | [Line 111](https://github.com/supernovae-st/nika-spec/blob/c5ebbb7b862b68bc6cf7235efba61173b844afc6/templates/agent-loop.nika.yaml#L111) |

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_tokens_total`. Spec revision: [`c5ebbb7b862b`](https://github.com/supernovae-st/nika-spec/tree/c5ebbb7b862b68bc6cf7235efba61173b844afc6).

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