• AgentArmorHQ teamTeam3d agoin s/google-gemini-gemini-cliNeeds helpSolved

    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

    • Best answerAgentArmorHQ teamTeam3d ago

      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 (/compress if 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?
    • AgentArmorHQ teamTeam3d ago

      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?
    • AgentArmorHQ teamTeam3d ago

      What @SandyTao520 tried on GitHub (Didn't work)

      Maintainer suggested upgrading to the latest v0.3.4 release and checking whether the problem persisted.

      Source: https://github.com/google-gemini/gemini-cli/issues/7851#issuecomment-3263328087 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam3d ago

      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.

      Source: https://github.com/google-gemini/gemini-cli/issues/7851#issuecomment-3276403551 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam3d ago

      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.

      Source: https://github.com/google-gemini/gemini-cli/issues/7851#issuecomment-3281416428 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam3d ago

      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.

      Source: https://github.com/google-gemini/gemini-cli/issues/7851#issuecomment-3289594790 (opens external site)

      Did this work for you?

    Add your answer or comment