Skip to content

Comments

feat(plan): support replace tool in plan mode to edit plans#18379

Merged
jerop merged 3 commits intomainfrom
feature/plan-mode-replace-tool
Feb 5, 2026
Merged

feat(plan): support replace tool in plan mode to edit plans#18379
jerop merged 3 commits intomainfrom
feature/plan-mode-replace-tool

Conversation

@jerop
Copy link
Contributor

@jerop jerop commented Feb 5, 2026

Enable the replace tool in Plan Mode to allow iterative updates to implementation plans. This change enables the agent to efficiently edit existing plan files within the plans directory without needing to rewrite the entire file using write_file.

  • Updated plan policy to allow replace on .md files in the plans directory
  • Updated Plan Mode system prompt to include replace tool instructions
  • Added table-driven integration tests for write_file and replace in Plan Mode

Closes #18306

Enable the 'replace' tool in Plan Mode to allow iterative updates to implementation plans.
This change enables the agent to efficiently edit existing plan files within the plans directory
without needing to rewrite the entire file using 'write_file'.

- Updated plan policy to allow 'replace' on .md files in the plans directory.
- Updated Plan Mode system prompt to include 'replace' tool instructions.
- Added table-driven integration tests for 'write_file' and 'replace' in Plan Mode.
- Updated prompt snapshots.
@jerop jerop requested a review from a team as a code owner February 5, 2026 17:04
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jerop, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces support for the replace tool within Plan Mode, allowing the agent to directly edit existing plan files. This enhancement streamlines the planning workflow by enabling iterative modifications to plans without requiring the agent to rewrite entire files, thereby improving efficiency and precision in plan management.

Highlights

  • Policy Update: The plan.toml policy has been updated to explicitly allow the replace tool to modify .md files within the plans directory when operating in Plan Mode. This enables agents to perform iterative updates on existing plan documents.
  • System Prompt Enhancement: The Plan Mode system prompt has been modified to include clear instructions for using the replace tool, guiding the agent on its proper application for updating plans.
  • Integration Test Expansion: Existing integration tests for the policy engine have been refactored into a table-driven format and extended to cover the replace tool, ensuring it adheres to the same strict file path and type restrictions as write_file within Plan Mode.
Changelog
  • packages/cli/src/config/policy-engine.integration.test.ts
    • Refactored write_file policy tests into a table-driven format for better readability and maintainability.
    • Extended the table-driven tests to include the replace tool, verifying its adherence to file path and type restrictions in Plan Mode.
  • packages/core/src/core/snapshots/prompts.test.ts.snap
    • Updated the snapshot to reflect the inclusion of the replace tool in the Plan Mode prompt instructions.
  • packages/core/src/policy/policies/plan.toml
    • Added a new policy rule to explicitly permit the replace tool for .md files located within the plans directory when the system is in Plan Mode.
  • packages/core/src/prompts/snippets.ts
    • Modified the Plan Mode system prompt to list the replace tool as an available option for agents.
Activity
  • Initial commit of changes to enable the replace tool in Plan Mode.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully enables the replace tool in Plan Mode, which will allow for more efficient, iterative updates to implementation plans. The changes are well-implemented across the policy configuration, system prompts, and integration tests. The refactoring of the tests to use a table-driven approach for both write_file and replace is a good improvement for maintainability. I have one suggestion regarding the policy definition in plan.toml to further improve maintainability by reducing code duplication.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Size Change: -2.33 kB (-0.01%)

Total Size: 23.7 MB

Filename Size Change
./bundle/gemini.js 23.7 MB -2.33 kB (-0.01%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

@jerop jerop enabled auto-merge February 5, 2026 17:15
@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality area/security Issues related to security area/enterprise Issues related to Telemetry, Policy, Quota / Licensing 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 5, 2026
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

In the future I wonder if we should even allow auto editing of the plan.md files in plan mode outside of auto edit mode. I find it a little annoying that I have to approve the edit to the plan.md file. yes I want you to edit the plan you are working

@jerop jerop added this pull request to the merge queue Feb 5, 2026
@jerop
Copy link
Contributor Author

jerop commented Feb 5, 2026

In the future I wonder if we should even allow auto editing of the plan.md files in plan mode outside of auto edit mode. I find it a little annoying that I have to approve the edit to the plan.md file. yes I want you to edit the plan you are working

good idea, filed #18384 to keep track of it

Merged via the queue into main with commit 4a6e3eb Feb 5, 2026
43 of 45 checks passed
@jerop jerop deleted the feature/plan-mode-replace-tool branch February 5, 2026 18:02
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
aswinashok44 pushed a commit to aswinashok44/gemini-cli that referenced this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality area/core Issues related to User Interface, OS Support, Core Functionality area/enterprise Issues related to Telemetry, Policy, Quota / Licensing area/security Issues related to security 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Edit / Replace tool in plan mode to update plans

2 participants