published fresh until

Gemini CLI's edit tool keeps failing: is there a setting for it?

Summary As of November 2026, useSmartEdit is absent from current Gemini CLI settings. Keep edits small and reload changed GEMINI.md instructions in the current session with /memory reload

Not for Gemini CLI account migration; see gemini-cli-stopped-working-move-to-antigravity-cli

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, do not add useSmartEdit; the current configuration reference does not list it. Do first: request a fresh read and a small replacement; after adding a failure rule to GEMINI.md, use /memory reload to load it into the current session.

The problem

The replace (edit) tool in Gemini CLI often fails with messages such as "Failed to edit, could not find the string to replace", "0 occurrences found for old_string" or "No changes detected", and the agent then loops. The tracking issue (opened 2025-06-13 by sijieamoy, with a summary added by a Gemini CLI collaborator) describes these failures. GitHub shows it as closed on 2025-12-03 with the reason "duplicate"; a commenter complained that the older, better-documented issue was closed in favour of a newer one. Reports continued into 2026 (the last comments are from January to March).

What the maintainers said

In September 2025 a collaborator wrote that the team was testing a new "smart edit" tool and asked users to add "useSmartEdit": true to settings.json, saying it had significantly improved the edit error rate in their testing. The later repository history and current reference describe a different situation:

  • A pull request titled "Enable smart edit by default on main" was merged on 2025-09-03.
  • The current Gemini CLI configuration reference does not list useSmartEdit, and the tools folder holds a single edit.ts. The history in the repository: PR 7679 (merged 2025-09-03) enabled smart edit by default on main, PR 11051 (merged 2025-10-13) changed the useSmartEdit schema default to true, and PR 15832 (merged 2026-01-02) removed the setting because smart edit is now the only registered edit tool. So on current versions useSmartEdit no longer exists and you should not rely on it.
  • The same reference documents tools.disableLLMCorrection (default true): when enabled, edit tools fail immediately if exact matches are not found instead of trying to self-correct. Leave this as the default unless you have a reason; this setting is not presented in the thread as a fix.

What commenters reported

  • One commenter said smart edit on CLI v0.4.0 dropped the error rate significantly but not to zero. Another enabled it and still saw repeated failures.
  • Rules in GEMINI.md were suggested by commenters. A commenter described a rule to grep for the target text whenever replace fails (reported as helping avoid most infinite loops). Another suggested telling the model to prefer small targeted replacements and to read the file again right before each replacement, reporting fewer failures. These are individual user reports, rather than a maintainer guarantee.
  • After changing GEMINI.md, run /memory reload to reload context, and /memory show to inspect it. The context guide documents both commands, so a restart is not required solely to reload those instructions.
  • Others had the agent use sed, or asked it to print the diff so they could apply it by hand.

Takeaway

The thread was closed as a duplicate on 2025-12-03; it does not identify a confirmed fix. Keep edits small, make the agent read the file again before replacing, keep a GEMINI.md rule for the failure case, and expect some failures after long sessions (commenters in 2026 said it grows worse over time).

Sources

Started from a post by @sijieamoy, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Gemini CLI's edit tool keeps failing: is there a setting for it?
Summary: As of November 2026, useSmartEdit is absent from current Gemini CLI settings. Keep edits small and reload changed GEMINI.md instructions in the current session with `/memory reload`
Copy for agent
get the whatworks thread gemini-cli-edit-tool-use-smart-edit and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread gemini-cli-edit-tool-use-smart-edit
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks