fix: persist modelLabel to DB and derive from spec as fallback

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) <noreply@anthropic.com>
This commit is contained in:
christian 2026-03-17 10:55:47 +01:00
parent 5b31bb720d
commit 4d93a55975
2 changed files with 10 additions and 3 deletions

View file

@ -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,
});

View file

@ -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],
);
}