エージェント モード
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このドキュメントでは、Gemini Code Assist のエージェント モードについて説明します。
エージェント モードは、VS Code と IntelliJ の統合開発環境(IDE)で使用できます。エージェント モードの使用を開始するには、エージェント チャットをペア プログラマーとして使用するをご覧ください。
VS Code のエージェント モードは Gemini CLI を利用しています。
IntelliJ のエージェント モードでは Gemini CLI は使用されません。
エージェント モードでは、次のような操作を行うことができます。
- コードに関する質問をします。
- コンテキストと組み込みツールを使用して、生成されたコンテンツを改善します。
- エージェントの機能を拡張するように MCP サーバーを構成します。
- 複数のステップを含む複雑なタスクのソリューションを入手します。
- 設計書、問題、
TODO
コメントからコードを生成します。
- 実行中にプランとツールの使用にコメントを付けたり、編集や承認を行うことで、エージェントの動作を制御します。
エージェント モードの仕組み
エージェント モードでは、プロンプトは使用可能なツールのリストとともに Gemini API に送信されます。Gemini API がプロンプトを処理し、レスポンスを返します。レスポンスは、直接的な回答の場合もあれば、利用可能なツールを使用するよう求めるリクエストの場合もあります。
ツールがリクエストされると、エージェントはツールを使用する準備を行い、明示的な権限あり、またはなしでツールを使用できるかどうかを確認します。
- ファイル システムを変更するツール リクエストや、リソースに対して変更オペレーションを実行するツール リクエストの場合、Gemini は、ツールを常に許可するように Gemini を構成していない限り、オペレーションを許可するよう求めます。
- 読み取り専用のツール リクエストでは、タスクを完了する前に権限を求められない場合があります。
ツールの使用を許可するかどうかを尋ねられたら、オペレーションを許可するか拒否するかを選択できます。エージェントから、ツールやサーバーを常に許可するオプションや、同様のオペレーションを許可するオプションが提示されることもあります。詳細については、エージェント アクションを常に許可するをご覧ください。
ツールの使用権限が付与されると(あるいは自身で取得すると)、エージェントはツールを使用して必要なアクションを完了し、そのアクションの結果が Gemini API に返送されます。Gemini はツール アクションの結果を処理し、別のレスポンスを生成します。このアクションと評価のサイクルは、タスクが完了するまで続きます。
複雑なタスクの場合、Gemini は大まかなプランを提示し、ユーザーに承認を求めることがあります。プロセスを開始する前に、プランの微調整や、チャットでの質問ができます。プランに問題がなければ承認します。プランを承認すると、エージェントは最初のタスクを開始します。プランの実行中は、必要に応じて説明や権限を求めます。
エージェント モードのコンテキスト
コンテキストを使用すると、エージェントは特定のプロンプトに対してより適切な回答を生成できます。コンテキストは、IDE のファイル、ローカル システム フォルダのファイル、ツールのレスポンス、プロンプトの詳細から取得できます。
IDE と設定によっては、エージェントが利用できるコンテキストが異なる場合があります。
次のタブでは、それぞれの IDE でコンテキストが収集される方法について説明します。
VS Code
エージェント モードの Gemini Code Assist は通常、次の方法でコンテキストを取得します。
- IDE ワークスペース内の情報。
- grep、ターミナル、ファイル読み取り、ファイル書き込みなどの組み込みツールからのレスポンス。
- Google 検索のレスポンス。
- プロンプトまたはツールで指定された URL のコンテンツ。
- Markdown で作成するコンテキスト ファイル。
エージェントのメモリ
VS Code の Gemini Code Assist エージェント モードは、Gemini CLI メモリ検出サービスを利用して、エージェントのコンテキストを提供する GEMINI.md
ファイルを検索して読み込みます。メモリ検出サービスは、現在の作業ディレクトリからプロジェクトのルート、ホーム ディレクトリへと階層的に移動し、ファイルを検索します。サブディレクトリも検索します。
グローバル、プロジェクト レベル、コンポーネント レベルのコンテキスト ファイルを作成できます。これらのファイルはすべて結合され、モデルに最も関連性の高い情報が提供されます。
/memory show
コマンドを使用すると、読み込まれたすべての GEMINI.md
ファイルのコンテンツを組み合わせて表示できます。また、/memory refresh
コマンドを使用すると、それらを再読み込みできます。
IntelliJ
エージェント モードの Gemini Code Assist は通常、次の方法でコンテキストを取得します。
- ファイル、インデックス付きシンボル、プロジェクトでのシンボルの使用状況など、IDE プロジェクト内の情報。
- grep、ファイル読み取り、ファイル書き込みなどの組み込みツールからのレスポンス。
- IntelliJ のバージョン管理。
- 構成済みの MCP サーバーとツール
- Markdown で作成するコンテキスト ファイル。
エージェントが利用できるコンテキストは、エージェント モードのチャット プロンプト領域のコンテキスト ドロワーで確認できます。
ツールは、エージェントがプロンプトに対するレスポンスのコンテキストとアクションに使用できる幅広いカテゴリのサービスです。ツールを使用すると、エージェントは関数呼び出しによって API エンドポイントまたは他のエージェントにアクセスし、最新の情報を取得できます。ツールは 1 つの関数のみを提供する場合もあれば、複数の関連関数を提供する場合もあります。
ツールの例としては、grep やファイルの読み取り / 書き込みなどの組み込みツール、ローカルまたはリモートの Model Context Protocol(MCP)サーバーとその実行可能関数、RESTful API 呼び出しなどがあります。
エージェント モードでは、Gemini は組み込みのシステムツールにアクセスできます。IDE を選択すると、エージェント モードの Gemini で使用可能な組み込みツールのリストが表示されます。
IntelliJ
read_file
- 絶対パスを使用してファイルのテキスト コンテンツを取得します。
write_file
- 指定されたファイルに指定されたテキストを書き込みます。ファイルが存在しない場合は作成します。
analyze_current_file
- エディタで開いているファイルのエラーと警告を分析します。
find_files
- ファイル名またはパスの一部を指定して、ファイルの絶対パスを取得します。
grep
- 指定されたテキスト パターンまたは正規表現を含むプロジェクト内のすべてのファイルを検索します。
list_files
- 指定された絶対パスにあるすべてのファイルとディレクトリを一覧表示します。
resolve_symbol
- 特定のシンボル参照を元の宣言に解決します。
find_usages
- プロジェクト内で、指定されたシンボル宣言のすべての参照を検索します。
git
- Git コマンドライン インターフェース(CLI)コマンドを実行し、結果を返します。
list_vcs_roots
- 現在のプロジェクト内のすべてのバージョン管理システム(VCS)ルート(Git リポジトリなど)を返します。
制限事項
標準の Gemini Code Assist チャットの一部の機能は、エージェント モードでは使用できないか、標準チャットとは異なる動作をする場合があります。
朗読はエージェント モードでは使用できません。エージェント モードでは、Gemini はソースを引用しません。また、引用されたソースと一致するコードの候補を無効にすることもできません。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-31 UTC。
[[["わかりやすい","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-31 UTC。"],[],[],null,["# Agent mode\n\n| **Preview**\n|\n| \u003cbr /\u003e\n|\n| This product or feature is in preview. Products and features that are\n| in preview are available \"as is\".\n|\n| \u003cbr /\u003e\n|\n\u003cbr /\u003e\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-code-assist/docs/use-agentic-chat-pair-programmer).\n\nAgent mode in VS Code is powered by [Gemini CLI](/gemini-code-assist/docs/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-code-assist/docs/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-code-assist/docs/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-code-assist/docs/works#how-when-gemini-cites-sources) and you can't\n[disable code suggestions that match cited sources](/gemini-code-assist/docs/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-code-assist/docs/use-agentic-chat-pair-programmer).\n- Read the [Gemini CLI documentation](https://github.com/google-gemini/gemini-cli/blob/main/docs/index.md)."]]