🎯 fix: Infer Agents Endpoint for Model Specs Naming an Agent - #14889
Open
danny-avila wants to merge 1 commit into
Open
🎯 fix: Infer Agents Endpoint for Model Specs Naming an Agent#14889danny-avila wants to merge 1 commit into
danny-avila wants to merge 1 commit into
Conversation
A model spec whose preset names an `agent_id` but omits `endpoint` was unusable. `isModelSpecEndpointMatch` compares the request's endpoint to `preset.endpoint` by strict equality, so an undefined endpoint matched nothing and every request selecting the spec was rejected with a bare `Model spec mismatch` — an error naming neither the spec nor the missing field. The selector had the matching half of the same gap: `handleSelectSpec` read `preset.endpoint` directly, so it sent no endpoint and skipped assigning `agent_id` to `model`. Fixing only the server would leave the request malformed, so the resolution is shared between both. - Add `resolveModelSpecEndpoint` to `librechat-data-provider`, inferring the agents endpoint when a preset names an agent and none is set. An explicit `endpoint` always wins, so configured specs are unaffected. - Use it for endpoint matching and in the selector, so the menu and the request pipeline resolve a spec identically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A model spec whose preset names an
agent_idbut omitsendpointis completely unusable — selecting it fails every time with:The match is strict equality:
With
preset.endpointundefined, that is false for every endpoint. There is no code path where such a spec can match, so it is dead on arrival — and the error names neither the spec nor the missing field, which makes it hard to act on.This is easy to hit when a spec is authored through a UI rather than hand-written YAML, since only the
agent_idis strictly meaningful to the author.The selector had the same gap
Fixing only the server would not have been enough.
handleSelectSpecreadpreset.endpointdirectly:With the endpoint undefined, the client sends no endpoint and skips assigning
agent_idtomodel— so the request is malformed before it reaches the check. Both halves need the same resolution, which is why this lives inlibrechat-data-providerrather than in either consumer.Changes
resolveModelSpecEndpointtolibrechat-data-provider: returnspreset.endpointwhen set, otherwise infersagentswhen the preset names anagent_id. Only the agents endpoint can serve such a preset, so the inference is unambiguous.packages/api/src/modelSpecs) and in the selector, so the menu and the request pipeline resolve a spec identically.An explicit
endpointalways takes precedence, so existing configured specs are unaffected. Nothing is inferred for presets without an agent.Scoped to
agent_idonly —assistant_idis intentionally left alone, as assistants are being removed.Testing
packages/apiandclienttypecheck clean.modelSpecssuite 11 → 14 tests, and the existingbuildEndpointOptionmiddleware suite (13 tests) still passes. New cases cover:agent_id, noendpoint→ matchesagents, not other endpointsendpointalongsideagent_id→ explicit wins