Skip to content

BuilderIO/agent-native / packages/core/docs

agent-native-docs

Unverified

How to look up version-matched Agent-Native framework docs and source in node_modules. Use before coding against @agent-native/core APIs or advanced features.

FileKindSize
AGENTS.mdmarkdown6.0 KB
SKILL.mdskill md2.2 KB
content/a2a-protocol.mdxmarkdown37.6 KB
content/actions-access-control.mdxmarkdown28.9 KB
content/actions-advanced.mdxmarkdown13.1 KB
content/actions-agent-tools.mdxmarkdown5.6 KB
content/actions-defining.mdxmarkdown31.2 KB
content/actions-other-surfaces.mdxmarkdown10.3 KB
content/actions-overview.mdxmarkdown8.3 KB
content/actions-run-context.mdxmarkdown9.1 KB
content/add-ui-to-your-agent.mdxmarkdown5.0 KB
content/administered-deployments.mdxmarkdown7.7 KB
content/agent-mentions.mdxmarkdown10.2 KB
content/agent-native-config.mdxmarkdown34.9 KB
content/agent-native-toolkit.mdxmarkdown17.3 KB
content/agent-resources.mdxmarkdown27.0 KB
content/agent-surfaces.mdxmarkdown33.8 KB
content/agent-teams.mdxmarkdown13.4 KB
content/agent-web-surfaces.mdxmarkdown10.7 KB
content/agentkit.mdxmarkdown14.0 KB
content/audit-log.mdxmarkdown14.3 KB
content/authentication.mdxmarkdown30.7 KB
content/automation-connectors.mdxmarkdown7.8 KB
content/automations.mdxmarkdown26.7 KB
content/aws-amplify.mdxmarkdown10.7 KB
content/aws-lambda.mdxmarkdown13.9 KB
content/aws-rds.mdxmarkdown1.7 KB
content/azure-postgresql.mdxmarkdown1.8 KB
content/azure-static-web-apps.mdxmarkdown9.1 KB
content/blueprint-installer.mdxmarkdown6.3 KB
content/cli-adapters.mdxmarkdown5.7 KB
content/client-advanced.mdxmarkdown13.1 KB
content/client-agent-chat.mdxmarkdown17.7 KB
content/client-data.mdxmarkdown19.3 KB
content/client-entry-points.mdxmarkdown1.2 KB
content/client-overview.mdxmarkdown10.6 KB
content/client-routing.mdxmarkdown5.7 KB
content/client-sync-internals.mdxmarkdown5.2 KB
content/cloneable-saas.mdxmarkdown16.6 KB
content/cloud-sql.mdxmarkdown2.3 KB
content/cloudflare.mdxmarkdown8.3 KB
content/code-agents-ui.mdxmarkdown26.6 KB
content/components.mdxmarkdown42.9 KB
content/context-awareness.mdxmarkdown24.9 KB
content/create-with-an-agent.mdxmarkdown8.8 KB
content/creating-templates.mdxmarkdown21.6 KB
content/cross-app-connect-design.mdxmarkdown8.4 KB
content/cross-app-sso.mdxmarkdown8.7 KB
content/custom-design-system.mdxmarkdown17.3 KB
content/data-programs.mdxmarkdown25.0 KB
content/decisions.mdxmarkdown7.9 KB
content/deno-deploy.mdxmarkdown7.2 KB
content/deploy-an-app.mdxmarkdown5.0 KB
content/deployment-environment-variables.mdxmarkdown16.3 KB
content/deployment.mdxmarkdown11.3 KB
content/dispatch.mdxmarkdown18.6 KB
content/docker.mdxmarkdown8.1 KB
content/docs-components.mdxmarkdown28.9 KB
content/doctor.mdxmarkdown21.3 KB
content/drafts/clips-experimental-features.mdmarkdown5.4 KB
content/drop-in-agent.mdxmarkdown16.0 KB
content/durable-background-runs.mdxmarkdown13.8 KB
content/durable-resume.mdxmarkdown10.0 KB
content/embedding-sdk.mdxmarkdown31.3 KB
content/environment-variables.mdxmarkdown29.9 KB
content/evals.mdxmarkdown12.4 KB
content/extensions.mdxmarkdown34.8 KB
content/external-agents-catalog.mdxmarkdown40.5 KB
content/external-agents.mdxmarkdown29.3 KB
content/file-uploads.mdxmarkdown10.7 KB
content/generative-ui.mdxmarkdown10.8 KB
content/getting-started-actions.mdxmarkdown2.7 KB
content/getting-started-pages.mdxmarkdown2.6 KB
content/getting-started.mdxmarkdown7.2 KB
content/harness-agents.mdxmarkdown16.9 KB
content/http-api.mdxmarkdown20.9 KB
content/integrations.mdxmarkdown33.8 KB
content/internationalization.mdxmarkdown6.2 KB
content/key-concepts.mdxmarkdown30.6 KB
content/koyeb.mdxmarkdown7.3 KB
content/locales/ar-SA/a2a-protocol.mdxmarkdown48.5 KB
content/locales/ar-SA/actions-access-control.mdxmarkdown40.8 KB
content/locales/ar-SA/actions-advanced.mdxmarkdown16.3 KB
content/locales/ar-SA/actions-agent-tools.mdxmarkdown8.1 KB
content/locales/ar-SA/actions-defining.mdxmarkdown42.2 KB
content/locales/ar-SA/actions-other-surfaces.mdxmarkdown14.5 KB
content/locales/ar-SA/actions-overview.mdxmarkdown11.3 KB
content/locales/ar-SA/actions-run-context.mdxmarkdown11.1 KB
content/locales/ar-SA/add-ui-to-your-agent.mdxmarkdown3.7 KB
content/locales/ar-SA/administered-deployments.mdxmarkdown6.4 KB
content/locales/ar-SA/agent-mentions.mdxmarkdown11.8 KB
content/locales/ar-SA/agent-native-toolkit.mdxmarkdown17.3 KB
content/locales/ar-SA/agent-resources.mdxmarkdown36.8 KB
content/locales/ar-SA/agent-surfaces.mdxmarkdown48.4 KB
content/locales/ar-SA/agent-teams.mdxmarkdown18.5 KB
content/locales/ar-SA/agent-web-surfaces.mdxmarkdown14.3 KB
content/locales/ar-SA/audit-log.mdxmarkdown15.9 KB
content/locales/ar-SA/authentication.mdxmarkdown39.8 KB
content/locales/ar-SA/automations.mdxmarkdown31.3 KB
content/locales/ar-SA/aws-amplify.mdxmarkdown14.9 KB
content/locales/ar-SA/aws-lambda.mdxmarkdown18.9 KB
content/locales/ar-SA/aws-rds.mdxmarkdown319 B
content/locales/ar-SA/azure-postgresql.mdxmarkdown344 B
content/locales/ar-SA/azure-static-web-apps.mdxmarkdown12.4 KB
content/locales/ar-SA/blueprint-installer.mdxmarkdown8.4 KB
content/locales/ar-SA/cli-adapters.mdxmarkdown6.7 KB
content/locales/ar-SA/client-advanced.mdxmarkdown17.8 KB
content/locales/ar-SA/client-agent-chat.mdxmarkdown23.0 KB
content/locales/ar-SA/client-data.mdxmarkdown23.8 KB
content/locales/ar-SA/client-entry-points.mdxmarkdown1.6 KB
content/locales/ar-SA/client-overview.mdxmarkdown13.9 KB
content/locales/ar-SA/client-routing.mdxmarkdown7.2 KB
content/locales/ar-SA/client-sync-internals.mdxmarkdown7.3 KB
content/locales/ar-SA/cloneable-saas.mdxmarkdown23.2 KB
content/locales/ar-SA/cloud-sql.mdxmarkdown317 B
content/locales/ar-SA/cloudflare.mdxmarkdown11.9 KB
content/locales/ar-SA/code-agents-ui.mdxmarkdown34.2 KB
content/locales/ar-SA/components.mdxmarkdown51.5 KB
content/locales/ar-SA/context-awareness.mdxmarkdown33.1 KB
content/locales/ar-SA/create-with-an-agent.mdxmarkdown12.2 KB
content/locales/ar-SA/creating-templates.mdxmarkdown26.8 KB
content/locales/ar-SA/cross-app-connect-design.mdxmarkdown1.5 KB
content/locales/ar-SA/cross-app-sso.mdxmarkdown9.7 KB
content/locales/ar-SA/custom-design-system.mdxmarkdown21.6 KB
content/locales/ar-SA/data-programs.mdxmarkdown33.3 KB
content/locales/ar-SA/decisions.mdxmarkdown9.1 KB
content/locales/ar-SA/deno-deploy.mdxmarkdown10.1 KB
content/locales/ar-SA/deploy-an-app.mdxmarkdown7.1 KB
content/locales/ar-SA/deployment-environment-variables.mdxmarkdown21.3 KB
content/locales/ar-SA/deployment.mdxmarkdown13.9 KB
content/locales/ar-SA/dispatch.mdxmarkdown27.3 KB
content/locales/ar-SA/docker.mdxmarkdown11.3 KB
content/locales/ar-SA/doctor.mdxmarkdown3.4 KB
content/locales/ar-SA/drop-in-agent.mdxmarkdown20.8 KB
content/locales/ar-SA/durable-resume.mdxmarkdown15.4 KB
content/locales/ar-SA/embedding-sdk.mdxmarkdown41.3 KB
content/locales/ar-SA/evals.mdxmarkdown13.3 KB
content/locales/ar-SA/extensions.mdxmarkdown34.0 KB
content/locales/ar-SA/external-agents.mdxmarkdown89.3 KB
content/locales/ar-SA/file-uploads.mdxmarkdown13.4 KB
content/locales/ar-SA/getting-started-actions.mdxmarkdown3.2 KB
content/locales/ar-SA/getting-started-pages.mdxmarkdown3.2 KB
content/locales/ar-SA/getting-started.mdxmarkdown9.7 KB
content/locales/ar-SA/harness-agents.mdxmarkdown22.3 KB
content/locales/ar-SA/internationalization.mdxmarkdown8.2 KB
content/locales/ar-SA/key-concepts.mdxmarkdown42.0 KB
content/locales/ar-SA/koyeb.mdxmarkdown10.2 KB
content/locales/ar-SA/mcp-apps.mdxmarkdown33.7 KB
content/locales/ar-SA/mcp-clients.mdxmarkdown35.0 KB
content/locales/ar-SA/mcp-protocol.mdxmarkdown27.6 KB
content/locales/ar-SA/messaging.mdxmarkdown59.2 KB
content/locales/ar-SA/multi-app-workspace.mdxmarkdown36.2 KB
content/locales/ar-SA/multi-tenancy.mdxmarkdown7.5 KB
content/locales/ar-SA/native-chat-ui.mdxmarkdown21.3 KB
content/locales/ar-SA/neon.mdxmarkdown244 B
content/locales/ar-SA/netlify.mdxmarkdown15.2 KB
content/locales/ar-SA/node-docker.mdxmarkdown878 B
content/locales/ar-SA/node-js.mdxmarkdown8.4 KB
content/locales/ar-SA/notifications.mdxmarkdown16.2 KB
content/locales/ar-SA/observability.mdxmarkdown45.2 KB
content/locales/ar-SA/observational-memory.mdxmarkdown10.9 KB
content/locales/ar-SA/onboarding.mdxmarkdown16.9 KB
content/locales/ar-SA/organizations-teams-permissions.mdxmarkdown5.9 KB
content/locales/ar-SA/package-lifecycle.mdxmarkdown3.0 KB
content/locales/ar-SA/plan-plugin.mdxmarkdown23.0 KB
content/locales/ar-SA/portal.mdxmarkdown636 B
content/locales/ar-SA/postgres.mdxmarkdown487 B
content/locales/ar-SA/pr-visual-recap.mdxmarkdown53.9 KB
content/locales/ar-SA/privacy-and-data-rights.mdxmarkdown6.2 KB
content/locales/ar-SA/processors.mdxmarkdown8.7 KB
content/locales/ar-SA/progress.mdxmarkdown10.7 KB
content/locales/ar-SA/pure-agent-apps.mdxmarkdown5.0 KB
content/locales/ar-SA/real-time-collaboration.mdxmarkdown55.6 KB
content/locales/ar-SA/recorder.mdxmarkdown16.7 KB
content/locales/ar-SA/recurring-jobs.mdxmarkdown23.8 KB
content/locales/ar-SA/render.mdxmarkdown11.2 KB
content/locales/ar-SA/sandbox-adapters.mdxmarkdown18.0 KB
content/locales/ar-SA/security.mdxmarkdown31.5 KB
content/locales/ar-SA/server-database.mdxmarkdown27.6 KB
content/locales/ar-SA/server-middleware.mdxmarkdown7.9 KB
content/locales/ar-SA/server-overview.mdxmarkdown12.2 KB
content/locales/ar-SA/server-plugins.mdxmarkdown9.1 KB
content/locales/ar-SA/server-routes.mdxmarkdown14.3 KB
content/locales/ar-SA/sharing.mdxmarkdown28.6 KB
content/locales/ar-SA/skills-guide.mdxmarkdown27.0 KB
content/locales/ar-SA/ssr-caching.mdxmarkdown7.4 KB
content/locales/ar-SA/supabase.mdxmarkdown264 B
content/locales/ar-SA/syncing-template-changes.mdxmarkdown11.7 KB
content/locales/ar-SA/telemetry.mdxmarkdown21.9 KB
content/locales/ar-SA/template-analytics.mdxmarkdown26.4 KB
content/locales/ar-SA/template-assets.mdxmarkdown31.9 KB
content/locales/ar-SA/template-brain.mdxmarkdown29.7 KB
content/locales/ar-SA/template-calendar-agent.mdxmarkdown10.2 KB
content/locales/ar-SA/template-calendar-developers.mdxmarkdown33.4 KB
content/locales/ar-SA/template-calendar-features.mdxmarkdown14.4 KB
content/locales/ar-SA/template-calendar-integrations.mdxmarkdown6.2 KB
content/locales/ar-SA/template-calendar.mdxmarkdown4.4 KB
content/locales/ar-SA/template-chat-agent.mdxmarkdown4.7 KB
content/locales/ar-SA/template-chat-developers.mdxmarkdown31.3 KB
content/locales/ar-SA/template-chat-features.mdxmarkdown9.9 KB

