Agent Mode
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تم تصميم "وضع الوكيل" في "Gemini في استوديو Android" للتعامل مع مهام التطوير المعقّدة والمتعدّدة المراحل التي تتجاوز ما يمكنك تجربته من خلال الدردشة مع Gemini فقط. يمكنك وصف هدف رفيع المستوى، وسينشئ الوكيل خطة وينفّذها، ويستدعي الأدوات اللازمة، ويجري تغييرات على عدة ملفات، ويصلح الأخطاء بشكل متكرر. يتيح لك سير العمل هذا الذي يعتمد على وكيل
التغلّب على التحديات المعقّدة وتسريع عملية التطوير.
البدء
للبدء في "وضع الوكيل" في Android Studio، اتّبِع الخطوات التالية:
- انقر على Gemini
في الشريط الجانبي. سجِّل الدخول وأكمِل عملية الإعداد إذا لزم الأمر.
- انقر على علامة التبويب الوكيل.
- قدِّم وصفًا للمَهمة التي تريد أن ينفّذها الوكيل.
أثناء تنفيذ الوكيل للخطوات اللازمة لإنجاز المهمة، سيكون بإمكانك مراجعة أي تغييرات والموافقة عليها.
اختياري: للموافقة على التغييرات تلقائيًا، انقر على خيارات الوكيل
> الموافقة التلقائية على التغييرات.
حالات الاستخدام
في ما يلي بعض الأمثلة على حالات الاستخدام التي يمكن أن يساعدك فيها الوكيل:
إصلاح أخطاء الإنشاء عندما تطلب من الوكيل إصلاح خطأ في الإصدار باستخدام طلب مثل "إصلاح أخطاء الإصدار في مشروعي"، سيطبّق الوكيل إصلاحًا مقترَحًا، وينشئ المشروع للتحقّق من الحلّ، ويكرّر العملية إلى أن يتم حلّ المشكلة.
يمكن أن يضيف "وضع الوكيل" عناصر واجهة المستخدم أو يعدّلها من تلقاء نفسه. على سبيل المثال، يمكنك أن تطلب من الوكيل "ضبط الوضع الداكن كوضع تلقائي في إعدادات المستخدم"، وسيبحث عن الملفات ذات الصلة ويقترح تغييرات لإنجاز المهمة. يمكنك معاينة تعديلات واجهة المستخدم على الفور في نافذة أداة الأجهزة قيد التشغيل.
من المفيد توفير بيانات تجريبية عند إنشاء نماذج أولية واختبار تطبيقك، وبدلاً من إنشاء بيانات وهمية يدويًا، يمكنك تفويض هذه المهمة إلى الوكيل.
في هذا المثال، طلبنا من الوكيل "إضافة جلستَين أخريَين إلى البيانات الوهمية". يعثر على الملف ذي الصلة ويضيف حدثَين آخرَين إلى قائمة mockSessions
.
إليك بعض الطلبات الأخرى التي يمكنك تجربتها:
- "اكتب اختبارات وحدات لـ <class> في <module>".
- "إنشاء مستندات للملف المفتوح حاليًا"
- "غيِّر عنوان التطبيق من <الاسم الحالي> إلى <الاسم الجديد>
- "حلّ مشكلة استثناء المؤشر الفارغ"
- أريد إعادة تصميم الرمز البرمجي من خلال نقل الدالة البرمجية القابلة للإنشاء <اسم الدالة البرمجية القابلة للإنشاء> إلى ملف جديد.
تأكَّد من تعديل جميع عمليات الاستيراد".
- "أريد إضافة زر جديد إلى الشاشة الرئيسية للتطبيق باسم "متابعة" ينقلني إلى قائمة بالمواضيع".
- "في العنصر القابل للإنشاء <اسم العنصر القابل للإنشاء>، قلِّل مساحة الحشو الخاصة بالمعدِّل <اسم المعدِّل>."
- "إنشاء زر مشاركة على وسائل التواصل الاجتماعي"
طريقة عمل الوكيل
في "وضع الوكيل"، يتم إرسال طلبك إلى Gemini API مع قائمة بالأدوات المتاحة. يمكنك اعتبار الأدوات مهارات، فهي تشمل القدرة على البحث عن الملفات وقراءتها والبحث عن النص داخل الملفات واستخدام أي خوادم MCP تم إعدادها وغير ذلك.
عندما تكلّف الوكيل بمهمة، يضع خطة ويحدّد الأدوات المطلوبة. قد تتطلّب منك بعض هذه الأدوات منح الإذن قبل أن يتمكّن الوكيل من استخدامها. بعد منح الإذن، يستخدم الوكيل الأداة لتنفيذ الإجراء اللازم وإرسال النتيجة إلى Gemini API. يعالج Gemini نتيجة الإجراء وينشئ ردًا آخر. وتستمر دورة العمل والتقييم هذه إلى أن تكتمل المهمة.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-05 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-05 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Agent Mode\n\nGemini in Android Studio's Agent Mode is designed to handle complex, multi-stage\ndevelopment tasks that go beyond what you can experience by just chatting with\nGemini. You can describe a high-level goal, and the agent will create and\nexecute a plan, invoking the necessary [tools](#how-it-works), making changes\nacross multiple files, and iteratively fixing bugs. This agent-assisted workflow\nempowers you to tackle intricate challenges, accelerating your development\nprocess.\n\nGet started\n-----------\n\nTo get started in Agent Mode in Android Studio, follow these steps:\n\n1. Click **Gemini** in the side bar. Sign in and onboard if you need to.\n2. Select the **Agent** tab.\n3. Describe the task you want the agent to perform.\n4. As the agent goes through the steps to accomplish the task, you'll have the\n option to review and approve any changes.\n\n5. Optional: To automatically approve changes, select **Agent options\n \\\u003e Auto-approve changes**.\n\nUse cases\n---------\n\nHere are some examples of use cases that the agent can help you with:\n\n- Fix build errors. When you ask the agent to fix a build error using a prompt\n like \"Fix build errors in my project,\" it will apply a recommended fix, build\n the project to verify the solution, and iterate until the issue is resolved.\n\n- Agent Mode can add or update UI elements all on its own. For example, ask the\n agent to \"Make dark mode the default in user preferences\" and it'll search for\n the relevant files and suggest changes to accomplish the task. You can\n immediately preview the UI updates in the **Running devices** tool window.\n\n- It's helpful to have mock data when prototyping and testing your app. Instead\n of manually creating fake data yourself, you can give that task to the agent.\n Here we've asked the agent to \"Add two more sessions to the fake data.\" It\n finds the relevant file and adds two more events to the `mockSessions` list.\n\nSome other prompts to try:\n\n- \"Write unit tests for \\\u003cclass\\\u003e in \\\u003cmodule\\\u003e.\"\n- \"Generate documentation for the currently open file.\"\n- \"Change the app title from \\\u003ccurrent name\\\u003e to \\\u003cnew name\\\u003e.\"\n- \"Resolve the null pointer exception.\"\n- \"Refactor my code by moving the \\\u003ccomposable name\\\u003e composable to a new file. Ensure all imports are updated.\"\n- \"Add a new button to the app's home screen called 'Follow' that takes you to a list of topics.\"\n- \"In the \\\u003ccomposable name\\\u003e composable, reduce the padding of the \\\u003cmodifier name\\\u003e modifier.\"\n- \"Create a share button to share to social media.\"\n\nHow the agent works\n-------------------\n\nIn Agent Mode, your prompt is sent to the Gemini API with a list of *tools* that\nare available. You can think of tools as skills: they include the ability to\nsearch for files, read files, search the text within files, use any\n[MCP servers](/studio/gemini/add-mcp-server) you have configured, and more.\n\nWhen you give the agent a task, it comes up with a plan and figures out which\ntools are needed. Some of these tools might need you to grant permission before\nthe agent can use them. Once you grant permission, the agent uses the tool to\nperform the necessary action and sends the result back to the Gemini API. Gemini\nprocesses the result of the action and generates another response. This cycle of\naction and evaluation continues until the task is complete."]]