Declare when the agent loop should end without writing termination logic by hand.
Not yet available. The Agent SDK is tracked to be built — today, use the Client SDKs against the live chat completions API. The docs below describe the intended design.
Stop conditions are declarative rules that tell callModel() when to stop calling the model. Instead of checking return values inside your loop body, you declare the exit conditions once and let the SDK enforce them.
no_tool_calls#Stop when the model completes a turn without making any tool calls. The most common condition for task-completion: the agent is done when it stops reaching for tools.
max_turns#Hard cap on the number of turns. Prevents runaway loops.
balance_below#Stop before the agent runs out of DA balance. The threshold is in micro-DA (1 DA = 1,000,000 micro-DA).
Note. This condition is checked after each turn using the
X-Balance-Availableresponse header. The final turn that crosses the threshold will still complete.
output_schema#Stop when the model's output matches a JSON Schema. Useful for structured-output agents that should loop until they produce a valid answer.
custom#Full escape hatch. Provide a function that receives the TurnResult and returns true to stop.
List multiple conditions to stop on whichever is met first:
result.stopReason tells you which condition ended the turn:
Stop conditions can also be returned from dynamicParams — useful when the threshold depends on runtime state. See Dynamic Parameters.
callModel() API.