feat!: scope chat model override settings to organizations - #28442
Conversation
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a57249cba
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9363044002
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4f1af0b11
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2935b3d438
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 940b95cb8f
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 137f88b755
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Documentation CheckThis PR moves chat model override settings from deployment scope to organization scope. The two affected published docs have been updated to match. Updates Needed
All previously flagged documentation is now accurate. Automated review via Coder Agents |
|
@codex review
|
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review
|
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
| Enabled bool `json:"enabled"` | ||
| MaxUsesPerRun int `json:"max_uses_per_run"` | ||
| MaxOutputTokens int64 `json:"max_output_tokens"` | ||
| Overrides []AgentsAdvisorOverrideTelemetry `json:"overrides"` |
There was a problem hiding this comment.
👀 the telemetry snapshot format is changing? Might need to handle this in the telemetry server.
There was a problem hiding this comment.
The advisor entry does change shape (single provider/model -> per-org overrides array). Deployment.AgentsExperiments is documented as opaque per-experiment JSON precisely so the reported set can rotate as a code-only change, and the field is omitted entirely by older coderd versions, so consumers already have to tolerate variance. That said, I cannot see the telemetry server from here to confirm nothing parses the advisor entry structurally, so leaving this thread open for you to confirm or route.
Xum acted on Mike's behalf.
There was a problem hiding this comment.
Quick check: it seems to be stored as bigquery.NullJSON so won't break telemetry-server but will need to be handled by consumers. It would be worth adding or updating fixtures in telemetry conversion tests.
There was a problem hiding this comment.
Confirmed on the telemetry-server side: convert.go passes AgentsExperiments through opaquely (json.RawMessage -> bigquery.NullJSON, no structural parsing), so nothing breaks. convert_test.go's Deployment case carries an advisor fixture with the old shape ({"advisor":{"enabled":true,"provider":"openai"}}); it still passes because the payload is opaque, but it should be refreshed to the new overrides-array shape so the fixtures document reality. That fixture lives in coder-telemetry-server, so it needs a small separate PR there; queued on our side.
Xum acted on Mike's behalf.
There was a problem hiding this comment.
Fixture PR opened: coder/coder-telemetry-server#48 (updates the Deployment conversion test's advisor fixture to the new overrides-array shape; conversion is confirmed opaque so no server change needed).
Xum acted on Mike's behalf.
0a8b960 to
6fbb431
Compare
6fbb431 to
91d8efc
Compare
91d8efc to
d75e734
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d75e734178
ℹ️ 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".
| // fails, the rows must stay rendered with the error inline so a stale | ||
| // override can still be cleared without the catalog. | ||
| const { loadError, refetchError } = splitModelQueryErrors(overridesQuery); | ||
| const inlineError = refetchError ?? modelsQuery.error; |
There was a problem hiding this comment.
Separate override refetch errors from model errors
When cached overrides exist and a background override refetch fails while the model query remains healthy, refetchError is folded into inlineError and then passed to every row as modelsError; each row consequently reports "Failed to load models" even though only the overrides request failed. Keep the override refetch error separate from modelsQuery.error so this refetch state is not misdiagnosed across all rows.
AGENTS.md reference: site/AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Render the MCP load error only once
When the initial MCP server request fails and has no cached data, both this unconditional block and the earlier data === undefined block render the same ErrorAlert, so users see a duplicate error banner for a single failure. Remove one rendering path or make the conditions mutually exclusive.
Useful? React with 👍 / 👎.
Fetch advisor overrides for telemetry in one bulk query instead of one query per organization, keep the Clear action usable when an organization has no enabled models, remount override settings forms on organization switch so mutation state never leaks across organizations, and resolve the sidebar personal-overrides feature flag through an accessible organization for users outside the default organization.
Parse the stored advisor config JSON inside plpgsql exception handlers in both migration directions so a malformed persisted value cannot abort an upgrade or rollback, and keep chat creation blocked when the personal override fetch fails so a catalog fallback is never submitted as an explicit model that bypasses the saved root override.
Seed legacy mode-only personal overrides into every organization the user belongs to (they were deployment-wide) and model-backed overrides into the organization that owns the model; prefer the default organization when rolling back. Look up the referenced model under a system context in the organization override PUT so custom roles with update-but-not-read access can use the endpoint they are authorized to call. Cover the new Defaults & overrides tab with a Storybook interaction.
…ng them The data-carry migration parsed three serialized legacy formats inside SQL (colon-joined site configs, advisor config JSON, personal override strings) with exception-guarded jsonb casts and per-organization seeding rules. Deleting the legacy keys outright removes all of that: admins and users re-select models in the new organization-scoped settings. Stale advisor model fields in agents_advisor_config are harmless because reads ignore unknown JSON keys and the next settings write rewrites the blob. The ParseChatPersonalModelOverride helper existed only to parse the legacy serialized values and is now dead code.
d75e734 to
117310c
Compare

Moves chat model override settings from deployment scope to organization scope, following the org-scoping of chat model configs in #28440.
Depends on #28440 (based on
ethan/chat-models-availability-consolidation).Remote dogfood UAT passed on this change, including multi-organization scenarios on a licensed deployment with real models.
Problem
Chat model configs are now owned by organizations, but the override settings that reference them stayed deployment-wide: admin subagent/title/compaction overrides in
site_configs, personal overrides inuser_configs, and the advisor model embedded in the advisor runtime JSON. A single deployment-level override can only point at one organization's model config, so overrides effectively worked for the default organization only, and title generation had to soften its hard-failure contract to tolerate unusable overrides.Fix
Admin overrides (general, explore, title generation, compaction, advisor) and personal overrides (root, general, explore) become organization-scoped rows in two new typed tables,
chat_organization_model_overridesandchat_user_model_overrides. Composite foreign keys on(organization_id, model_config_id)make cross-organization model references unrepresentable. The migration deletes the legacy serializedsite_configs/user_configsoverride keys instead of migrating them; admins and users re-select models in the new organization-scoped settings.New endpoints live under
/api/experimental/organizations/{organization}/chats/model-overrides(admin defaults) and/api/experimental/organizations/{organization}/members/{user}/chats/model-overrides(personal overrides); the legacy deployment-level routes are removed. chatd resolves overrides via the chat's organization, restoring the hard-failure contract for configured-but-unusable title generation overrides. The deployment-levelAllowUsersswitch and advisor runtime limits stay deployment-scoped.The Coder Agents settings UI gains a per-organization "Defaults & overrides" page under AI Settings > Models, and the personal overrides page gains an organization selector for users in multiple organizations. Advisor telemetry now reports per-organization override rows.
BREAKING CHANGE: Existing deployment-level overrides are dropped, not migrated. Every organization starts with no overrides after upgrade, and model selections must be re-applied in the new settings. The legacy deployment-level override endpoints are removed.
Closes https://linear.app/coder/issue/CODAGT-872
Note
Xum (AI agent) authored this PR on behalf of @ibetitsmike.