Skip to content

fix: hide and reject chat models from disabled AI providers - #27070

Merged
ibetitsmike merged 12 commits into
mainfrom
mike/codagt-601-disabled-provider-selectable-models
Jul 19, 2026
Merged

fix: hide and reject chat models from disabled AI providers#27070
ibetitsmike merged 12 commits into
mainfrom
mike/codagt-601-disabled-provider-selectable-models

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Disabling an AI provider did not remove its models from the chat model selector, the subagent override selectors, or the advisor settings, and the API still accepted requests that resolved to a model under a disabled provider. Sending a message with such a model only failed later in generation with chat failed unexpectedly.

The frontend now filters model options down to configs whose provider row is enabled and present (chat picker, subagent overrides, advisor settings), folds provider-query loading and error state into the Coder Agents settings sections, blocks disabled providers on the add-model path, and invalidates chat model queries when providers change. The models management view intentionally keeps listing configs of disabled providers.

The backend rejects unusable models with a 400 at admission on every path instead of failing at generation time:

  • explicit model_config_id at chat create, send message, edit message, and the subagent/advisor override endpoints
  • the send-message fallback (last model, then default) and the create-chat default resolution
  • the edit-message path that preserves the edited message's original model
  • the chatd daemon rechecks explicit models before persisting (create, send, edit), closing the race where an admin disables the model or provider after the coderd preflight
  • default reselection (after deleting or unsetting the default) prefers configs that are enabled under an enabled provider

Closes https://linear.app/codercom/issue/CODAGT-601/disabled-providers-still-expose-selectable-models

This PR was created by Mux, an AI agent working on Mike's behalf. It was iterated to green through the Codex review loop (10 review threads addressed).

@linear-code

linear-code Bot commented Jul 7, 2026

Copy link
Copy Markdown

CODAGT-601

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00f216757a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/src/pages/AgentsPage/utils/modelOptions.ts Outdated
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec46e50453

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96aacc468f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread site/src/pages/AISettingsPage/ModelsPage/components/ModelFormProviderSelect.tsx Outdated
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29ef7f6c4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/exp_chats.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 66528f0c45

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/exp_chats.go Outdated
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 495c32dfab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/chatd.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7517ac6a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/exp_chats.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 12cfc92b7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/chatd.go Outdated
Comment thread site/src/pages/AgentsPage/components/AdvisorSettings.tsx Outdated
@ibetitsmike
ibetitsmike marked this pull request as ready for review July 17, 2026 11:07
Disabling an AI provider left its enabled model configs selectable in
the frontend and accepted by the API, producing an unclear runtime
failure. Model selectors now filter by provider row (instance) state,
and the create-chat, send-message, edit-message, subagent/advisor
override endpoints reject model configs whose provider is disabled
with a clear 400.

- codersdk: expose provider enabled state on UserChatProviderConfig
- site: skip disabled-provider configs in model option builders, the
  subagent/advisor override selectors, and the model form provider
  select (create flow only); invalidate chat queries on AI provider
  mutations
- coderd: validate explicit model_config_id at admission using the
  existing availability check; advisor override PUT now requires an
  enabled config + provider
- admin model-config list keeps returning provider-disabled configs
  so the ModelsPage management view can show them

Fixes coder/internal#CODAGT-601

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 562ef458cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/exp_chats.go
Comment thread coderd/exp_chats.go
Extract validateExplicitChatModelConfigAvailable for the send/edit
admission checks, route getModelOptionsFromConfigs through
filterConfigsWithEnabledProvider, pass precomputed enabledModelConfigs
to AdvisorSettings instead of refiltering, and parallelize provider
mutation query invalidations. No behavior changes.
… info

The user provider key configs endpoint omits disabled providers unless
the user has a key for them, so a missing provider row means the
provider is disabled or deleted. Treating missing rows as enabled let
admins select models under a disabled provider whenever another enabled
provider of the same type kept the catalog type available.
The Coder Agents settings page filters model configs by provider
enablement, but only reported the model config query's loading and
error state. While the provider query was still loading or after it
failed, the filter saw an empty provider map and hid every model, which
made saved subagent and advisor overrides look unavailable and could
let AdvisorSettings clear a valid override on save. Combine both
queries' loading, fetching, and error state so the sections stay in
their loading or error UI until provider data is ready.
The add-model page derives its provider selection from the ?provider=
query param, and canManageProviderModels did not check provider
enablement, so a disabled provider stayed selectable and the form could
submit a create request the backend rejects. Treat disabled providers
as unmanageable, keep the selected disabled provider visible only in
edit mode, and explain the disabled state in the add-page fallback.
When a chat omitted model_config_id, admission reused the chat's last
model via a lookup that only excluded deleted configs, so chats whose
model or provider was disabled kept sending requests through the
disabled provider. Resolve the fallback through the enabled-config
lookup: a disabled last model now falls back to the default, and a
disabled default is rejected with ErrNoDefaultChatModelConfig instead
of being admitted and failing at generation time.
Creating a chat without model_config_id resolved the default model
without checking that it and its provider are enabled, so disabling the
default model's provider let POST /chats create a running chat that
only failed later at generation time. Validate the resolved default
through the enabled-config lookup and reject the request with a 400 at
admission, matching the send-message fallback behavior.
Sending a message without an explicit model can now fail with
ErrNoDefaultChatModelConfig when the chat's last model and the default
are both unavailable. The send handler did not map that error, so users
got a generic 500 instead of the admission error chat creation returns
for the same state.
Editing a message without model_config_id preserved the edited
message's original model without checking that it is still usable, so
edits kept routing through disabled models or providers and failed at
generation time. Resolve the preserved model through the send-message
fallback (disabled model falls back to the default, disabled default is
rejected) and map the rejection to a 400 in the edit handler.
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-601-disabled-provider-selectable-models branch from 562ef45 to 7611114 Compare July 17, 2026 11:27
@coderagents

coderagents Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

Updates Needed

  • docs/ai-coder/agents/models.md - The "How developers select models" section says the selector "shows only models from providers that have valid credentials configured." This PR also filters the model selectors (chat picker, subagent overrides, advisor settings) by the provider's enabled state, so disabling a provider now hides its models from developers even when credentials are set. Update this section to reflect provider enable/disable, and note that the admin Models management view intentionally still lists configs belonging to disabled providers.

Automated review via Coder Agents

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b70bd3705c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/exp_chats.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 311e96affe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike merged commit 9b3af62 into main Jul 19, 2026
32 of 33 checks passed
@ibetitsmike
ibetitsmike deleted the mike/codagt-601-disabled-provider-selectable-models branch July 19, 2026 06:33
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants