Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

☑️ refactor: Allow Mid-convo Agent Selection from Agent Panel (#8510)

Danny Avila0b1b0af741aa
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<Agent>, template: Partial<TPreset | TConversation>) => {
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<TPreset>,
- keepLatestMessage: true,
- });
- } else {
+ if (isAssistantsEndpoint(conversation?.endpoint)) {
newConversation({
template: { ...(template as Partial<TConversation>) },
preset: template as Partial<TPreset>,
});
+ return;
}
+ const currentConvo = getDefaultConversation({
+ conversation: { ...(conversation ?? {}), agent_id: agent.id },
+ preset: template,
+ });
+ newConversation({
+ template: currentConvo,
+ preset: template as Partial<TPreset>,
+ keepLatestMessage: true,
+ });
},
[conversation, getDefaultConversation, newConversation],
);