Gemini CLI: API Error 'Model stream ended with an invalid chunk or missing finish reason' after ReadFile or Edit tool calls
Gemini CLI shows '[API Error: Model stream ended with an invalid chunk or missing finish reason.]' right after a ReadFile or Edit tool call, and the model then gives confused replies. Users on v0.3.x through v0.6.0 nightly on macOS and Linux reported it. Is there a fix or workaround?
Originally asked on GitHub: https://github.com/google-gemini/gemini-cli/issues/7851
6 answers
The issue was closed as completed, but reporters said the error persisted after the maintainer asked users to update to v0.3.4, and one user still saw it on v0.4.1, so treat it as not reliably fixed. The maintainer's first suggestion was to update to the latest v0.3.4 release and check whether the problem persists. A maintainer also asked whether the session had been downgraded to gemini-2.5-flash, which can happen when the Pro quota is exhausted.
What users reported:
- Removing GEMINI.md helped one user temporarily, but a later test by another user showed no change.
- Switching authentication methods did not clear the error for one user.
- One user found the error appeared more often as chat history grew. Compressing a history from about 178k tokens to about 60k tokens, followed by dozens of ReadFile and Edit calls, produced no occurrences. This suggests context size correlates with the error more than file content does.
- Another user saw the error on almost every message once it started, and had to send a placeholder message to continue.
General advice: start a new session or compress the chat history (
/compressif your version supports it) when the error begins, and check that you are on the latest release. This is not confirmed as a fix in the thread.Did this work for you?What @mdbro tried on GitHub (Didn't work)
Reporter used ReadFile with an absolute path on a markdown file in a project. The stream error appeared after the tool call, and the model asked the user to repeat the request.
Source: https://github.com/google-gemini/gemini-cli/issues/7851 (opens external site)
Did this work for you?What @SandyTao520 tried on GitHub (Didn't work)
Maintainer suggested upgrading to the latest v0.3.4 release and checking whether the problem persisted.
Did this work for you?What @hillct tried on GitHub (Didn't work)
User removed the GEMINI.md file as a workaround on the 0.6.0 nightly build with gemini-2.5-pro on macOS.
Did this work for you?What @hillct tried on GitHub (Partly worked)
User compressed chat history from about 178k to about 60k tokens and ran dozens of ReadFile and Edit calls with gemini-2.5-pro. No error occurred in that session.
Did this work for you?What @JimDabell tried on GitHub (Partly worked)
User on v0.4.1 typed a placeholder message each time the error appeared to resume the session.
Did this work for you?
Related questions
- gemini-cli 400: "only 'enum' and 'date-time' are supported for STRING type"
- gemini-cli stuck on "This is taking a bit longer" after Esc cancel — is there a fix?
- Is there a way to get codebase indexing in gemini-cli?
- How can I use voice input instead of typing with Gemini CLI?
- Is gemini-cli able to run as an MCP server for other AI tools?