الجمع بين الحدود المضمنة
status: "stopped".
الوظائف المساعدة المتاحة
إضافة شرط مخصص
يمكن للشرط إعادةfalse أو true أو سلسلة نصية للسبب:
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
قيّد عمل الوكيل بعدد الخطوات أو الرموز أو التكلفة أو المدة أو استدعاءات الأدوات أو سبب الإنهاء.
import {
maxCost,
maxDuration,
maxTokensUsed,
stepCountIs,
} from "@phaseo/agent-sdk";
const agent = createAgent({
id: "bounded-research",
stopWhen: [
stepCountIs(12),
maxTokensUsed(40_000),
maxCost(2),
maxDuration(60_000),
],
});
status: "stopped".
| الدالة المساعدة | تتوقف عندما… |
|---|---|
stepCountIs(limit) | يصل عدد الخطوات المكتملة إلى الحد |
maxTokensUsed(limit) | يصل استخدام الرموز التراكمي إلى الحد |
maxCost(limit) | تصل التكلفة التراكمية المُبلّغ عنها إلى الحد |
maxDuration(ms) | تصل مدة التشغيل المنقضية إلى الحد |
hasToolCall(name) | تحتوي خطوة على استدعاء الأداة المحدد |
finishReasonIs(reason) | تبلغ خطوة النموذج عن سبب الإنهاء |
false أو true أو سلسلة نصية للسبب:
const stopAfterRepeatedFailures = ({ steps }) => {
const failures = steps.filter((step) => step.status === "failed").length;
return failures >= 2 ? "repeated_failures" : false;
};
const agent = createAgent({
id: "support-agent",
stopWhen: [stepCountIs(10), stopAfterRepeatedFailures],
});
هل كانت هذه الصفحة مفيدة؟