content/locales/ar-SA/agent-teams.mdx

View on GitHub
---
title: "فرق الوكلاء"
description: "يعمل مفوضو الوكلاء الرئيسيون مع الوكلاء الفرعيين الذين يعملون في سلاسل الرسائل الخاصة بهم ويظهرون كشرائح معاينة مباشرة مضمنة في الدردشة."
---

# فرق الوكلاء

إن دردشة الوكيل هي **منسقة** وليست كتلة واحدة. عندما يقوم الوكيل الرئيسي بمهمة من الأفضل أن يمتلكها أحد المتخصصين - "اكتب هذه الرسالة الإلكترونية بصوتي"، "قم بإجراء تحليل BigQuery"، "مراجعة العلاقات العامة هذه" - فإنه يولد وكيلًا فرعيًا في سلسلة الرسائل والأدوات والسياق الخاصة به. يظهر الوكيل الفرعي كمعاينة مباشرة **شريحة** مضمنة في الدردشة الرئيسية؛ انقر عليه لفتح المحادثة الكاملة كعلامة تبويب.

يحافظ هذا على تركيز الموضوع الرئيسي، ويسمح للوكلاء الفرعيين بالعمل بالتوازي، ويمنحك مسار تدقيق نظيف لأي عمل مفوض.

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

