Custom provider, calling Gemini model with Google SDK results in unexpected interruptions. #9431

Open
opened 2026-02-16 18:12:26 -05:00 by yindo · 1 comment
Owner

Originally created by @Sallyn0225 on GitHub (Feb 15, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

When using the Gemini model, it sometimes abruptly stops during tool calls, and at other times, it stops while thinking. However, with the same upstream source, if connected to chat tools like Chatbox or platforms like Kilo Code, it functions normally, so upstream issues can likely be ruled out.

I also used an AI gateway like AxonHub to check the logs. I can see a message indicating a stop with input but no output, and a specific response body is as follows:

Image
{
  "candidates": [
    {
      "index": 0,
      "content": {
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ],
  "responseId": "18CRacGiPIuxjuMPw_mKkAk",
  "modelVersion": "gemini-3-flash-preview",
  "usageMetadata": {
    "totalTokenCount": 22066,
    "promptTokenCount": 22066
  }
}

The "finishReason": "STOP" in the middle caught my attention, and it seems to be the cause of the abrupt termination of output.

Plugins

oh-my-opencode, opencode-axonhub-tracing

OpenCode version

1.2.4

Steps to reproduce

  1. Use custom channels, use Google's SDK
  2. When calling Gemini series models, there is a probability of sudden interruption. However, it will not suddenly interrupt when the model outputs text.

Screenshot and/or share link

Image

Operating System

Windows 11 WSL2 Debian

Terminal

Windows Terminal

Originally created by @Sallyn0225 on GitHub (Feb 15, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description When using the Gemini model, it sometimes abruptly stops during tool calls, and at other times, it stops while thinking. However, with the same upstream source, if connected to chat tools like Chatbox or platforms like Kilo Code, it functions normally, so upstream issues can likely be ruled out. I also used an AI gateway like AxonHub to check the logs. I can see a message indicating a stop with input but no output, and a specific response body is as follows: <img width="364" height="127" alt="Image" src="https://github.com/user-attachments/assets/5930604b-1ce8-4130-8bcc-6ed61ebc7544" /> ```json { "candidates": [ { "index": 0, "content": { "role": "model" }, "finishReason": "STOP" } ], "responseId": "18CRacGiPIuxjuMPw_mKkAk", "modelVersion": "gemini-3-flash-preview", "usageMetadata": { "totalTokenCount": 22066, "promptTokenCount": 22066 } } ``` The "finishReason": "STOP" in the middle caught my attention, and it seems to be the cause of the abrupt termination of output. ### Plugins oh-my-opencode, opencode-axonhub-tracing ### OpenCode version 1.2.4 ### Steps to reproduce 1. Use custom channels, use Google's SDK 2. When calling Gemini series models, there is a probability of sudden interruption. However, it will not suddenly interrupt when the model outputs text. ### Screenshot and/or share link <img width="1313" height="442" alt="Image" src="https://github.com/user-attachments/assets/80f32779-1a41-4cc1-a1c4-6dce76bddbc8" /> ### Operating System Windows 11 WSL2 Debian ### Terminal Windows Terminal
yindo added the windowsbug labels 2026-02-16 18:12:26 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 15, 2026):


This issue might be a duplicate of a recently closed issue. Please check:

  • #13736: "Custom provider, calling Gemini model with Google SDK results in unexpected interruptions" - Exact duplicate issue from the same author that was closed due to non-compliance, but now your current issue #13780 is compliant with all requirements

Additionally, your issue relates to the underlying Gemini API behavior mentioned in:

  • #11153: "Session loop doesn't stop when model returns finish_reason=stop" - Your issue directly mentions the same finishReason: STOP causing session loops

If this is a new attempt to resolve the issue from #13736, please mention that in your comments so maintainers can help track the investigation.

@github-actions[bot] commented on GitHub (Feb 15, 2026): --- This issue might be a duplicate of a recently closed issue. Please check: - #13736: "Custom provider, calling Gemini model with Google SDK results in unexpected interruptions" - **Exact duplicate issue from the same author** that was closed due to non-compliance, but now your current issue #13780 is compliant with all requirements Additionally, your issue relates to the underlying Gemini API behavior mentioned in: - #11153: "Session loop doesn't stop when model returns finish_reason=stop" - Your issue directly mentions the same `finishReason: STOP` causing session loops If this is a new attempt to resolve the issue from #13736, please mention that in your comments so maintainers can help track the investigation.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9431