إنشاء وكلاء مُدارين

تتيح لك الوكلاء المُدارون على Gemini API توسيع نطاق "وكيل Antigravity" باستخدام التعليمات والمهارات والبيانات الخاصة بك. يمكنك تخصيص الوكيل بشكل مضمّن في وقت التفاعل، أو حفظ الإعداد كوكيل مُدار تستدعيه حسب رقم التعريف.

تخصيص "وكيل Antigravity"

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

  • اختيار النموذج: اختَر نموذج Gemini الأساسي من خلال agent_config (الإعداد التلقائي هو Gemini 3.7 Flash).
  • تعليمات النظام: مرِّر نصًا مضمّنًا من خلال system_instruction لتحديد السلوك.
  • الأدوات: يمكنك إلغاء الأدوات التلقائية (تنفيذ الرموز البرمجية والبحث وسياق عنوان URL) أو تسجيل خوادم MCP عن بُعد أو تحديد وظائف مخصّصة (استدعاء الدوال).
  • الملفات والمهارات: يمكنك تثبيت ملفات، مثل AGENTS.md وSKILL.md، في البيئة.

في ما يلي مثال على تمرير كل من هذه العناصر الثلاثة بشكل مضمّن:

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Analyze the Q1 revenue data and create a slide deck.",
    system_instruction="You are a data analyst. Always include visualizations and export results as PDF.",        
    environment={
        "type": "remote",
        "sources": [
            {
                "type": "inline",
                "target": ".agents/AGENTS.md",
                "content": "Always use matplotlib for charts. Include a summary table in every report.",
            },
            {
                "type": "inline",
                "target": ".agents/skills/slide-maker/SKILL.md",
                "content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results.",
            },
        ],
    },
)

print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    agent: "antigravity-preview-05-2026",
    input: "Analyze the Q1 revenue data and create a slide deck.",
    system_instruction: "You are a data analyst. Always include visualizations and export results as PDF.",        
    environment: {
        type: "remote",
        sources: [
            {
                type: "inline",
                target: ".agents/AGENTS.md",
                content: "Always use matplotlib for charts. Include a summary table in every report.",
            },
            {
                type: "inline",
                target: ".agents/skills/slide-maker/SKILL.md",
                content: "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results.",
            },
        ],
    },
}, { timeout: 300000 });

console.log(interaction.output_text);

راحة

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "agent": "antigravity-preview-05-2026",
    "input": "Analyze the Q1 revenue data and create a slide deck.",
    "system_instruction": "You are a data analyst. Always include visualizations and export results as PDF.",
    "environment": {
        "type": "remote",
        "sources": [
            {
                "type": "inline",
                "target": ".agents/AGENTS.md",
                "content": "Always use matplotlib for charts. Include a summary table in every report."
            },
            {
                "type": "inline",
                "target": ".agents/skills/slide-maker/SKILL.md",
                "content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results."
            }
        ]
    }
}'

يتم تحديد كل شيء في وقت التفاعل. ولست بحاجة إلى تسجيل أي شيء أولاً. يوفر إطار عمل "وكيل Antigravity" وقت التشغيل (تنفيذ الرموز البرمجية وإدارة الملفات والوصول إلى الويب) وطبقات الإعداد الخاصة بك في الأعلى.

الأدوات وتعليمات النظام

يمكنك تخصيص سلوك الوكيل وإمكاناته لتفاعل معيّن باستخدام المَعلمتَين system_instruction وtools.

  • تعليمات النظام: استخدِم المَعلمة system_instruction لتمرير نص مضمّن يحدّد سلوك الوكيل. هذا مثالي لإجراء تعديلات سريعة تريد تغييرها لكل مكالمة. إنّ system_instruction وAGENTS.md إضافيتان، ويتم تطبيق كلتيهما إذا كانتا متوفرتَين.
  • الأدوات: بشكلٍ تلقائي، يمكن لـ "وكيل Antigravity" الوصول إلى code_execution وgoogle_search وurl_context. يمكنك إلغاء هذه القائمة من خلال تمرير المَعلمة tools في وقت التفاعل. يمكنك أيضًا تسجيل خوادم MCP عن بُعد أو تحديد وظائف مخصّصة (استدعاء الدوال) لربط الوكيل بواجهات برمجة التطبيقات وقواعد البيانات الخاصة بك. للاطّلاع على التفاصيل الكاملة حول الأدوات المتاحة، يُرجى الرجوع إلى مقالة "وكيل Antigravity: الأدوات المتوافقة".

التخصيص على مستوى الملفات

بنية دليل الوكيل

على الرغم من أنّه يمكنك تمرير الإعداد بشكل مضمّن، ننصحك بتنظيم ملفات الوكيل في دليل منظَّم. يسهّل ذلك إدارة الملفات والتحكّم في إصداراتها وتثبيتها في بيئة الوكيل.

يبدو دليل مشروع الوكيل النموذجي على النحو التالي: