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

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

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

ركّب دوال الإيقاف المساعدة داخل `AgentDefinition.StopWhen`:

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

`HasToolCall(...)` و`FinishReasonIs(...)` provide event-based limits. احتفظ بحد للخطوات أو المدة حتى عند تحديد عدد الرموز أو التكلفة، لأنهما يعتمدان على الاستخدام المُبلّغ عنه.

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

* [الأدوار الديناميكية](./agent-sdk-dynamic-turns.mdx)
* [Outputs وretries](./agent-sdk-run-controls.mdx)


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