Skip to main content
Watch: Google Found How to Make Your Agents Cheaper and Faster

Gemini CLI error

Gemini CLI: API Error: Model stream ended with an invalid chunk or missing finish reason

Error message
[API Error: Model stream ended with an invalid chunk or missing finish reason.]

Status: WorkaroundLast verified 1 documented fix6 sources

What it means

The model's streamed response ended without a valid finish reason or content, so the turn stopped mid-task. This exact text is the message reported in #7851 on 0.3.3; it no longer appears in current source, which raises InvalidStreamError with types such as NO_FINISH_REASON and MALFORMED_FUNCTION_CALL (for example "Model stream ended without a finish reason.").

Causes

  • The response stream from the model ended without a finish reason or with malformed content (InvalidStreamError in core/geminiChat.ts). The visible thread of #7851 states no root cause beyond this; its linked fix is #7857, "fix(core): Treat stream chunk with finishReason but no content as valid".

How to fix it

  1. Fix 1.

    Update the CLI. In #7851 a contributor asked the reporter to update to v0.3.4. Invalid-stream handling was later changed in v0.7.0 (#9169 "Retry invalid stream only 1 time") and v0.42.0 (#26218 "handle InvalidStream event gracefully without throwing").

    Terminal
    npm install -g @google/gemini-cli@latest

More Gemini CLI errors

All 19 Gemini CLI errors

FAQ

What does "API Error: Model stream ended with an invalid chunk or missing finish reason" mean in Gemini CLI?

The model's streamed response ended without a valid finish reason or content, so the turn stopped mid-task. This exact text is the message reported in #7851 on 0.3.3; it no longer appears in current source, which raises InvalidStreamError with types such as NO_FINISH_REASON and MALFORMED_FUNCTION_CALL (for example "Model stream ended without a finish reason.").

How do I fix "API Error: Model stream ended with an invalid chunk or missing finish reason"?

Update the CLI. In #7851 a contributor asked the reporter to update to v0.3.4. Invalid-stream handling was later changed in v0.7.0 (#9169 "Retry invalid stream only 1 time") and v0.42.0 (#26218 "handle InvalidStream event gracefully without throwing").

Is this Gemini CLI error fixed?

Status: Workaround. No release removes the cause. The documented fixes work around it. Affected versions: Reported on 0.3.3 (#7851)

Sources

Last verified against 6 sources: official docs, maintainer replies and release notes.

Newsletter

Fixes for the tools you use, weekly

One email per week. New coding agent releases, what broke, and how developers are working around it.