-
-
Notifications
You must be signed in to change notification settings - Fork 35
Fix gemini OpenAI chat tool calling 2 #264
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
Conversation
zikajk
commented
Jan 13, 2026
- I added a entry in changelog under unreleased section.
Handle OpenAI-compatible providers that send finish_reason=stop alongside tool_calls by deferring :finish, return executed tools from the accumulator, and emit a finish only when no valid tools can run to prevent hung prompts.
Emit string :content for text-only messages (including reason/tag fallback) to improve Gemini/OpenAI-compat payload shape, and update tests to expect string content.
|
@ericdallo Do you think the failing build can be related to my changes? |
|
no, I did a mistake in master that I'm taking a look, I let you know when fixed |
| (string? content) | ||
| [{:type "text" | ||
| :text (string/trim content)}] | ||
| (string/trim content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used maps to keep consistency in the data structure, but I'm ok if that fix problems, I just hope to not cause any other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is supported, but often not recommended so I decided to take the safe route here :-).
And I suppose it will save some tokens as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think tokens are calculated based on the structure, but on the chars content, but I'm ok with that
|
@ericdallo The Gemini is still buggy though. It looks like its OPENAI api isn't perfect.
|
|
@ericdallo Regarding the rare problem with broken gemini thinking tag. It is not something I will fix in this PR. |
|
@zikajk does that means it's a bug only with gemini or other providers? is it possible to repro with other providers so I can try? |
Only with Gemini. I have an experimental branch where reasoning is purged from history (user can opt-out via provider config). |
I see, but for other models I'd say this is unlikely, as at least major models like openai and anthropic this is required, but let's test, but I'd say it should affect model quality |
Can you point me to the documentation? I know they use different API but I am curious. |
https://platform.openai.com/docs/api-reference/responses/create
Anthropic has the same here, mentioning to pass back thinking blocks |
The Gemini also requires to keep the encrypted version (thought_signatures).
But yeah, I am keeping the mentioned branch experimental and I don't plan it to make it PR until I am absolutely sure that it helps. |
ericdallo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this done? can you add changelog entry please?
|
@ericdallo Done. |