## النموذج العقلي {#mental-model}

- **الدردشة الرئيسية** — المنسق. يقرأ طلبك، المندوبين. نادرًا ما يؤدي العمل الشاق بحد ذاته.
- **الوكلاء الفرعيون** — يتم تشغيلهم باستخدام سلسلة الرسائل الخاصة بهم، وموجه النظام الخاص بهم، ومجموعة الأدوات الخاصة بهم. يتم تعيين كل منها إلى ملف تعريف "الوكيل المخصص" في [موارد الوكيل](/docs/agent-resources).
- **الرقائق** — بطاقة المعاينة الغنية التي تظهر مضمنة في الدردشة الرئيسية، وتعرض الخطوة الحالية للوكيل الفرعي، ومخرجات البث، والملخص النهائي. تم طيها بشكل افتراضي؛ يتم توسيعه إلى المحادثة الكاملة عند النقر.
- **المراسلة ثنائية الاتجاه** — يمكن للوكيل الرئيسي إرسال متابعات إلى وكيل فرعي قيد التشغيل؛ يمكن للوكيل الفرعي الرد على الرسائل عندما يصل إلى نقطة غامضة.

تستمر حالة الوكيل الفرعي في جدول `application_state` SQL (ضمن `agent-task:<taskId>`)، لذلك تظل المهام قادرة على البقاء على قيد الحياة مع عمليات التشغيل الباردة بدون خادم والعمل عبر عمليات متعددة.

