fix(agent-server): dedupe models by provider and id, not id alone - #1927
Open
Osamaali313 wants to merge 1 commit into
Open
fix(agent-server): dedupe models by provider and id, not id alone#1927Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
getAvailableModels() deduplicated by model.id only, but model identity in this module is the (provider, id) pair -- isModelConfigValid() matches on model.provider === provider && model.id === modelId. So when the same model id is configured under two providers (e.g. gpt-4o via both openai and azure-openai), the second entry was silently dropped: it went missing from GET /api/v1/models (the picker) and updateSessionModel rejected switching to it with "Invalid model configuration" even though it was configured. Include provider in the dedup key. Genuine duplicates (same provider + id) still collapse. Add regression tests.
✅ Deploy Preview for tarko ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for agent-tars-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
getAvailableModelsinmultimodal/tarko/agent-server/src/utils/model-utils.tsdeduplicates bymodel.idalone:But everywhere else in the same module, model identity is the
(provider, id)pair —isModelConfigValidmatches onmodel.provider === provider && model.id === modelId. The dedup key and the validation key disagree.So when the same model id is configured under two different providers — a common multi-provider setup, e.g.
gpt-4ovia bothopenaiandazure-openai, orclaude-3-5-sonnetviaanthropicandbedrock— the second entry is silently dropped.Impact (live server code)
GET /api/v1/models(src/api/routes/system.ts) →getPublicAvailableModels→ the second provider's model is missing from the model picker served to the UI.updateSessionModel(src/api/controllers/system.ts) →isModelConfigValid→ switching to the shared-id model under the second provider returns HTTP 400 "Invalid model configuration" even though it is configured.AgentSessionuses it for model resolution.Reproduction
getAvailableModels(config)['openai/gpt-4o'](azure dropped)['openai/gpt-4o', 'azure-openai/gpt-4o']isModelConfigValid(config, 'azure-openai', 'gpt-4o')falsetrueGenuine duplicates (same
providerandid) still collapse to one entry.Fix
Include
providerin the dedup key:Tests
Added to
tests/utils/model-utils.test.ts:getAvailableModelskeeps the same id under different providers, and still collapses genuine duplicates.isModelConfigValidvalidates a shared id for each provider.Before the fix, the two new positive cases fail; after, the full
model-utilssuite passes (18 tests). Verified by running the suite against the real module (vitest run tests/utils/model-utils.test.ts).