Closed
Description
Description
When using the stop function from useAssistant, the stream stops to the client, but the run continues. If you try to start another run, and the first one (the one you thought you cancelled) has not finished, you get the error:
"Can't add messages to thread_xyz while a run run_abc is active.",
The stop function should also cancel the run:
https://platform.openai.com/docs/api-reference/runs/cancelRun
Code example
const {
status,
input,
messages,
submitMessage,
stop,
error
} = useAssistant({...})
const handleCancel = () => {
if ($status === 'in_progress') stop();
}
Additional context
The 'error' also has a 'DOMException: BodyStreamBuffer was aborted' error when calling the stop function, but this error is expected and should be ignored.
Side note -If the useAssistant messages included more information about the message (for example, the assistant_id, or createdAt fields) this could also be super helpful.