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

# Abbruchbedingungen

> Begrenze Python-Agent-Arbeit nach Schritten, Tokens, Kosten, Dauer, Tools oder Abschlussgrund.

Kombiniere Stopp-Hilfsfunktionen über `stop_when`:

```python theme={null}
stop_when = [
    step_count_is(12),
    max_tokens_used(40_000),
    max_cost(2),
    max_duration(60_000),
]
```

Weitere Hilfsfunktionen sind `has_tool_call(...)` und `finish_reason_is(...)`. Lege auch bei Kosten- oder Tokenlimits eine Schritt- oder Zeitgrenze fest, da diese von gemeldeten Nutzungsdaten abhängen.

## Verwandte Themen

* [Dynamische Turns](./agent-sdk-dynamic-turns.mdx)
* [Ausgaben und Wiederholungen](./agent-sdk-run-controls.mdx)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.