gemini-cli - 💡(How to fix) Fix Subagent definitions and texts are being loaded into context and are polluting the context [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25596Fetched 2026-04-18 05:57:33
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Code Example

> /about
About Gemini CLI│                                                                                                                                                             │
CLI Version                                           0.38.1Git Commit                                            7f5580034                                                                                             │
Model                                                 gemini-3-flash-preview                                                                                │
Sandbox                                               no sandbox                                                                                            │
OS                                                    linux                                                                                                 │
Auth Method                                           Signed in with Google (ksprashanth82@gmail.com)Tier                                                  Gemini Code AssistGCP Project                                           cloudshell-gca                                                                                        │
IDE Client                                            Cloud Shell
RAW_BUFFERClick to expand / collapse

What happened?

I have a bunch of agent defintions in my local .gemini/ folder.

When I make a query, the filesnames are being read into context, and then the files themselves are read into context, and the model uses these instructions for completion.

This is not expected. The main agent / instance should not get polluted with preferences / content from agents definitions.

<img width="1094" height="666" alt="Image" src="https://github.com/user-attachments/assets/1bf89315-0c49-4f78-9509-5e90cf5bfbdb" />

What did you expect to happen?

It just uses the model to generate a completion using only the system prompt and user instructions. Not other information that is lying around.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
│ About Gemini CLI                                                                                                                                            │
│                                                                                                                                                             │
│ CLI Version                                           0.38.1                                                                                                │
│ Git Commit                                            7f5580034                                                                                             │
│ Model                                                 gemini-3-flash-preview                                                                                │
│ Sandbox                                               no sandbox                                                                                            │
│ OS                                                    linux                                                                                                 │
│ Auth Method                                           Signed in with Google ([email protected])                                                       │
│ Tier                                                  Gemini Code Assist                                                                                    │
│ GCP Project                                           cloudshell-gca                                                                                        │
│ IDE Client                                            Cloud Shell
</details>

Login information

No response

Anything else we need to know?

No response

extent analysis

TL;DR

The issue can be mitigated by ensuring that the agent definitions in the local .gemini/ folder do not interfere with the main agent's context.

Guidance

  • Verify that the agent definitions are properly isolated from the main agent's context by checking the code that reads the filenames and files into context.
  • Check the documentation for the Gemini CLI to see if there are any configuration options or flags that can be used to prevent the agent definitions from being read into context.
  • Consider modifying the code that reads the agent definitions to only read the necessary information and ignore any unnecessary data.
  • Review the security and isolation features of the Gemini CLI to ensure that they are properly configured to prevent unintended access to sensitive information.

Notes

The exact cause of the issue is unclear, but it appears to be related to the way the agent definitions are being read into context. Without more information about the code and configuration, it is difficult to provide a more specific solution.

Recommendation

Apply workaround: Modify the code that reads the agent definitions to properly isolate them from the main agent's context, as this is the most likely cause of the issue and can be addressed without waiting for a potential fix in a future version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix Subagent definitions and texts are being loaded into context and are polluting the context [1 comments, 2 participants]