Skip to content

fix: Pause text updates during active tool calls (gemini-2.5-pro bug) #2024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

paflopes
Copy link

Originally I found this issue with Gemini 2.5 Pro models in OpenRouter and AI Studio. The problem is in the example below

image

Most of the times, it breaks the AI for the rest of the conversation, sometimes it doesn't.

The issue is that Gemini returns a tool call in the stream, then it sends the same tool but this time in content:

data: {"id":"gen-1755460677-sseVdUiRiZKHTQpgBrkm","provider":"Google AI Studio","model":"google/gemini-2.5-pro","object":"chat.completion.chunk","created":1755460677,"choices":[{"index":0,"delta":{"role":"assistant","content":null,"tool_calls":[{"index":0,"id":"tool_0_glob","type":"function","function":{"name":"glob","arguments":"{\"pattern\":\"**/*.test.ts\"}"}}]},"finish_reason":"tool_calls","native_finish_reason":null,"logprobs":null}]}
data: {"id":"gen-1755460677-sseVdUiRiZKHTQpgBrkm","provider":"Google AI Studio","model":"google/gemini-2.5-pro","object":"chat.completion.chunk","created":1755460677,"choices":[{"index":0,"delta":{"role":"assistant","content":"call:glob{pattern:","reasoning":null,"reasoning_details":[]},"finish_reason":"stop","native_finish_reason":"STOP","logprobs":null}]}
data: {"id":"gen-1755460677-sseVdUiRiZKHTQpgBrkm","provider":"Google AI Studio","model":"google/gemini-2.5-pro","object":"chat.completion.chunk","created":1755460677,"choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null,"native_finish_reason":null,"logprobs":null}],"usage":{"prompt_tokens":13280,"completion_tokens":280,"total_tokens":13560,"prompt_tokens_details":{"cached_tokens":0}}}
data: [DONE]

This commit prevents this by not appending any assistant messages after a tool call is made, until it gets a response.

@paflopes paflopes closed this Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant