> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Stop conditions

> Bound PHP agent runs by steps, tokens, cost, duration, tools, or finish reason.

Combine stop helpers to enforce product budgets independently of the model's decision to continue.

```php theme={null}
$agent = AgentSdk::createAgent(new AgentDefinition(
    id: "bounded-research",
    model: "openai/gpt-5.4-nano",
    stopWhen: [
        AgentSdk::stepCountIs(12),
        AgentSdk::maxTokensUsed(40000),
        AgentSdk::maxCost(2.50),
        AgentSdk::maxDuration(120000),
    ]
));
```

The SDK also provides tool-call and finish-reason conditions. Inspect `$result->run->stopReason` and normalized usage after completion so the application can distinguish a budget stop from a normal model finish.

Stopping is a bounded result, not automatically an exception. Decide which stop reasons your product treats as successful, retryable, or user-visible.
