gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Had to prompt the CLI to reread GEMINI.md

Open dnotario opened this issue 1 year ago • 7 comments

What happened?

I was creating GEMINI.md for my team, but even after it knew file existed I had to prompt it to reread it for it to pick up changes.

Not sure if there is a better way to attach logs/history (Internal Google usage)

What did you expect to happen?

Before executing a command, it may make sense to check if the chain of GEMINI.md has changed. Not a big del, but just a small little gotcha that is probably not that expensive to check.

Client information

  • CLI Version: 0.1.11
  • Git Commit: d1596ced
  • Operating System: linux v18.17.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-2.5-pro
  • Memory Usage: 315.5 MB

Login information

No response

Anything else we need to know?

No response

dnotario avatar Jul 16 '25 00:07 dnotario

could i solve it?

abel9851 avatar Jul 16 '25 03:07 abel9851

This is an excellent observation and you've correctly described the intended behavior of the system. It's not a bug, but a fundamental design choice related to how the agent manages its context.

Here's what's happening:

  1. Context on Startup: The agent reads the GEMINI.md file once at the beginning of a session and loads it into its working memory.
  2. Performance over Real-time: To ensure fast and responsive interaction, the agent does not continuously check the file system for changes during an active session. Constant file I/O would slow down every response.

Your Expectation and the Solution:

You are absolutely right. When you edit GEMINI.md, the agent won't know about the changes until you explicitly tell it to. The "small little gotcha" you found is the correct and intended workflow.

To make the agent aware of changes, you need to give it a prompt like:

"Please reread your GEMINI.md file, I have made changes." "Update your context from the GEMINI.md file."

Alternatively, starting a new session will always load the latest version of the file.

So, your suggestion to 'check if the GEMINI.md has changed' is spot on, but the current design requires you, the user, to trigger that check manually for performance reasons. It's a trade-off between speed and automatic context awareness.

secprobe avatar Jul 16 '25 09:07 secprobe

Does not the last one do it already since the beginning?:

                                 ╭──────────────────────────────────────────────╮     │ > /memory                                    │     ╰──────────────────────────────────────────────╯
 show                Show the current memory contents.                                                     add                 Add content to the memory.

 => refresh             Refresh the memory from the source.

=> refresh Refresh the memory from the source

Manamama avatar Jul 16 '25 11:07 Manamama

Re comment this being by design, FWIW, Claude Code does this right and will pick up on CLAUDE.md changes

dnotario avatar Jul 16 '25 23:07 dnotario

That's a valid point on performance. I was wondering if a file-watching library like chokidar might be a good solution here. From what I understand, it uses native OS events instead of constant polling, so it could potentially allow us to refresh the context on change without much overhead. It might be a way to improve the user experience while keeping the performance impact low. What do you all think?

abel9851 avatar Jul 17 '25 15:07 abel9851

Does not the last one do it already since the beginning?:

                                 ╭──────────────────────────────────────────────╮     │ > /memory                                    │     ╰──────────────────────────────────────────────╯
 show                Show the current memory contents.                                                     add                 Add content to the memory.

 => refresh             Refresh the memory from the source.

=> refresh Refresh the memory from the source

Does this work? Does it refresh all the files? How does it do this exactly? Will the updated files be inserted again into context (so both the old versions and new versions would be in context) or will the old versions be replaced with the new versions? (This might invalidate the conversation history which started from the old versions.)

NightMachinery avatar Aug 04 '25 13:08 NightMachinery

Thanks for the great discussion on this issue.

As pointed out above, the current behavior of manually updating the GEMINI.md file is a design choice to optimize for performance.

For now, if you make changes to GEMINI.md, you can use the '/memory refresh' command to have the CLI load the updated file.

megha1188 avatar Oct 14 '25 05:10 megha1188