-
Notifications
You must be signed in to change notification settings - Fork 2.5k
OpenAI: When using streaming with responses API, tool call arguments are parsed incorrectly. #8049
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
Comments
Thanks for reporting this @nidhi-nair! I'll get a release with the fix out ASAP. |
@nidhi-nair - are you observing issues with tool calling when using the responses API, or is this something that you found by reading the code? FWIW, it's a bit split up in the code, but we do handle both the We do it this way, rather than just capturing the final output on In the meantime I'll verify that our integration tests exercise function calling with the responses API, and if that reveals any issues I'll get a fix out ASAP. |
From manual testing I do see an issue, but it's different from the one that you originally described. I'll fix it, but it'd be good to know if this matches what you're observing on your end. The issue that I'm seeing occurs only when streaming. What happens is I get a tool call from the model, and handle it, but when I call
This appears to be happening because in the streaming output we emit the responses item ID for the tool call in the Fortunately this is a very simple one line fix, and I'll release it in a few minutes. That said - please please let me know if this doesn't replicate the behavior that you're seeing. If that's the case I'll gladly reopen and investigate further. Either way, thanks once again for reporting! |
The fix for this went out in |
@benjamincburns this was a few weeks ago so I'm not entirely sure I'm remembering this correctly, but my observation was that the delta event processing was not aggregating the JSON in a way that could be parsed correctly. IIRC there was code somewhere that collected the args from the delta chunks and pushed it out if it made sense as a JSON, but for whatever reason the deltas never produced a proper aggregated JSON. Hence this workaround solution of adding the This was from observation on behaviour as I was using the library, and I went digging into code afterward. 🙂 I'll check the updated lib for this other error, may be the aggregation logic was somehow linked? |
Checked other resources
Example Code
I haven't generated a sample code, but here's a sample body that gets sent through
Error Message and Stack Trace (if applicable)
Sample streaming response from OpenAI
Description
The streaming response from Open AI for when a tool call is expected contains the full argument body in the event called
response.output_item.done
but we are currently expecting to find this information inresponse.output_item.added
. As a result, the arguments are never parsed correctly in the response.The following patch will fix the immediate issue, but I am unsure of side effects to this.
System Info
The text was updated successfully, but these errors were encountered: