-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix empty tool call ID causing API errors when switching providers #4590
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
base: dev
Are you sure you want to change the base?
Conversation
| return false | ||
| }), | ||
| ), | ||
| ...modelMessages, |
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.
what was the reason for this?
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.
@rekram1-node extracted it for readability since the streamtext call was getting too long, but yeah could use ...(await ...) too. should i revert to inline style?
| return false | ||
| }), | ||
| ), | ||
| ...modelMessages, |
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.
what's the reason for this change?
|
@9j are you sure this fixes the issue? I can't get google to not generate ids |
|
ahh I see ur message it was specifically with the invalid tool |
I believe, the correct fix is here, all the other changes you made can be undone, just make sure that the id is set here |
917250b to
f4593c6
Compare
There are cases like this. And when I built and tested with the version of the code I wrote, this problem was resolved.
|
|
Yeah can you show me a tool call from gemini that has no id? Your example didnt have that but it did have the invalid tool missing an id Yeah we can do the other thing repair the session too but I think this is an edge case when the model calls a tool that doesnt exist But maybe it happens more often with gemini can u show an example? |
f1dc981 to
3e15a39
Compare
df8bdf9 to
0dd5039
Compare
I experienced this issue when switching from Gemini 3 Pro to Claude. Here's what I found: Evidence from my storage: You're right that the invalid tool case is when the model calls a non-existent tool. But I also found multiple cases where Gemini 3 Pro generates empty callIDs for normal tool Not sure if this is model-specific or provider-specific, but all empty callIDs in my storage came from the same session where I used Gemini 3 Pro and then switched to Claude. |
|
ah okay makes sense, just wanted to avoid code if we could help it, I guess if u can resolve the conflicts this is basically good to go |
bc8d99c to
7ec9c1b
Compare
|
@rekram1-node done! |
Some providers (e.g. Gemini) don't generate tool call IDs, resulting in empty callID being stored. This causes errors when switching to providers that require tool call IDs (e.g. Anthropic, OpenAI). - Generate fallback ulid() when value.id is empty from stream events - Make toModelMessage async to fix empty callID in existing stored data - Update storage with generated ID when empty callID is found
7ec9c1b to
e0feae2
Compare
|
@rekram1-node done again |
|
ill merge in the morning thanks for your work on this |
f8ee907 to
6a9856d
Compare
|
@rekram1-node Just a friendly bump! 👋 Let me know if there's anything else needed from my side before merging. |
close #1279
Problem
Some providers (e.g. Gemini) don't generate tool call IDs, resulting in empty callID being stored. When switching to providers that require tool call IDs (e.g. Anthropic, OpenAI), this causes API errors with "id": "" in tool_use blocks.
Solution
Test plan