budgetinteger|nullnullCredits for the run. Checked before every step and before every paid tool.
maxStepsinteger100Steps. A subagent is capped at 40 whatever this says.
contextTokensinteger200 000The context limit. A whole number, at least 10 000, no larger than the model's window.
api.agents.create({
runtime: "local", machine: pc, model,
budget: 200,
maxSteps: 40,
contextTokens: 400_000,
});api.agents.create(
runtime="local", machine=pc, model=model,
budget=200,
max_steps=40,
context_tokens=400_000,
)Which one to set
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
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
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
| 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
| 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.