openai-node
openai-node copied to clipboard
No Function Arguments in toolCallDone Stream Event Hook
Confirm this is a Node library issue and not an underlying OpenAI API issue
- [X] This is an issue with the Node library
Describe the bug
The ".on('toolCallDone') used on the stream returned by ai.beta.threads.runs.stream" does not return arguments (empty string), only function name:
{
index: 0,
id: 'call_id',
type: 'function',
function: { name: 'functionName', arguments: '', output: null }
}
To Reproduce
- Retrieve a run stream with
ai.beta.threads.runs.stream - Add the
.on('toolCallDone')hook. - Wait for the response, it does not return with what arguments should the function be called.
Code snippets
const stream = ai.beta.threads.runs.stream(threadId, {
assistant_id: assistantId,
});
stream.on('toolCallDone', (toolCall) => {
console.log(toolCall); // no arguments for function
});
OS
macOS
Node version
v20.11.1
Library version
openai v4.36.0
Thanks for reporting, we'll look into it!
Isn't this a duplicate of my issue #771?
Just for completeness. In the toolCallDone event with the toolCall.type === code_interpreter, then toolCall.code_interpreter.input is also empty.
As a workaround I'm listening to the event thread.run.step.completed and handling runStep.step_details.type === 'tool_calls' then the input and output properties are both not empty for function and code_interpreter.
Also, aside from this still happening 100% of the times a tool is called, I would also like to add that once the tool output is submitted, the assistant doesn't respond with anything, or at least it is not shown by .on('messageDone') nor with any other .on() listener.
When i have multiple function calls, toolCallDone is called once just with first functionCall.
Is there an bug?
When i have multiple function calls, toolCallDone is called once just with first functionCall.
Is there an bug?
That is correct that toolCallDone is called once, it is supposed to be the event triggered once AI finished writing the tool call (see docs). The current bug (unless fixed already, probably not) is that toolCallDone is not usable because when I was testing it, it had the empty function.arguments parameter.
When i have multiple function calls, toolCallDone is called once just with first functionCall. Is there an bug?
That is correct that
toolCallDoneis called once, it is supposed to be the event triggered once AI finished writing the tool call (see docs). The current bug (unless fixed already, probably not) is thattoolCallDoneis not usable because when I was testing it, it had the emptyfunction.argumentsparameter.
Wich one is called for all tool calls?
Actually im using generic events like:
if (event.event === 'thread.run.requires_action') {
const run = event.data;
run.required_action.submit_tool_outputs.tool_calls.map((toolCall) => {
if (toolCall.type === 'function') {
const assistantResponse = {
id: toolCall.id,
role: 'tool',
type: 'FUNCTION',
content: toolCall.function,
status: 'waiting',
};
this.emit('assistantResponse', assistantResponse);
}
});
this.emit('requiresAction');
}
And submitting all tool calls to my sistems
Closing as a duplicate of https://github.com/openai/openai-node/issues/771