fix: surface GitHub Copilot AI provider in Coder Agents chat#26387
Draft
DanielleMaywood wants to merge 1 commit into
Draft
fix: surface GitHub Copilot AI provider in Coder Agents chat#26387DanielleMaywood wants to merge 1 commit into
DanielleMaywood wants to merge 1 commit into
Conversation
A Copilot AI provider was always reported unavailable in the chat model catalog. chatprovider.NormalizeProvider had no copilot case, so the provider normalized to an empty string and was dropped before availability resolution, and ResolveUserProviderKeys had no path to mark it available without an API key. Copilot rejects API keys by design and authenticates via request-time GitHub OAuth tokens injected by aibridge, so it could never satisfy the key-based availability check. This left the Agents page showing 'set up a provider then add a model' even after an admin created a Copilot provider and model, while Anthropic worked because it carries a stored API key. Recognize copilot as a supported provider, treat it like Bedrock's ambient-credential path so it resolves available without a key, and add its display label on both backend and frontend.
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.
Note
🤖 This PR was written by Coder Agent on behalf of Danielle Maywood
Problem
After an admin configures a GitHub Copilot AI provider and creates a model for it, the Coder Agents page still shows "set up a provider then add a model" and the model never appears in the selector. Configuring an Anthropic provider + model works.
Root cause
The chat model catalog only surfaces providers it marks
available: true. For a Copilot provider, that flag is never set:chatprovider.NormalizeProviderhad nocopilotcase, so"copilot"normalized to""and was dropped before availability was ever computed (inResolveUserProviderKeys,ListConfiguredModels, andorderProvidersviasupportedProviderNames).ResolveUserProviderKeyshad no path to mark Copilot available. Copilot rejects API keys by design (coderd/ai_providers.go) and authenticates via request-time GitHub OAuth tokens injected by aibridge, so it can never satisfy the key-based availability check. The only keyless ("ambient credentials") path was hard-coded to Bedrock.Net effect on the frontend:
getAvailableProvidersfilters toprovider.available === true, socountConfiguredProviderConfigsandgetModelOptionsFromConfigsboth drop Copilot, collapsingproviderCount/modelCountto0and rendering the setup notice. Anthropic works only because it carries a stored API key.Execution was never the problem: chatd already routes Copilot through the AI Gateway via the OpenAI-compatible
defaultbranch offantasyConfigForAIBridge, with credentials delegated to aibridged.Fix
In
coderd/x/chatd/chatprovider/chatprovider.go:copilotas a supported provider (NormalizeProvider,supportedProviderNames, display nameGitHub Copilot).ProviderAllowsAmbientCredentialsreturns true for Copilot, andResolveUserProviderKeysresolves a configured Copilot provider as available without an API key. A missing GitHub link now surfaces as a runtime error instead of silently hiding the provider.In
site/src/utils/aiProviders.ts:GitHub Copilotdisplay label for the model selector.Tests
TestResolveUserProviderKeys_Copilot— a keyless Copilot provider resolvesAvailable: truewith an ambient (empty) key entry.TestListConfiguredModels_Copilot— a Copilot provider + model appears in the catalog and is available.Both fail on
mainand pass with this change. ExistingTestListChatModelsand the fullchatproviderpackage still pass.Verification
Notes / follow-ups