-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Confirm this is a Node library issue and not an underlying OpenAI API issue
- This is an issue with the Node library
Describe the bug
When an Assistant run finishes with thread.run.incomplete, the library throws an OpenAIError: Final run has not been received. However, according to the OpenAI documentation, this is a valid transition, and the thread should still be able to continue.
Despite this, the library stops the event stream, preventing further continuation of the thread. This seems to be an unintended behavior, as the thread should still be available for further interaction.
I have traced the error to the main switch that handles all the events:
openai-node/src/lib/AssistantStream.ts
Lines 363 to 403 in 41a7ce3
| switch (event.event) { | |
| case 'thread.created': | |
| //No action on this event. | |
| break; | |
| case 'thread.run.created': | |
| case 'thread.run.queued': | |
| case 'thread.run.in_progress': | |
| case 'thread.run.requires_action': | |
| case 'thread.run.completed': | |
| case 'thread.run.failed': | |
| case 'thread.run.cancelling': | |
| case 'thread.run.cancelled': | |
| case 'thread.run.expired': | |
| this.#handleRun(event); | |
| break; | |
| case 'thread.run.step.created': | |
| case 'thread.run.step.in_progress': | |
| case 'thread.run.step.delta': | |
| case 'thread.run.step.completed': | |
| case 'thread.run.step.failed': | |
| case 'thread.run.step.cancelled': | |
| case 'thread.run.step.expired': | |
| this.#handleRunStep(event); | |
| break; | |
| case 'thread.message.created': | |
| case 'thread.message.in_progress': | |
| case 'thread.message.delta': | |
| case 'thread.message.completed': | |
| case 'thread.message.incomplete': | |
| this.#handleMessage(event); | |
| break; | |
| case 'error': | |
| //This is included for completeness, but errors are processed in the SSE event processing so this should not occur | |
| throw new Error( | |
| 'Encountered an error event in event processing - errors should be processed earlier', | |
| ); | |
| } |
the
thread.run.incomplete event is not handled anywhere, so I suppose that is the error thrown when a final state is not handled.
To Reproduce
- Create a new Assistant
- Create a new Thread for that assistant
- Add a new message that raises a
thread.run.incompletestate (e.g., a message that raises acontent_filtererror) - Start the run in streaming mode
- Observe the error be thrown from the library
Code snippets
OS
Ubuntu
Node version
Node 22.4.0
Library version
4.83.0 and 5.0.0-alpha.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working