diff --git a/web/hooks/useCreateNewThread.ts b/web/hooks/useCreateNewThread.ts index 40e554945e..1094ec621d 100644 --- a/web/hooks/useCreateNewThread.ts +++ b/web/hooks/useCreateNewThread.ts @@ -191,9 +191,11 @@ export const useCreateNewThread = () => { async (thread: Thread) => { updateThread(thread) - setActiveAssistant(thread.assistants[0]) updateThreadCallback(thread) - updateAssistantCallback(thread.id, thread.assistants[0]) + if (thread.assistants && thread.assistants?.length > 0) { + setActiveAssistant(thread.assistants[0]) + updateAssistantCallback(thread.id, thread.assistants[0]) + } }, [ updateThread,