Get an API key
api.agents

Options · budget and context

budget · maxSteps · contextTokens

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

budget nullmaxSteps 100contextTokens 200 000
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

budgetinteger|nullnull

Credits for the run. Checked before every step and before every paid tool.

maxStepsinteger100

Steps. A subagent is capped at 40 whatever this says.

contextTokensinteger200 000

The 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

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

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 toEffect
absentThe smaller of 200 000 and the model's window
a numberThat, unless it is larger than the window — then context_too_large on the first run
under 10 000Refused 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

ReachedstopReason
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.