fix: forward modelLabel to AgentClient so it reaches the model - #15332
fix: forward modelLabel to AgentClient so it reaches the model#15332AyushCipher wants to merge 23 commits into
Conversation
modelSpecs.list[].preset.modelLabel was resolved and displayed correctly in the UI, but was never actually sent to the model for any endpoint (custom endpoints like OpenRouter included, since all endpoints now route through the unified AgentClient). api/server/services/Endpoints/agents/initialize.js already read endpointOption.model_parameters.modelLabel to compute the display sender name, but never forwarded the raw value into the options object passed to `new AgentClient(...)`. AgentClient (client.js) already expected `this.options.modelLabel` in several places - most importantly to set `assistantName` in formatMessage(), which stamps a `name` field onto outgoing assistant messages, making the label visible to the model - so the value was silently undefined the whole time. Fixes danny-avila#14968
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, matches the documented/expected data flow, and includes a targeted test asserting the forwarding behavior.
Pull request overview
This PR fixes a gap in the unified Agents endpoint flow where modelSpecs.list[].preset.modelLabel was correctly resolved/displayed in the UI but never forwarded into the AgentClient options, preventing it from reaching model-visible message context (via formatMessage()’s assistant name).
Changes:
- Forward
endpointOption.model_parameters.modelLabelinto thenew AgentClient(...)constructor options soclient.jscan usethis.options.modelLabel(including forformatMessage()andgetSaveOptions()). - Add a Jest test that simulates a custom endpoint ephemeral agent (OpenRouter-style) and asserts the
AgentClientconstructor receivesmodelLabel.
File summaries
| File | Description |
|---|---|
| api/server/services/Endpoints/agents/initialize.js | Passes modelLabel through to AgentClient options so it can be applied to outgoing assistant messages and persisted in save options. |
| api/server/services/Endpoints/agents/initialize.spec.js | Adds coverage to ensure model_parameters.modelLabel is forwarded for custom endpoint ephemeral agents. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
👋 Thanks for the contribution! LibreChat merges all changes into Nothing is needed from you; your commits, reviews and discussion are unchanged. If the diff now shows files you did not touch, rebase onto git remote add upstream https://github.com/danny-avila/LibreChat.git
git fetch upstream dev
git rebase upstream/dev
git push --force-with-leaseMaintainers: apply the |
modelSpecs.list[].preset.modelLabelwas resolved and displayed correctly in the UI, but was never actually sent to the model for any endpoint (custom endpoints like OpenRouter included, since all endpoints now route through the unifiedAgentClient).api/server/services/Endpoints/agents/initialize.jsalready computed the display sender name fromendpointOption.model_parameters.modelLabel, but never forwarded the raw value into the options object passed tonew AgentClient(...).AgentClient(client.js) already expectedthis.options.modelLabelin several places but most importantly to setassistantNameinformatMessage(), which stamps anamefield onto outgoing assistant messages, making the label visible to the model, so the value was silentlyundefinedthe whole time.Fixes #14968
Summary
Forward the already-resolved
modelLabelinto theAgentClientconstructor options inapi/server/services/Endpoints/agents/initialize.js, so it reachesformatMessage()'sassistantNameand is included in the model-visible message context, matching the documented behavior. No other files needed changes. The value was already being parsed and resolved correctly everywhere else.Change Type
Testing
Added a test case in
api/server/services/Endpoints/agents/initialize.spec.jsthat simulates a custom-endpoint (OpenRouter-style) ephemeral agent withmodel_parameters.modelLabelset, and asserts the value reaches the capturedAgentClientconstructor args.Ran:
jest server/services/Endpoints/agents/initialize.spec.js— 50/50 passing (including the new test)eslinton both touched files — cleanprettier --checkon both touched files — cleanstatic-checkspre-commit hook (lint-staged, circular-dependency check) — passedTest Configuration:
Node v22 (repo declares
>=24.0.0; ran with a slightly older local Node, no issues observed), Windows.Checklist