Agent Mode
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מצב הסוכן של Gemini ב-Android Studio נועד לטפל במשימות פיתוח מורכבות ורב-שלביות, שחורגות מהיכולות של Gemini בשיחה רגילה. אתם יכולים לתאר מטרה כללית, והסוכן ייצור תוכנית ויבצע אותה, יפעיל את הכלים הנדרשים, יבצע שינויים בכמה קבצים ויפתור באגים באופן איטרטיבי. תהליך העבודה הזה עם סיוע של סוכן
מאפשר לכם להתמודד עם אתגרים מורכבים ומקצר את תהליך הפיתוח.
שנתחיל?
כדי להתחיל להשתמש במצב סוכן ב-Android Studio, פועלים לפי השלבים הבאים:
- בסרגל הצד, לוחצים על Gemini
. אם צריך, נכנסים לחשבון ומצטרפים ל-Google Workspace.
- בוחרים בכרטיסייה סוכן.
- מתארים את המשימה שרוצים שהסוכן יבצע.
במהלך ביצוע השלבים להשלמת המשימה על ידי הסוכן, תוכלו לבדוק ולאשר את השינויים.
אופציונלי: כדי לאשר שינויים באופן אוטומטי, בוחרים באפשרות אפשרויות של סוכן
> אישור אוטומטי של שינויים.
תרחישים לדוגמה
הנה כמה דוגמאות לתרחישי שימוש שבהם הסוכן יכול לעזור לכם:
מתקנים את שגיאות הבנייה. כשמבקשים מהסוכן לתקן שגיאת בנייה באמצעות הנחיה כמו "תקן שגיאות בנייה בפרויקט שלי", הוא יחיל תיקון מומלץ, יבנה את הפרויקט כדי לאמת את הפתרון ויחזור על הפעולה עד שהבעיה תיפתר.
מצב הסוכן יכול להוסיף או לעדכן רכיבי ממשק משתמש באופן עצמאי. לדוגמה, אפשר לבקש מהסוכן "להגדיר את המצב הכהה כברירת מחדל בהעדפות המשתמש", והוא יחפש את הקבצים הרלוונטיים ויציע שינויים כדי לבצע את המשימה. אפשר לראות תצוגה מקדימה של עדכוני ממשק המשתמש באופן מיידי בחלון הכלים Running devices.
נתוני דמה יכולים לעזור לכם כשאתם יוצרים אב טיפוס ובודקים את האפליקציה. במקום ליצור נתוני דמה בעצמכם, אתם יכולים להטיל את המשימה הזו על הסוכן.
בדוגמה הזו ביקשנו מהסוכן הדיגיטלי 'להוסיף עוד שתי סשנים לנתונים המזויפים'. הוא מוצא את הקובץ הרלוונטי ומוסיף עוד שני אירועים לרשימה mockSessions
.
הנחיות נוספות שאפשר לנסות:
- "Write unit tests for <class> in <module>."
- "Generate documentation for the currently open file" (יצירת תיעוד לקובץ שפתוח כרגע).
- "תשנה את שם האפליקציה מ-<השם הנוכחי> ל-<השם החדש>".
- "Resolve the null pointer exception" (פתרון חריגת מצביע null).
- "תבצע רפקטורינג בקוד שלי על ידי העברת הקומפוזיבל [שם הקומפוזיבל] לקובץ חדש.
חשוב לוודא שכל הייבוא עודכן".
- "תוסיף כפתור חדש למסך הבית של האפליקציה בשם 'מעקב' שיעביר אותי לרשימת נושאים".
- "In the <composable name> composable, reduce the padding of the <modifier
name> modifier."
- "צור לחצן שיתוף כדי לשתף ברשתות חברתיות".
איך הסוכן פועל
במצב סוכן, ההנחיה שלכם נשלחת אל Gemini API עם רשימה של כלים שזמינים. אפשר לחשוב על כלים כעל כישורים: הם כוללים את היכולת לחפש קבצים, לקרוא קבצים, לחפש את הטקסט בתוך קבצים, להשתמש בכל שרתי MCP שהגדרתם ועוד.
כשנותנים לסוכן משימה, הוא יוצר תוכנית ובוחר את הכלים שדרושים לביצוע שלה. יכול להיות שתצטרכו לתת הרשאה לחלק מהכלים האלה לפני שהסוכן יוכל להשתמש בהם. אחרי שתתנו הרשאה, הסוכן ישתמש בכלי כדי לבצע את הפעולה הנדרשת וישלח את התוצאה בחזרה אל Gemini API. Gemini מעבד את תוצאת הפעולה ויוצר תשובה נוספת. המחזור הזה של פעולה והערכה נמשך עד שהמשימה מסתיימת.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-05 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-05 (שעון UTC)."],[],[],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."]]