Agent mode

This document describes agent mode in Gemini Code Assist.

Agent mode is available in the VS Code integrated development environment (IDE). To start using agent mode, see Use agentic chat as a pair programmer.

Agent mode in VS Code is powered by Gemini CLI.

With agent mode, you can do any of the following and more:

  • Ask questions about your code.
  • Use context and built-in tools to improve generated content.
  • Configure MCP servers to extend the agent's abilities.
  • Get solutions to complex tasks with multiple steps.
  • Generate code from design documents, issues, and TODO comments.
  • Control the agent behavior by commenting on, editing, and approving plans and tool use during execution.

How agent mode works

In agent mode, your prompt is sent to the Gemini API with a list of tools that are available. The Gemini API processes the prompt and returns a response. The response might be a direct answer or a request to use an available tool.

When a tool is requested, the agent prepares to use the tool and checks to see if it is allowed to use the tool with or without explicit permission:

  • 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.
  • Tool requests that are read-only might not ask for permission before completing the task.

When asked to allow the use of a tool, you can choose to allow or deny the operation. The agent might also give you options to always allow a tool or server or allow similar operations. For more information, see Always allow agent actions.

Once permission to use the tool is given or self-granted, the agent uses the tool to complete the required action, and the result of that action is sent back to the Gemini API. Gemini processes the result of the tool action and generates another response. This cycle of action and evaluation continues until the task is complete.

For complex tasks, Gemini might show a high-level plan for your approval. You can fine tune the plan and ask questions in chat before beginning the process. Once you are happy with the plan, you can approve it. After you approve the plan, the agent starts working on the first task, and will ask you for clarifications or permissions as needed as it executes the plan.

Agent mode context

Context allows an agent to generate better responses for a given prompt. Context can be taken from files in your IDE, files in your local system folders, tool responses, and your prompt details.

Depending on your IDE and settings, different contexts might be available to the agent.

The following tabs detail how context is gathered for different IDEs.

VS Code

The following methods of getting context are usually available to Gemini Code Assist in agent mode:

  • Information in your IDE workspace.
  • Tool responses from built-in tools like grep, terminal, file read, or file write.
  • Google Search responses.
  • Content from a given URL provided in a prompt or by a tool.
  • Context files you create in Markdown.

Agent memory

Gemini Code Assist agent mode in VS Code leverages the Gemini CLI memory discovery service to find and load GEMINI.md files that provide context for the agent. The memory discovery service searches for these files hierarchically, starting from the current working directory and moving up to the project root and your home directory. It also searches in subdirectories.

You can create context files that are global, project-level, and component-level, which are all combined to provide the model with the most relevant information.

You can use the /memory show command to see the combined content of all loaded GEMINI.md files, and the /memory refresh command to reload them.

Gemini CLI extensions

You can use Gemini CLI extensions to configure and extend Gemini Code Assist agent mode functionality.

The agent looks for extensions in two locations:

  • WORKSPACE/.gemini/extensions where WORKSPACE is your current workspace.
  • ~/.gemini/extensions where ~ is your home directory.

The agent loads all extensions from both locations, but if an extension with the same name exists in both, the one in the workspace directory will take precedence. Each extension is a directory that contains a gemini-extension.json file. This file contains the configuration for the extension.

For more information, see Gemini CLI extensions.

IntelliJ

This feature isn't supported in Gemini Code Assist for IntelliJ or other JetBrains IDEs.

Tools

Tools are a broad category of services that an agent can use for context and actions in its response to your prompt. Some example tools are built-in tools like grep and file read or write, local or remote Model Context Protocol (MCP) servers and their executable functions, and bespoke service implementations.

What's next