تقوم Laravel AI SDK بشحن واجهة برمجة تطبيقات بشرية في الحلقة للموافقة على مكالمات أدوات الوكيل
يتناول أحد تحديثات إطار العمل التي تم الإعلان عنها في Laracon US 2026 مشكلة يعرفها بالفعل أي شخص قام بشحن وكيل ذكاء اصطناعي في الإنتاج: بمجرد أن يبدأ الوكيل في الاتصال بالأدوات، لم تكن هناك طريقة تقليدية للتدخل قبل

استخدام lovable unlimited بدون حدود
أعرف المزيديتناول أحد تحديثات إطار العمل التي تم الإعلان عنها في Laracon US 2026 مشكلة يعرفها بالفعل أي شخص قام بشحن وكيل ذكاء اصطناعي قيد الإنتاج: بمجرد أن يبدأ الوكيل في الاتصال بالأدوات، لا توجد عادة طريقة للتدخل قبل أن يتصرف. تغير واجهة برمجة تطبيقات Laravel AI SDK الجديدة البشرية في الحلقة (HITL) ذلك من خلال السماح لك باعتراض مكالمات أداة محددة وتتطلب قرارًا بشريًا قبل أن يستمر الوكيل.
المشكلة التي يحلها
يعد الوكيل الذي يمكنه، على سبيل المثال، إصدار المبالغ المستردة أو حذف السجلات أو إرسال رسائل البريد الإلكتروني نيابة عن المستخدم مفيدًا حقًا ومحفوفًا بالمخاطر حقًا إذا كان يعمل دون مراقبة. حتى الآن، كانت الطريقة الوحيدة لإضافة شبكة أمان هي بناء طبقة الموافقة الخاصة بك حول SDK باليد: اعتراض تنفيذ الأداة، واستمرار المكالمات المعلقة في مكان ما، وتوصيل واجهة المستخدم للموافقة عليها. تنقل واجهة برمجة تطبيقات HITL الجديدة هذا النمط إلى إطار العمل نفسه.
كيف تعمل هذه الطريقة؟
تضع علامة على الأداة على أنها تتطلب الموافقة، ويتوقف الوكيل مؤقتًا بدلاً من تنفيذها مباشرة:
use Laravel\Ai\Agent;
use Laravel\Ai\Attributes\RequiresApproval;
class IssueRefundTool
{
#[RequiresApproval]
public function __invoke(string $orderId, float $amount): string
{
Order::findOrFail($orderId)->refund($amount);
return "Refunded {$amount} for order {$orderId}.";
}
}
عندما يقرر الوكيل استدعاء أداة تحمل علامة #[RequiresApproval]، يتم إيقاف التنفيذ مؤقتًا وإعادة المكالمة المعلقة إلى طلبك بدلاً من تشغيلها على الفور:
$run = $agent->run($conversation);
if ($run->isPendingApproval()) {
foreach ($run->pendingToolCalls() as $call) {
// Surface $call->tool, $call->arguments to a human reviewer
}
}
الموافقة أو الرفض أو التعديل
لا يقتصر المراجع على ثنائية "نعم" أو "لا". تدعم واجهة برمجة التطبيقات تعديل الحجج قبل تشغيل الأداة بالفعل، وهو أمر مهم بالنسبة لشيء مثل مبلغ رد الأموال الذي قد يرغب الإنسان في تقليله بدلاً من رفضه تمامًا:
// Approve as-is
$run->approve($call->id);
// Deny, with a reason the agent can see and react to
$run->deny($call->id, reason: 'Refund exceeds policy limit for this order.');
// Approve with modified arguments
$run->approve($call->id, arguments: ['orderId' => $call->arguments['orderId'], 'amount' => 25.00]);
بمجرد حلها، يستمر عمل الوكيل من حيث توقف، مع دمج قرار المراجع في خطوته التالية بدلاً من البدء من جديد.
لماذا هذا مهم لفرق وكلاء الشحن
تقوم الكثير من الفرق التي تعتمد على Laravel AI SDK بتجديد طبقة الموافقة الخاصة بها بالفعل، وعادةً ما تكون وظيفة في قائمة الانتظار مع علامة قاعدة بيانات ولوحة إدارة مخصصة. إن وجود هذا كواجهة برمجة تطبيقات للطرف الأول يعني أن النمط متسق الآن عبر النظام البيئي، ويمكن أن تعتمد الحزم المبنية على مجموعة أدوات تطوير البرمجيات للذكاء الاصطناعي على نفس آليات الموافقة بدلاً من أن يخترع كل منها آلياته الخاصة.
إذا كنت تبني أي شيء يتيح للوكيل التصرف بناءً على بيانات العميل أو الفوترة أو البنية التحتية، فإن هذا يستحق الاعتماد حتى لو كان تدفق الموافقة الحالي يعمل بشكل جيد، لأنه يضعك على مسار مدعوم حيث تستمر SDK في التطور بدلاً من الحفاظ على التنفيذ الموازي بنفسك.
One of the framework updates announced at Laracon US 2026 addresses a problem anyone who has shipped an AI agent in production already knows about: once an agent starts calling tools, there's traditionally been no way to step in before it acts. The Laravel AI SDK's new human-in-the-loop (HITL) API changes that by letting you intercept specific tool calls and require a human decision before the agent proceeds.
The problem it solves
An agent that can, say, issue refunds, delete records, or send emails on a user's behalf is genuinely useful, and genuinely risky if it's running unattended. Until now, the only way to add a safety net was to build your own approval layer around the SDK by hand: intercepting tool execution, persisting pending calls somewhere, and wiring up a UI to approve them. The new HITL API moves that pattern into the framework itself.
How it works
You mark a tool as requiring approval, and the agent pauses instead of executing it directly:
use Laravel\Ai\Agent;
use Laravel\Ai\Attributes\RequiresApproval;
class IssueRefundTool
{
#[RequiresApproval]
public function __invoke(string $orderId, float $amount): string
{
Order::findOrFail($orderId)->refund($amount);
return "Refunded {$amount} for order {$orderId}.";
}
}
When the agent decides to call a tool marked with #[RequiresApproval], execution pauses and the pending call is handed back to your application instead of running immediately:
$run = $agent->run($conversation);
if ($run->isPendingApproval()) {
foreach ($run->pendingToolCalls() as $call) {
// Surface $call->tool, $call->arguments to a human reviewer
}
}
Approve, deny, or modify
A reviewer isn't limited to a binary yes or no. The API supports adjusting the arguments before the tool actually runs, which matters for something like a refund amount a human might want to reduce rather than reject outright:
// Approve as-is
$run->approve($call->id);
// Deny, with a reason the agent can see and react to
$run->deny($call->id, reason: 'Refund exceeds policy limit for this order.');
// Approve with modified arguments
$run->approve($call->id, arguments: ['orderId' => $call->arguments['orderId'], 'amount' => 25.00]);
Once resolved, the agent's run continues from where it left off, incorporating the reviewer's decision into its next step rather than starting over.
Why this matters for teams shipping agents
Plenty of teams building on the Laravel AI SDK have been rolling their own approval layer already, usually as a queued job with a database flag and a custom admin panel. Having this as a first-party API means that pattern is now consistent across the ecosystem, and packages built on top of the AI SDK can rely on the same approval mechanics instead of each inventing their own.
If you're building anything that lets an agent act on customer data, billing, or infrastructure, this is worth adopting even if your current approval flow works fine, since it puts you on a supported path as the SDK continues to evolve rather than maintaining a parallel implementation yourself.
عبدالرحمن ربيع
Software Engineer & AI Builder
مطور برمجيات متكامل ومصمم جرافيك مع أكثر من 4 سنوات خبرة في بناء تطبيقات الويب الحديثة باستخدام PHP و JavaScript و HTML و CSS. خلفية قوية في تصميم UI/UX واستخدام متقدم لأدوات الذكاء الاصطناعي لتعزيز كفاءة التطوير والأتمتة واتخاذ القرارات. حاصل على ماجستير تنفي...
مقالات ذات صلة
يضيف Laravel Pint علمًا بشفرة لتنسيق قوالب الشفرة الخاصة بك
اقرأ المقال
باحثون من برينستون وآنت جروب وستانفورد يقدمون AQuA: إطار عمل وكيل من جزأين لاكتشاف العوامل المستقلة وتطوير النماذج في التمويل الكمي
اقرأ المقال
Alibaba Qwen Releases Qwen3.8-Omni-Flash: A 1M-Context Omni-Modal Model Built Around Agentic Audio-Video Understanding and Tool Use
اقرأ المقال
التعليقات (0)
كن أول من يعلّق على هذا المقال.