# Options · budget and context

Canonical URL: https://developers.iagenify.com/sdk/ref/agents/options/budget/
Language: en

`budget · maxSteps · contextTokens`

Three ceilings: what it may spend, how many steps it may take, and how much conversation it may hold.

Status: budget null · maxSteps 100 · contextTokens 200 000

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `budget` | integer|null | null | Credits for the run. Checked before every step and before every paid tool. |
| `maxSteps` | integer | 100 | Steps. A subagent is capped at 40 whatever this says. |
| `contextTokens` | integer | 200 000 | The context limit. A whole number, at least 10 000, no larger than the model's window. |

```javascript
api.agents.create({
  runtime: "local", machine: pc, model,
  budget: 200,
  maxSteps: 40,
  contextTokens: 400_000,
});
```

## Which one to set {#which}

> **budget is the one that matters**
>
> maxSteps is a runaway guard — 100 is high on purpose. The thing that should normally stop a run is credits, because that is what you actually care about and what a media tool can burn in one call.

## What counts against the budget {#counted}

Every turn, every paid tool, the summary turn that compaction performs, and everything every subagent does — a subagent reads the parent's running total, so several working in parallel are bounded together.

## It bounds when the run stops {#overshoot}

The check is before a step, so an allowed step can still cost more than what was left. Slightly above the budget is normal.

## contextTokens {#context}

| Set to | Effect |
| --- | --- |
| absent | The smaller of 200 000 and the model's window |
| a number | That, unless it is larger than the window — then `context_too_large` on the first run |
| under 10 000 | Refused at creation with `invalid_context` |

Raising it does not avoid compaction; it postpones it. A turn carrying 800 000 tokens is slow and expensive on every step that follows, because the whole history is re-sent each time.

## How a run reports each ceiling {#stopping}

| Reached | stopReason |
| --- | --- |
| `budget` | `"budget"` |
| `maxSteps` | `"max_steps"` |
| stop() | `"stopped"` |

None of them is a failure or a success: the run ends with whatever the model last wrote, which may be half a thought.

- [Budget](/sdk/agent/budget): In detail.
- [Context](/sdk/agent/context): Clearing and compaction.
- [The loop](/sdk/agent/loop): Where each check happens.

```python
api.agents.create(
    runtime="local", machine=pc, model=model,
    budget=200,
    max_steps=40,
    context_tokens=400_000,
)
```
