انتقل إلى المحتوى
أمين أبوزيد
MID-069

استدعاء الأدوات والوكلاء

  • 8 درس
  • 3.5 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • استدعاء الدوال (Function Calling)
  • تصميم الأدوات الآمنة
  • الآثار الجانبية والتكرار الآمن (idempotency)
  • التفويض
  • الموافقة البشرية
  • حلقات الوكلاء (Agent Loops)
  • مفهوم Model Context Protocol

تعلّم أولًا

3.5 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Explain how tool (function) calling works: the model proposes a call, the application decides whether and how to execute it.
  2. Design tools with narrow scope, typed parameters, idempotency, and clear error results.
  3. Enforce authorization on every tool call using the end user's identity, never the model's judgment.
  4. Require human approval for tools with side effects (refunds, cancellations) and bound agent loops with step, time, and cost limits.
  5. Describe the Model Context Protocol (MCP) as a standard way to expose tools and data to models, and when it is worth adopting.

الدروس

  1. 01من الإجابة إلى التنفيذ
  2. 02كيف يعمل استدعاء الأدوات
  3. 03تصميم أدوات آمنة
  4. 04التفويض والهوية في استدعاءات الأدوات
  5. 05الآثار الجانبية والتكرار الآمن والموافقة البشرية
  6. 06حلقات الوكلاء وحدودها؛ MCP كمفهوم
  7. 07عرض عملي: أداة حالة الطلب تحترم الملكية
  8. 08عرض عملي: طلب استرداد يُوجَّه إلى موافقة بشرية

المختبر والتمارين

Lab

MID-069-LAB1 · Assistant with tools

Outcomes: 1–5 · Time: ~3.5 h Give the order-support assistant read-only tools (order status, shipment tracking) that call Shop Platform services with the customer's token, and a "request refund" tool that only creates a pending request for a human agent. Add step, time, and cost limits to the agent loop. Acceptance: a customer can never see another customer's order through the assistant (test); no tool with side effects executes without approval; loops stop at the configured step and cost limits.

Exercises (assessment: tool-design review)

IDOutcomeTask
MID-069-EX011Draw the sequence of one tool call and mark which steps the model does and which the application does.
MID-069-EX022Redesign run_sql(query) into three narrow tools with typed parameters and error results.
MID-069-EX033Review a tool that takes userId as an argument; fix it so identity comes from the session.
MID-069-EX044Add an idempotency key and a pending-approval state to cancel_order.
MID-069-EX054Write a loop with step, time, and cost limits and a test where each limit stops it.
MID-069-EX065Write a half-page note: would you adopt MCP for Shop's three tools? State the trigger that would change your answer.
MID-069-EX072–4Review a provided tool set; list authorization, idempotency, and approval gaps with fixes.
أظهر الحلول
  • EX01 Model: proposes name and arguments, writes the final answer. Application: validates, authorizes, executes, returns the result.
  • EX02 get_order_status(orderId), list_my_orders(page), get_shipment(orderId); each with a positive-long or bounded page parameter and NOT_FOUND/NOT_ALLOWED errors.
  • EX03 Remove userId; read the subject from the authenticated token and forward the token downstream.
  • EX04 Tool creates PENDING request keyed by (orderId, action); repeat calls return the same request; a human endpoint moves it to APPROVED/EXECUTED.
  • EX05 for (step = 0; step < maxSteps && elapsed < maxTime && cost < maxCost; step++); tests use a fake model that always asks for another call.
  • EX06 Three tools in one app: no, a direct tool interface is simpler; adopt MCP when several assistants or teams must share tools. Authorization is needed either way.
  • EX07 Typical gaps: service-account calls, model-supplied user id, refund executing directly, no idempotency key, no limits; fix each as in EX03-EX05.

Outcome 1 is also checked by quiz Q01-Q03; outcome 5 by quiz Q09-Q10 and EX06.

الاختبار

Outcomes: O1 how tool calling works · O2 tool design · O3 authorization · O4 approval and loop limits · O5 MCP.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1In tool calling, the model:O1
  2. 2Tool arguments produced by the model should be treated as:O1
  3. 3After the tool runs, its result is:O1
  4. 4Which tool is best designed?O2
  5. 5A good error result is:O2
  6. 6Tool calls should run with:O3
  7. 7Who decides whether a refund is allowed?O3
  8. 8A refund tool should:O4
  9. 9Why use an idempotency key?O4
  10. 10MCP is:O5

الجزء العملي

Seven exercises MID-069-EX01 to EX07 (EX07 is the tool-design review) plus the assistant lab. Pass: at least five exercises including EX07, and a lab where the ownership test passes and no side-effect tool runs without approval.

أخطاء شائعة

Tools that run with a service account and bypass ownership checks; letting the model decide whether an action is allowed; non-idempotent tools retried by the agent loop; unbounded loops.

التقييم

Tool-design review — find authorization, idempotency, and approval gaps in a provided tool set.

الصلة بالمسار الوظيفي

Agentic features at Senior levels (SRC-021) and the AI platform's tool governance (SRB-021).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.