> ## 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 .NET agent work by steps, tokens, cost, duration, tools, or finish reason.

Compose stop helpers in `AgentDefinition.StopWhen`:

```csharp theme={null}
StopWhen = new[]
{
    AgentSdk.StepCountIs(12),
    AgentSdk.MaxTokensUsed(40_000),
    AgentSdk.MaxCost(2),
    AgentSdk.MaxDuration(TimeSpan.FromMinutes(1)),
};
```

`HasToolCall(...)` and `FinishReasonIs(...)` provide event-based limits. Keep a step or duration bound even when using token or cost limits, because those depend on reported usage.

## Related

* [Dynamic turns](./agent-sdk-dynamic-turns)
* [Outputs and retries](./agent-sdk-run-controls)