<Diagram id="doc-block-1yz8edc" title={"المنسقين والمتخصصين"} summary={"تقوم الدردشة الرئيسية بتفويض الوكلاء الفرعيين الذين يعملون في سلاسل الرسائل الخاصة بهم ويقدمون تقاريرهم كشرائح مضمنة."}>

```html
<div class="at-orc">
  <div class="diagram-card main">
    <span class="diagram-pill accent">الدردشة الرئيسية</span
    ><small class="diagram-muted">منسق &mdash; يقرأ طلبك، المندوبين</small>
  </div>
  <div class="at-fan">
    <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
    <div class="at-subs">
      <div class="diagram-box">
        مراجعة الكود<br /><small class="diagram-muted"
          >الخيط الخاص &amp; اِسْتَدْعَى</small
        >
      </div>
      <div class="diagram-box">
        تحليل BigQuery<br /><small class="diagram-muted">الأدوات الخاصة</small>
      </div>
      <div class="diagram-box">
        البريد الإلكتروني في الصوت<br /><small class="diagram-muted"
          >السياق الخاص</small
        >
      </div>
    </div>
  </div>
  <div class="diagram-pill">يظهر كل منها مضمنًا كشريحة حية &#8635;</div>
</div>
```

```css
.at-orc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.at-orc .diagram-card {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.at-orc .at-fan {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.at-orc .diagram-arrow {
  font-size: 22px;
}
.at-orc .at-subs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.at-orc .diagram-box {
  text-align: center;
}
```

