No Function Arguments in toolCallDone Stream Event Hook
Problem
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: [code block] To Reproduce 1. Retrieve a run stream with `ai.beta.threads.runs.stream` 2. Add the `.on('toolCallDone')` hook. 3. Wait for the response, it does not return with what arguments should the function be called. Code snippets [code block] OS macOS Node version v20.11.1 Library version openai v4.36.0
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Implement Argument Handling in toolCallDone Event
The current implementation of the '.on('toolCallDone')' event does not correctly pass the function arguments due to a missing or incorrect event emission in the Node library. This results in an empty string being returned instead of the expected arguments.
Awaiting Verification
Be the first to verify this fix
- 1
Check Event Emission
Inspect the source code of the Node library to ensure that the 'toolCallDone' event is emitting the correct arguments. Look for the event emitter logic in the relevant module.
javascriptconst EventEmitter = require('events'); class ToolRunner extends EventEmitter { // ... completeToolCall(args) { this.emit('toolCallDone', args); } } - 2
Modify Event Emission Logic
If the event emission is incorrect, modify it to ensure that the correct arguments are passed when the 'toolCallDone' event is emitted. This may involve changing the parameters of the function that emits the event.
javascriptthis.emit('toolCallDone', { functionName: this.functionName, args: args }); - 3
Update Event Listener
Ensure that the event listener for 'toolCallDone' is set up to handle the new argument structure. Update the listener to access the arguments correctly.
javascriptai.beta.threads.runs.stream.on('toolCallDone', ({ functionName, args }) => { console.log(`Function: ${functionName}, Args: ${JSON.stringify(args)}`); }); - 4
Test the Changes
Run a test to confirm that the 'toolCallDone' event now returns the expected arguments. Use a mock or a test case to verify that the arguments are correctly emitted and received.
javascriptconst mockArgs = ['arg1', 'arg2']; // Trigger the event completeToolCall(mockArgs);
Validation
To confirm the fix worked, run the application and check the console output for the 'toolCallDone' event. Ensure that it logs the correct function name and the arguments passed to it. If the arguments are displayed as expected, the fix is successful.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep