From 4d93a559757aed1df96625c18b98fd3cbac10d86 Mon Sep 17 00:00:00 2001 From: christian Date: Tue, 17 Mar 2026 10:55:47 +0100 Subject: [PATCH] fix: persist modelLabel to DB and derive from spec as fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All chat (including bedrock specs) goes through /api/agents/chat/:endpoint. The buildOptions middleware nests conversation settings inside model_parameters, then the AgentClient constructor was never given modelLabel — so getSaveOptions() always returned modelLabel: undefined, which was stripped by removeNullishValues. The field was never saved to the database, so every page refresh lost it. Two fixes: 1. api/server/services/Endpoints/agents/initialize.js (backend — the real bug) Pass modelLabel from model_parameters to the AgentClient constructor, so it gets persisted to the conversation in MongoDB. 2. client/src/hooks/Conversations/useGetSender.ts (frontend — defensive fallback) When a loaded conversation has a spec but no modelLabel (older conversations that were saved before this fix), derive the display label from the spec configuration instead of falling back to "AWS Bedrock". Co-Authored-By: Claude Sonnet 4.6 (1M context) --- api/server/services/Endpoints/agents/initialize.js | 1 + client/src/hooks/Conversations/useGetSender.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/api/server/services/Endpoints/agents/initialize.js b/api/server/services/Endpoints/agents/initialize.js index 08f631c3d2..16ff7ffc2f 100644 --- a/api/server/services/Endpoints/agents/initialize.js +++ b/api/server/services/Endpoints/agents/initialize.js @@ -441,6 +441,7 @@ const initializeClient = async ({ req, res, signal, endpointOption }) => { endpointType: endpointOption.endpointType, resendFiles: primaryConfig.resendFiles ?? true, maxContextTokens: primaryConfig.maxContextTokens, + modelLabel: endpointOption.model_parameters?.modelLabel, endpoint: isEphemeralAgentId(primaryConfig.id) ? primaryConfig.endpoint : EModelEndpoint.agents, }); diff --git a/client/src/hooks/Conversations/useGetSender.ts b/client/src/hooks/Conversations/useGetSender.ts index cced4ca4fe..51d03b0db9 100644 --- a/client/src/hooks/Conversations/useGetSender.ts +++ b/client/src/hooks/Conversations/useGetSender.ts @@ -1,15 +1,21 @@ import { useCallback } from 'react'; import { getResponseSender } from 'librechat-data-provider'; import type { TEndpointOption, TEndpointsConfig } from 'librechat-data-provider'; -import { useGetEndpointsQuery } from '~/data-provider'; +import { useGetEndpointsQuery, useGetStartupConfig } from '~/data-provider'; export default function useGetSender() { const { data: endpointsConfig = {} as TEndpointsConfig } = useGetEndpointsQuery(); + const { data: startupConfig } = useGetStartupConfig(); return useCallback( (endpointOption: TEndpointOption) => { const { modelDisplayLabel } = endpointsConfig?.[endpointOption.endpoint ?? ''] ?? {}; - return getResponseSender({ ...endpointOption, modelDisplayLabel }); + let { modelLabel } = endpointOption; + if (!modelLabel && endpointOption.spec) { + const spec = startupConfig?.modelSpecs?.list?.find((s) => s.name === endpointOption.spec); + modelLabel = spec?.preset?.modelLabel ?? spec?.label ?? null; + } + return getResponseSender({ ...endpointOption, modelLabel, modelDisplayLabel }); }, - [endpointsConfig], + [endpointsConfig, startupConfig], ); }