[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Agent mode\n\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis document describes agent mode in Gemini Code Assist.\n\nAgent mode is available in the VS Code and IntelliJ integrated development\nenvironments (IDEs). To start using agent mode, see\n[Use agentic chat as a pair programmer](/gemini/docs/codeassist/use-agentic-chat-pair-programmer).\n\nAgent mode in VS Code is powered by [Gemini CLI](/gemini/docs/codeassist/gemini-cli).\n\nAgent mode in IntelliJ doesn't use the Gemini CLI.\n\nWith agent mode, you can do any of the following and more:\n\n- Ask questions about your code.\n- Use context and built-in tools to improve generated content.\n- Configure MCP servers to extend the agent's abilities.\n- Get solutions to complex tasks with multiple steps.\n- Generate code from design documents, issues, and `TODO` comments.\n- Control the agent behavior by commenting on, editing, and approving plans and tool use during execution.\n\nHow agent mode works\n--------------------\n\nIn agent mode, your prompt is sent to the Gemini API with a list of\n[tools](#tools) that are available. The Gemini\nAPI processes the prompt and returns a response. The response might be a direct\nanswer or a request to use an available tool.\n\nWhen a tool is requested, the agent prepares to use the tool and checks to see\nif it is allowed to use the tool with or without explicit permission:\n\n- For tool requests that modify the file system, or perform mutating operations on any resources, Gemini will ask you to allow the operation unless you have configured Gemini to always allow the tool or tools.\n- Tool requests that are read-only might not ask for permission before completing the task.\n\nWhen asked to allow the use of a tool, you can choose to allow or deny the\noperation. The agent might also give you options to always allow a tool or\nserver or allow similar operations. For more information, see\n[Always allow agent actions](/gemini/docs/codeassist/use-agentic-chat-pair-programmer#yolo-mode).\n\nOnce permission to use the tool is given or self-granted, the agent uses the\ntool to complete the required action, and the result of that action is sent\nback to the Gemini API. Gemini processes the result of the\ntool action and generates another response. This cycle of action and\nevaluation continues until the task is complete.\n\nFor complex tasks, Gemini might show a high-level plan for your\napproval. You can fine tune the plan and ask questions in chat before beginning\nthe process. Once you are happy with the plan, you can approve it. After you\napprove the plan, the agent starts working on the first task, and will ask you\nfor clarifications or permissions as needed as it executes the plan.\n\nAgent mode context\n------------------\n\nContext allows an agent to generate better responses for a given prompt. Context\ncan be taken from files in your IDE, files in your local system folders, tool\nresponses, and your prompt details.\n\nDepending on your IDE and settings, different contexts might be available to the\nagent.\n\nThe following tabs detail how context is gathered for different IDEs. \n\n### VS Code\n\nThe following methods of getting context are usually available to\nGemini Code Assist in agent mode:\n\n- Information in your IDE workspace.\n- Tool responses from built-in tools like grep, terminal, file read, or file write.\n- Google Search responses.\n- Content from a given URL provided in a prompt or by a tool.\n- Context files you create in Markdown.\n\n### Agent memory\n\nGemini Code Assist agent mode in VS Code leverages the\nGemini CLI memory discovery service to find and load `GEMINI.md`\nfiles that provide context for the agent. The memory discovery service\nsearches for these files hierarchically, starting from the current working\ndirectory and moving up to the project root and your home directory. It also\nsearches in subdirectories.\n\nYou can create context files that are global,\nproject-level, and component-level, which are all combined to provide the\nmodel with the most relevant information.\n\nYou can use the `/memory show` command to see the combined content of all\nloaded `GEMINI.md` files, and the `/memory refresh` command to reload them.\n\n### IntelliJ\n\nThe following methods of getting context are usually available to\nGemini Code Assist in agent mode:\n\n- Information in your IDE project including your files, indexed symbols and usage of symbols in your project.\n- Tool responses from built-in tools like grep, file read, or file write.\n- IntelliJ [version control](https://www.jetbrains.com/help/idea/version-control-integration.html).\n- Configured MCP servers and tools\n- Context files you create in Markdown.\n\nYou can see the context available to the agent in the context drawer in the\nagent mode chat prompt area. \n\nTools\n-----\n\n*Tools* are a broad category of services that an agent can use for context and\nactions in its response to your prompt. Tools allow agents to access up-to-date\ninformation through function calling to API endpoints or to other agents. Tools\nmight only offer one function, or they might offer multiple related functions.\n\nSome example tools are built-in tools like grep and file read or write, local or\nremote Model Context Protocol (MCP) servers and their executable functions, and\nRESTful API calls.\n\n### Built-in tools\n\nIn agent mode, Gemini has access to your built-in system tools. Select\nyour IDE to view a list of built-in tools available to Gemini in\nagent mode. \n\n### VS Code\n\nAll of the\n[Gemini CLI built-in tools](https://github.com/google-gemini/gemini-cli/blob/main/docs/core/tools-api.md#built-in-tools) are\navailable to agent mode in Gemini Code Assist.\n\n### IntelliJ\n\n`read_file`\n: Retrieves the text content of a file using its absolute path.\n\n`write_file`\n: Writes the given text to a specified file, creating the file if it doesn't exist.\n\n`analyze_current_file`\n: Analyzes the open file in the editor for errors and warnings.\n\n`find_files`\n: Finds the absolute path to files given a filename or a part of the path\n\n`grep`\n: Finds all files inside the project that contain a given text pattern or regular expression.\n\n`list_files`\n: Lists all files and directories in a given absolute path.\n\n`resolve_symbol`\n: Resolves a specific symbol reference to its original declaration.\n\n`find_usages`\n: Searches the project for all references to a given symbol declaration.\n\n`git`\n: Runs a Git command-line interface (CLI) command and returns the result.\n\n`list_vcs_roots`\n: Returns all Version Control System (VCS) roots, such as Git repositories, in the current project.\n\nLimitations\n-----------\n\nSome features of [standard Gemini Code Assist chat](/gemini/docs/codeassist/chat-overview)\nmight not be available in agent mode or might work differently than they do in\nstandard chat.\n\nRecitation is not available in agent mode. While in agent mode, Gemini\ndoesn't [cite sources](/gemini/docs/discover/works#how-when-gemini-cites-sources) and you can't\n[disable code suggestions that match cited sources](/gemini/docs/codeassist/write-code-gemini#disable_code_suggestions_that_match_cited_sources).\n\nWhat's next\n-----------\n\n- [Use agentic chat as a pair programmer](/gemini/docs/codeassist/use-agentic-chat-pair-programmer).\n- Read the [Gemini CLI documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/index.md)."]]