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

# شروط الإيقاف

> حدّد عمل وكيل Python بعدد الخطوات أو الرموز أو التكلفة أو المدة أو الأدوات أو سبب الانتهاء.

اجمع أدوات الإيقاف المساعدة عبر `stop_when`:

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

تشمل الأدوات الإضافية `has_tool_call(...)` و`finish_reason_is(...)`. احتفظ بحد للخطوات أو المدة حتى عند تحديد التكلفة أو عدد الرموز، لأن هذه الحدود تعتمد على الاستخدام المُبلّغ عنه.

## مواضيع ذات صلة

* [الجولات الديناميكية](./agent-sdk-dynamic-turns.mdx)
* [المخرجات وإعادة المحاولة](./agent-sdk-run-controls.mdx)


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