diff --git a/client/src/hooks/Agents/useSelectAgent.ts b/client/src/hooks/Agents/useSelectAgent.ts index bda268062f..585554fc39 100644 --- a/client/src/hooks/Agents/useSelectAgent.ts +++ b/client/src/hooks/Agents/useSelectAgent.ts @@ -1,6 +1,11 @@ import { useCallback, useState } from 'react'; import { useQueryClient } from '@tanstack/react-query'; -import { EModelEndpoint, isAgentsEndpoint, Constants, QueryKeys } from 'librechat-data-provider'; +import { + Constants, + QueryKeys, + EModelEndpoint, + isAssistantsEndpoint, +} from 'librechat-data-provider'; import type { TConversation, TPreset, Agent } from 'librechat-data-provider'; import useDefaultConvo from '~/hooks/Conversations/useDefaultConvo'; import { useAgentsMapContext } from '~/Providers/AgentsMapContext'; @@ -24,22 +29,22 @@ export default function useSelectAgent() { const updateConversation = useCallback( (agent: Partial, template: Partial) => { logger.log('conversation', 'Updating conversation with agent', agent); - if (isAgentsEndpoint(conversation?.endpoint)) { - const currentConvo = getDefaultConversation({ - conversation: { ...(conversation ?? {}), agent_id: agent.id }, - preset: template, - }); - newConversation({ - template: currentConvo, - preset: template as Partial, - keepLatestMessage: true, - }); - } else { + if (isAssistantsEndpoint(conversation?.endpoint)) { newConversation({ template: { ...(template as Partial) }, preset: template as Partial, }); + return; } + const currentConvo = getDefaultConversation({ + conversation: { ...(conversation ?? {}), agent_id: agent.id }, + preset: template, + }); + newConversation({ + template: currentConvo, + preset: template as Partial, + keepLatestMessage: true, + }); }, [conversation, getDefaultConversation, newConversation], );