File re-reading loops & VERY high costs when using API key
What happened?
I played around with gemini-cli using 2.5 pro for 3 days and tried to let it enhance some projects, and suddenly the costs exploded to nearly 900$.
I had to restart gemini-cli often when using it, because it was unable to read files and replace strings in it, and then it seemed to be stuck in an endless loop of re-reading a single file and trying to replace something in it, what never succeeded. I guess that's when the costs kick in.
Another issue is, that it says it will update a file, and then i get "No changes made", and it claims to have changed something in the file and responds with "I changed the file. The issue is fixed" - what clearly can't be true, since it did not change anything at all.
Sometimes it flooded the console with some randomly distorted ascii-lines (the border of some info-boxes, i guess) and seemed to answer to multiple (mostly older) prompts in parallel, like it's spawning multiple threads of the conversation in the current conversation, even if i explicitly prompt "Forget all current or past tasks" before.
If 900$ is the cost of using it for 3 days, it's unlikely i will continue using it.
Is there any chance to reduce the bill due to it being experimental? Or to get a partly refund due to it definitely having bugs? I'd happily pay to use gemini-cli with the 2.5 pro, but this is a major "no" for me. Can i avoid such high cost in the future? I really like gemini-cli and want to use it more, but if these are the costs, i have to stop using it.
Are these usual stats?
│ Agent powering down. Goodbye! │ │ │ │ Cumulative Stats (76 Turns) │ │ │ │ Input Tokens 15,344,399 │ │ Output Tokens 94,093 │ │ Thoughts Tokens 88,064 │ │ Cached Tokens 12,342,136 (79.5%) │ │ ────────────────────────────────── │ │ Total Tokens 15,526,556 │ │ │ │ Total duration (API) 35m 34s │ │ Total duration (wall) 29h 56m 50s │
also see a screenshot of the calculated usage attached.
What did you expect to happen?
I expected some costs, but not having to pay 900$ for 3 days playing around with it. I feel like i have to pay most of the 900$ for gemini-cli spawning multiple conversational threads in parallel and getting stuck reading files in endless loops.
Client information
╭────────────────────────────────────────╮
│ │
│ About Gemini CLI │
│ │
│ CLI Version 0.1.7 │
│ Git Commit 55cc809 │
│ Model gemini-2.5-pro │
│ Sandbox no sandbox │
│ OS darwin │
│ Auth Method OAuth │
│ │
╰────────────────────────────────────────╯
Login information
Gemini API-Key in .env file.
Anything else we need to know?
No response
Hi @datayeah, Could you please share the best email address or contact information where we can reach you to further discuss this?
Why not ask your questions here? If you need more information about the issue, i will try to provide the answers.
I just had another "loop"-conversation. it's really annoying. and cost-intensive, i guess. (see end of log)
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The bookings are being returned, but not displayed on the calendar. This indicates that the FullCalendar is not correctly
interpreting or rendering the event data it receives.
I need to check the FullCalendar initialization in public/js/main.js to ensure that the event data is being passed and processed
correctly. FullCalendar expects event objects to have start and end properties, and it seems the backend is returning start_time
and end_time. While FullCalendar is usually smart enough to handle ISO strings, sometimes explicit mapping is needed.
Let's examine the FullCalendar initialization in public/js/main.js.
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ ReadFile public/js/main.js │
│ │
│ (truncated) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ℹ IMPORTANT: This conversation approached the input token limit for gemini-2.5-flash. A compressed context will be sent for future
messages (compressed from: 1018190 to 1438 tokens).
✕ [API Error: [{
"error": {
"code": 400,
"message": "Please ensure that the number of function response parts is equal to the number of function call parts of the
function call turn.",
"errors": [
{
"message": "Please ensure that the number of function response parts is equal to the number of function call parts of the
function call turn.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
]]
> /quit
╭─────────────────────────────────────╮
│ │
│ Agent powering down. Goodbye! │
│ │
│ │
│ Cumulative Stats (48 Turns) │
│ │
│ Input Tokens 49,806,575 │
│ Output Tokens 90,889 │
│ Thoughts Tokens 42,630 │
│ ───────────────────────────────── │
│ Total Tokens 49,940,094 │
│ │
│ Total duration (API) 41m 3s │
│ Total duration (wall) 1h 52m 33s │
│ │
╰─────────────────────────────────────╯
I experienced these loop issues with Cursor when using gemini-2.5-flash, but not with gemini-2.5-pro. However, when using the Gemini CLI with 2.5-pro, the loop happens more frequently.
I experienced them with both (using Gemini-CLI).
Wow. Very similar to mine, linked above, but my Gemini was silent when rereading (looped) the file, no comment even given. (Use the tips there, for a while: the free tier based API, project, and the usage capped, in very short.)
An aside, re: 'flooded the console with some randomly distorted ascii-lines' - something related happens during a longer (10 turns more or less) convo, when the terminal is probably flooded with some refresh signals due to e.g. whisperx transcription output run by Gemini. On Termux (Droid) I must then even kill the terminal, as it slows down to a crawl. (Yes, it is an end-client problem, I know, I guess the node based GUI is to blame, and probably no tokens consumed then, yet, but FYI, too).
My experience was, that whenever the "flooding" of ascii-lines happens, gemini-cli seems to begin to stumble. It prints every line of the answer multiple (up to 4-6) times, as if it was copying the current conversation and answering it in multiple threads in parallel. Might be just an UI or visual issue, but if not, it will cost the user the a probably already huge amount of tokens multiple times with every new line of text.
Thank you for all the detailed information here. I am still investigating this issue.
I was suggesting taking this discussion offline in order to verify usage and to facilitate any eligible refund. In case a refund is possible we will require your Google account and billing information. I was suggesting exchanging only account information offline.
I reported to Billings similar issues around the unusually high token use (1000%+ above the normal average) for July 4, 2025, including the looping, repeated fast scrolling text, and rate-limiting issues that many have shared in different issues.
While we have learned to live with the idea of paying for software that has bugs and does not work 100%, MS Windows, and not being able to claim your purchase price back etc. This is something different! A piece of buggy software that costs you money when you run it! Maybe someone with more legal knowledge could comment. The major players are all racing ahead with AI and I understand the reason for development/test versions of software being released, but in 50+ years in this industry this is the first time I've encountered test/development/beta software that can cost you money when you run it because of bugs to this degree. Personally I deleted my billing account after 6 hours of use because of the excessive charges. What I'm suggesting is that the major players in the AI market need to re-assess how they go forward with charging fees for what is unfinished code. It may have worked in the past, they may have got away with it for decades, but surely situations as described in this post can not be correct.
Side-Note: Now working on Free Tier (100 RPD). In one session I made 24 requests, yet ran into RPD limits. I had not made 100 requests, but Gemini CLI had!! Maybe something in the terminal stating how many requests Gemini will use to carry out an instruction.
- Re: https://github.com/google-gemini/gemini-cli/issues/2773#issuecomment-3048775647 : "Don't look a gift 🎁 horse 🐴 in the mouth AI👾'". This GUI is open source. Fix 👩🏭 it. Write PRs here etc. (I have, here and e.g. there: https://github.com/OpenInterpreter/open-interpreter/issues.)
- Re: "Maybe something in the terminal stating how many requests Gemini will use to carry out an instruction." AFAIK, after the file reading loop debacle (this one mostly) fix, there is a soft limit of the ingest and thinking tokens. I saw a methion of it in Help, q.v. For a hard limit: use https://github.com/google-gemini/gemini-cli/blob/main/docs/core/tools-api.md#built-in-tools , e.g. this one: https://phase2online.com/2025/05/23/sequential-thinking-mcp-server-anthropic/ (so so, but indeed limits and structures the thinking depth).
- Ask Gemini CLI how to self fix, e.g. in the Settings file or via the Memories chain, or in the code itself or workflows. It tends to work: https://github.com/Manamama/Puzzles_for_AIs/tree/main/docs/pmbok_instructions, at least "on my box" 📦☑️
Found possible duplicate issues:
- #3299: (0.9141062600485969)
- #4495: (0.9105736070529473)
- #3004: (0.9087178436303818)
- #4410: (0.9013779818190363)
- #2479: (0.9012420236324074)