</Diagram>

## متى يتم إنشاء وكيل فرعي {#when-to-spawn}

تفرخ عند المهمة:

- يحتاج إلى **موجه نظام** مختلف (صوت أو نغمة متخصصة، على سبيل المثال، "مراجعة الكود").
- يحتوي على سلسلة أدوات **طويلة الأمد** من شأنها تلويث السياق الرئيسي.
- يمكن تشغيله **بالتوازي** مع الأعمال الأخرى التي يقوم بها الوكيل الرئيسي.
- مملوكة من قبل **فريق مختلف** لديه بالفعل ملف تعريف وكيل مخصص.

لا تلجأ إلى عمل تافه لمرة واحدة - قم باستدعاء الإجراء مباشرة.

## استدعاء وكيل فرعي {#invoking}

ثلاث طرق لبدء وكيل فرعي، من الأقل إلى الأكثر وضوحًا:

### 1. `@mention` وكيل مخصص {#mention}

يكتب المستخدم `@agent-name` في مؤلف الدردشة. تظهر قائمة منسدلة للوكلاء الفرعيين لمساحة العمل. يؤدي اختيار واحدة إلى إدراج شريحة؛ عند الإرسال، يقوم الوكيل الرئيسي بتفويض الرسالة إلى ذلك الوكيل الفرعي.

