google-gemini / google-gemini/gemini-cli
Agent repeatedly runs broad searches causing massive context overflow
- Dominant language
- TypeScript
- Stars
- 107k
- Forks
- 14.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 45
Description
### What happened?
This happens fairly often. I will ask the agent to review a repo or find code, and it executes an overly broad SearchText command (e.g., searching 'Gmail' in ./ as shown in the screenshot). This picks up thousands of matches, often including huge debug logs or build artifacts.
Instead of refining the search, the agent attempts to ingest all 5,000+ matches immediately. In the attached example, it tried to send a payload of 41 million tokens against a ~900k limit.
Additionally, the UI becomes very confusing here. It displays a yellow "Sending this message..." warning, but it's unclear if the message has actually been sent, if the CLI is hanging, or how to cancel the operation without killing the terminal.
### What did you expect to happen?
Smarter Agent: When a search returns thousands of results, the agent should recognize this is too much and refine its search query—not try to read them all.
Hard Block: The CLI should prevent the agent from attempting to send a request that is 40x over the context limit.
Clearer UI: When a limit is hit, the UI should offer a clear "Cancel" or "Abort" option rather than just saying "Sending...".
### Client information
I terminated the session, so I can't run /about.
Version: 0.24.0-preview
OS: macOS
#######
Screenshot: https://screenshot.googleplex.com/5HatNtr4PQSP7Em
#######
✓ SearchText 'Gmail' within ./
Found 5006 matches
✓ ReadFile scripts/smart_ingest.py
i Sending this message (41740251 tokens) might exceed the remaining context window limit (904878 tokens).
### Login information
API key
### Anything else we need to know?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.