runTools() without stream:true incorrectly emits "message" events for messages passed in #994
Closed
1 task done
Labels
bug
Something isn't working
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
The documentation for the "message" event on the runner returned by
openai.beta.chat.completions.runTools()
says "The event fired when a new message is either sent or received from the API. Does not fire for the messages sent as the parameter to either.runTools()
or.stream()
". This works correctly if you passstream: true
in the options torunTools()
, but if you don't passstream: true
, the runner always emits "message" events for all of the messages including those passed in as parameters.This is an issue for me because I want to record all the messages (including tool calls and tool results) generated by a
runTools()
call and add them to the list of existing messages so that they're visible to GPT when processing future messages from the user, and from the docs it looks like the "message" events are the proper way to do this, but because of this issue it seems like there's no clean way to do what I need unless I pass instream: true
, which doesn't seem like it's meant to affect this behavior. (I have no issue with usingstream: true
but it took me a while to think to try it.)I initially wondered if this bug was tied to how I was using
runTools()
, but I run into this same exact issue with the in-repo example at https://github.com/openai/openai-node/blob/master/examples/function-call-helpers.ts (okay that uses the olderrunFunctions()
method instead but I'm assuming it's meant to work the same).To Reproduce
openai.beta.chat.completions.runTools()
with one or more messages, without specifyingstream: true
.runTools()
call.runTools()
call to set thestream: true
option and see that it correctly emits "message" events only for new messages.Code snippets
OS
Windows
Node version
Node v21.7.3, Deno 1.45.5
Library version
openai v4.55.7
The text was updated successfully, but these errors were encountered: