Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: prevent BYOK model from conflicting with same-named Copilot model in picker#246

Open
rsd-darshan wants to merge 7 commits into
microsoft:mainfrom
rsd-darshan:fix/byok-model-picker-conflict
Open

fix: prevent BYOK model from conflicting with same-named Copilot model in picker#246
rsd-darshan wants to merge 7 commits into
microsoft:mainfrom
rsd-darshan:fix/byok-model-picker-conflict

Conversation

@rsd-darshan
Copy link
Copy Markdown
Contributor

Summary

  • Fixes [Bug] BYOK model conflict #167
  • When a BYOK model was given the same name as a Copilot-native model (e.g. GPT-4.1), both dropdown items in the model picker received the same ID, causing both to appear selected simultaneously
  • Added ModelUtils.getPickerId() which returns providerName_modelName for BYOK models and modelName for standard models, ensuring each item has a unique identity in the picker
  • Updated ModelPickerGroupsBuilder and ModelService to use this unique ID consistently for item construction, selection display, and lookup

Test plan

  • Create an OpenAI model provider in BYOK settings
  • Add a model named GPT-4.1 (same as a Copilot-native model)
  • Open the model picker — verify only one model appears selected at a time
  • Select the BYOK GPT-4.1 — verify the correct model is used and requests succeed
  • Select the native GPT-4.1 — verify it also works correctly and independently

…l in picker

When a BYOK model is named identically to a Copilot-native model (e.g. GPT-4.1),
both dropdown items received the same ID, causing the picker to highlight both
as selected simultaneously.

Use a provider-prefixed picker ID for BYOK models so each item has a unique
identity, and update the selection and lookup logic to match.

Fixes microsoft#167
Copilot AI review requested due to automatic review settings May 20, 2026 15:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes model picker selection conflicts when a BYOK model shares the same display name as a Copilot-native model by introducing a unique picker identity and using it consistently across picker item creation, selection display, and model lookup.

Changes:

  • Added ModelUtils.getPickerId() to generate unique IDs for picker items (BYOK: providerName_modelName, native: modelName).
  • Updated model lookup in ModelService#setActiveModel to match by picker ID.
  • Updated picker binding and dropdown item construction to use the new picker ID.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/utils/ModelUtils.java Adds getPickerId() helper to generate unique picker IDs.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/ModelService.java Uses picker ID for active model lookup and selected item display.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ModelPickerGroupsBuilder.java Uses picker ID as dropdown item id to prevent collisions.
Comments suppressed due to low confidence (1)

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/ModelService.java:1

  • setActiveModel(String modelName) now effectively expects a picker ID (sometimes providerName_modelName) rather than a plain model name. This is a behavioral/API contract change that can break existing call sites that pass getModelName(). Consider (a) renaming the parameter/method to reflect the new meaning (e.g., setActiveModelByPickerId(String pickerId)), or (b) supporting both formats for backward compatibility (first match by picker ID, then fallback match by getModelName() when no picker-id match is found).
// Copyright (c) Microsoft Corporation.

Existing internal callers pass plain model names (e.g. fallback model,
custom mode event). Match by picker ID first, then fall back to model
name so both call patterns keep working.
@jdneo
Copy link
Copy Markdown
Member

jdneo commented May 21, 2026

Hi @rsd-darshan, thank you for your contribution. Pls check the copilot review first :)

…concatenation

Replaces the custom providerName + "_" + modelName concatenation with the
model's existing getModelKey() method, which already produces a stable
composite key used throughout the codebase. This avoids potential collisions
from naive string concatenation and eliminates the blank-provider-name edge case.
@rsd-darshan
Copy link
Copy Markdown
Contributor Author

@jdneo addressed the Copilot review comments — switched to using the model's existing getModelKey() method for the picker ID, which avoids both the concatenation collision and the blank-provider-name edge case. Conversations resolved.

…dules (microsoft#208)

Replace getPickerId() wrapper with direct model.getModelKey() calls at each
use site, removing the unnecessary indirection.
- setActiveModel now accepts only a composite model key (modelKey),
  matching the picker ID used throughout the codebase
- Custom mode event handler resolves the model name to a key via
  findModelKeyByName() before calling setActiveModel
- ModelHoverContentProvider uses model.getModelKey() directly instead
  of model.getModelName()
@jdneo
Copy link
Copy Markdown
Member

jdneo commented May 22, 2026

@ethanyhou Currently we have fallback model related logics in ModelService. Is it still require after TBB rolls out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] BYOK model conflict

3 participants