يعيش الوكلاء المخصصون في مساحة العمل في `agents/<slug>.md` - ملف Markdown مع المادة الأمامية YAML. راجع [Custom Agents](/docs/agent-resources#custom-agents) لمعرفة التنسيق.

### 2. يقوم الوكيل الرئيسي بالتفويض تلقائيًا {#auto-delegate}

يمنح إطار العمل الوكيل الرئيسي أداة `agent-teams`. عندما يقرر النموذج أن المهمة تناسب ملف تعريف وكيل فرعي مسجل، فإنه يستدعي الأداة باستخدام `action: "spawn"` ومعلمة `agent` اختيارية لتسمية ملف تعريف من `agents/*.md`. تظهر شريحة؛ يعمل الوكيل الفرعي. ينتظر الوكيل الرئيسي (أو يتحرك بالتوازي) ويدمج النتيجة عندما ينتهي الوكيل الفرعي.

مجموعة إجراءات `agent-teams` الكاملة هي:

| الإجراء       | الغرض                                    |
| ------------- | ---------------------------------------- |
| `spawn`       | ابدأ مهمة وكيل فرعي جديدة                |
| `status`      | التحقق من تقدم الوكيل الفرعي قيد التشغيل |
| `read-result` | احصل على مخرجات الوكيل الفرعي النهائية   |
| `send`        | مراسلة وكيل فرعي قيد التشغيل             |
| `list`        | عرض كافة المهام للمستخدم الحالي          |

### 3. تفرخ برمجي {#programmatic-spawn}

بالنسبة لعمليات التكامل على مستوى إطار العمل، استخدم `spawnTask()` من `@agent-native/core/server`:

```ts
import { spawnTask } from "@agent-native/core/server";

const task = await spawnTask({
  description: "Draft an outreach email to this lead",
  instructions: "Match the user's voice from memory/MEMORY.md.",
  ownerEmail: user.email,
  systemPrompt: mailAgentSystemPrompt,
  actions: mailActions,
  // Pass either apiKey or engine — engine takes precedence.
  apiKey: process.env.ANTHROPIC_API_KEY, // optional if engine is provided
  parentSend: emit, // streaming sender for the parent chat response
});
```

لن تستدعي معظم أكواد التطبيق هذا مباشرة - حيث يقوم إطار العمل بذلك تحت غطاء `@mentions` ولأداة `agent-teams`. يمكنك الوصول إلى `spawnTask()` فقط عندما تقوم بتوصيل نقطة دخول جديدة (على سبيل المثال, زر يبدأ مهمة خلفية تعمل كوكيل فرعي).

## دورة حياة المهمة {#lifecycle}

<Diagram id="doc-block-1lkr7n1" title={"ما يفعله spawnTask()"} summary={"ينشئ كل نشر سلسلة رسائل، ويستمر في الحالة إلى SQL، ويقوم بتدفق أحداث الشريحة حتى الاكتمال."}>

```html
<div class="at-life">
  <div class="diagram-box"><code>مهمة تفرخ ()</code></div>
  <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
  <div class="diagram-card">
    <span class="diagram-pill">إنشاء موضوع</span
    ><small class="diagram-muted"
      >صف جديد في <code>chat_threads</code>، الوصف كرسالة أولى</small
    >
  </div>
  <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
  <div class="diagram-card">
    <span class="diagram-pill">استمرار الحالة</span
    ><small class="diagram-muted"
      ><code>مهمة الوكيل:&lt;بطاقة تعريف&gt;</code> &rarr;
      <code>application_state</code>الحالة = قيد التشغيل</small
    >
  </div>
  <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
  <div class="diagram-card">
    <span class="diagram-pill accent">تدفق</span
    ><small class="diagram-muted"
      ><code>agent_task_started</code> &rarr; تظهر الشريحة؛
      <code>agent_task_step</code> &rarr; تحديثات الشريحة مباشرة</small
    >
  </div>
  <div class="diagram-arrow diagram-muted" aria-hidden="true">&darr;</div>
  <div class="diagram-card ok">
    <span class="diagram-pill ok">مكتمل</span
    ><small class="diagram-muted"
      >الحالة = مكتملة، اكتب ملخصًا + معاينة، انبعاث
      <code>agent_task_done</code></small
    >
  </div>
</div>
```

```css
.at-life {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  max-width: 560px;
}
.at-life .diagram-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
}
.at-life .diagram-box {
  align-self: flex-start;
}
.at-life .diagram-arrow {
  font-size: 18px;
  align-self: center;
}
```

</Diagram>

في أي وقت، يمكن للوكيل الأصلي استئناف الوكيل الفرعي من خلال المتابعة عبر `sendToTask(taskId, message)`. إذا كانت أخطاء الوكيل الفرعي, فإن `markTaskErrored(taskId, reason)` يسجل الفشل ويظهره للمستخدم.

ميزة المراسلة ثنائية الاتجاه متينة. تتم متابعات الوالدين لتشغيل الوكلاء الفرعيين
يتم تسليمها خلال دورة حياة المهمة؛ إذا لم يتمكن الوكيل الفرعي من استهلاكها في
الخطوة الحالية، يجب أن تظل في قائمة الانتظار ويتم تطبيقها في مكان آمن
نقطة الاستمرار. يمكن للوكلاء الفرعيين أيضًا الرد عندما يحتاجون إلى توضيح
بدلاً من الحظر بشكل غير مرئي.

## حالة مهمة القراءة {#reading-state}

من رمز الخادم أو actions آخر:

```ts
import { getTask, listTasks } from "@agent-native/core/server";

const task = await getTask(taskId); // single task
const tasks = await listTasks(); // all tasks for the user (sorted newest first)
```

الحقول الرئيسية `AgentTask`:

```ts
interface AgentTask {
  taskId: string;
  threadId: string;
  description: string;
  status: "running" | "completed" | "errored";
  preview: string; // short one-liner for the chip
  summary: string; // full summary once completed
  currentStep: string; // latest step label (updated while running)
  createdAt: number;
  delegationDepth?: number; // 1 for a direct sub-agent, 2 for a sub-agent of that sub-agent, etc.
  // Additional fields: parentThreadId, name, updatedAt, startedAt,
  // completedAt, runId, error
}
```

## ملفات تعريف الوكيل المخصصة {#profiles}

يتم تعيين الوكلاء الفرعيين إلى ملفات تعريف الوكلاء المخصصة — ملفات Markdown في `agents/<slug>.md` في مساحة العمل التي تظهر في القائمة المنسدلة `@mention` وتعمل كأهداف للتفويض. تمتلك [موارد الوكيل — Custom Agents](/docs/agent-resources#custom-agents) التنسيق الكامل (frontmatter، `tools`، `delegate-default`، تجاوزات النموذج).

## حارس عمق التفويض {#depth-guard}

يمكن للوكلاء الفرعيين إنشاء وكلاء فرعيين، وهو ما يمثل مخاطرة جامحة/تكلفة: يمكن أن تنتشر سلسلة غير محدودة من التفويضات إلى أجل غير مسمى. يفرض إطار العمل حدًا أقصى **على عمق التفويض**، من جانب الخادم، بشكل مستقل عن أي حماية على مستوى الأداة.

الدردشة ذات المستوى الأعلى هي العمق `0`. العامل الفرعي الذي يولده هو العمق `1`؛ قد يظهر هذا العامل الفرعي مرة أخرى (العمق `2`)؛ تم رفض النشر الذي من شأنه إنشاء وكيل فرعي للعمق `3` **. الحد الأقصى الافتراضي هو **2\*\*.

<Diagram id="doc-block-br5fuo" title={"حارس عمق التفويض (الغطاء الافتراضي 2)"} summary={"قد يؤدي كل مستوى إلى ظهور مستوى أعمق حتى الغطاء؛ تفرخ الماضي تم رفضه من جانب الخادم."}>

```html
<div class="at-depth">
  <div class="diagram-card ok">
    <span class="diagram-pill">العمق 0</span
    ><strong>دردشة على أعلى مستوى</strong
    ><small class="diagram-muted ok">قد ينشئ &darr;</small>
  </div>
  <div class="diagram-card ok">
    <span class="diagram-pill">العمق 1</span><strong>وكيل فرعي</strong
    ><small class="diagram-muted ok">قد ينشئ &darr;</small>
  </div>
  <div class="diagram-card warn">
    <span class="diagram-pill warn">العمق 2</span
    ><strong>وكيل فرعي لوكيل فرعي</strong
    ><small class="diagram-muted"
      >عند الحد الأقصى &mdash; لا يمكنه إنشاء المزيد</small
    >
  </div>
  <div class="diagram-card">
    <span class="diagram-pill warn">العمق 3</span><strong>مرفوض</strong
    ><small class="diagram-muted">خطأ من جانب الخادم</small>
  </div>
</div>
```

```css
.at-depth {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.at-depth .diagram-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
}
.at-depth .rung-1,
.at-depth .diagram-card:nth-child(2) {
  margin-inline-start: 24px;
}
.at-depth .diagram-card:nth-child(3) {
  margin-inline-start: 48px;
}
.at-depth .diagram-card:nth-child(4) {
  margin-inline-start: 72px;
}
```

</Diagram>

التنفيذ محيط: يعمل كل وكيل فرعي داخل `AsyncLocalStorage` الذي يسجل عمقه الخاص، وبالتالي فإن أي `spawnTask` يتم الوصول إليه بشكل انتقالي من هذا التشغيل يقرأ عمق الأصل الخاص به ويرفض بمجرد الوصول إلى الحد الأقصى - حتى لو تم تسليم أداة `agent-teams` إلى وكيل فرعي لا ينبغي أن يحصل عليها. يتم عرض القرار على أنه `evaluateSubagentDepth(parentDepth)` نقي وقابل للاختبار بالوحدة. يُرجع النشر المرفوض خطأً واضحًا: _"تم الوصول إلى الحد الأقصى لعمق التفويض (الحد الأقصى N)؛ لا يمكن نشر وكيل فرعي آخر."_

### تهيئة الحد الأقصى {#depth-guard-config}

تجاوز الإعداد الافتراضي في وقت النشر باستخدام `AGENT_NATIVE_MAX_SUBAGENT_DEPTH`:

| القيمة           | التأثير                                                                                                                                  |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| _(إلغاء الضبط)_  | الحد الأقصى الافتراضي لـ `2`.                                                                                                            |
| `0`              | **لا يجوز إنشاء أي وكلاء فرعيين** — يقوم وكيل المستوى الأعلى بكل العمل.                                                                  |
| `1`…`16`         | أن هناك مستويات عديدة للتفويض.                                                                                                           |
| غير صالح / `>16` | تعود القيمة غير الصحيحة / السالبة / NaN إلى `2`؛ أي شيء أعلى من `16` يتم تثبيته على `16` لذا لا يمكن للخطأ المطبعي تعطيل الحماية مطلقًا. |

```bash
AGENT_NATIVE_MAX_SUBAGENT_DEPTH=1   # مسموح بالوكلاء الفرعيين، لكن لا يمكنهم التفويض من الباطن
```

عندما يصل الوكيل الفرعي إلى الحد الأقصى أو أقل منه، يقوم إطار العمل بإدخال سطر في سياق وقت التشغيل الخاص به لإخباره بمدى عمقه وما إذا كان يمكنه تفويض المزيد، وبالتالي ينفق النموذج ميزانيته بشكل مناسب.

## ما هي الخطوة التالية

- [**موارد الوكيل — Custom Agents**](/docs/agent-resources#custom-agents) — تنسيق الملف الشخصي
- [**A2A Protocol**](/docs/a2a-protocol) — عندما يعيش "الوكيل الفرعي" في تطبيق مختلف تمامًا
- [**Actions**](/docs/actions-overview) — الأدوات التي يستدعيها الوكيل الفرعي
rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).Stars: 198kUpdated Claude CodeCodexUnverifiedInstall
doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.Stars: 198kUpdated Claude CodeCodexVerifiedInstall