feat!: scope chat model override settings to organizations by ibetitsmike · Pull Request #28442 · coder/coder · GitHub
Skip to content

feat!: scope chat model override settings to organizations - #28442

Merged
ethanndickson merged 16 commits into
ethan/chat-models-availability-consolidationfrom
mike/codagt-872-org-scope-model-overrides
Aug 24, 2026
Merged

feat!: scope chat model override settings to organizations#28442
ethanndickson merged 16 commits into
ethan/chat-models-availability-consolidationfrom
mike/codagt-872-org-scope-model-overrides

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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 in user_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_overrides and chat_user_model_overrides. Composite foreign keys on (organization_id, model_config_id) make cross-organization model references unrepresentable. The migration deletes the legacy serialized site_configs/user_configs override 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-level AllowUsers switch 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.

@linear-code

linear-code Bot commented Aug 21, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Docs preview

Check 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.

@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: 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".

Comment thread site/src/pages/AISettingsPage/ModelsPage/DefaultsPage/DefaultsPageView.tsx Outdated
Comment thread coderd/telemetry/telemetry.go Outdated
Comment thread site/src/pages/AgentsPage/AgentsPageLayout.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: 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".

Comment thread coderd/database/migrations/000583_chat_model_override_org_scope.up.sql Outdated
Comment thread site/src/pages/AgentsPage/components/AgentCreateForm.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: 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".

Comment thread coderd/x/chatd/compaction_override.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: 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".

Comment thread coderd/database/migrations/000583_chat_model_override_org_scope.up.sql Outdated
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: 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".

Comment thread site/src/pages/AgentsPage/AgentSettingsUserAgentsPageView.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: 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".

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. Another round soon, please!

Reviewed commit: 4b8e4c84d1

ℹ️ 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 marked this pull request as ready for review August 22, 2026 05:31
@ibetitsmike
ibetitsmike requested review from ethanndickson and removed request for DanielleMaywood August 22, 2026 05:31
@coderagents

coderagents Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

This PR moves chat model override settings from deployment scope to organization scope. The two affected published docs have been updated to match.

Updates Needed

  • docs/ai-coder/agents/models.md (## Model overrides section) - Addressed. Overrides are now described as organization-scoped ("Admin overrides (per organization)"), the UI location is corrected to the Defaults & overrides tab under AI Settings > Models, the personal-override organization selector is documented, the Compaction and Advisor contexts were added, the resolution order and title-generation hard-fail behavior were updated, and the closing note now points to the new org-scoped API paths (/api/experimental/organizations/{organization}/chats/model-overrides and .../members/{user}/chats/model-overrides). The migration [!IMPORTANT] note accurately reflects that legacy overrides are dropped rather than migrated.
  • docs/ai-coder/agents/platform-controls/advisor.md (## Configuration) - Addressed. Runtime limits (max uses per turn, max output tokens) are now scoped as deployment-wide on /api/experimental/chats/config/advisor, and the advisor model / reasoning effort are documented as organization-scoped model overrides configured on the Defaults & overrides tab, with the API section pointing to PUT /api/experimental/organizations/{organization}/chats/model-overrides/advisor.

All previously flagged documentation is now accurate.


Automated review via Coder Agents

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum acted on Mike's behalf: migration simplified to drop legacy overrides instead of migrating them.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 6ad6b1ebc2

ℹ️ 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

Xum acted on Mike's behalf: added a docs caveat that legacy model overrides are dropped on upgrade.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 262b443231

ℹ️ 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".

Enabled bool `json:"enabled"`
MaxUsesPerRun int `json:"max_uses_per_run"`
MaxOutputTokens int64 `json:"max_output_tokens"`
Overrides []AgentsAdvisorOverrideTelemetry `json:"overrides"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👀 the telemetry snapshot format is changing? Might need to handle this in the telemetry server.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread coderd/x/chatd/subagent.go Outdated
Comment thread docs/ai-coder/agents/models.md Outdated
@ethanndickson
ethanndickson force-pushed the mike/codagt-872-org-scope-model-overrides branch from 0a8b960 to 6fbb431 Compare August 24, 2026 09:07
@ethanndickson
ethanndickson force-pushed the mike/codagt-872-org-scope-model-overrides branch from 6fbb431 to 91d8efc Compare August 24, 2026 09:30
@ethanndickson
ethanndickson force-pushed the mike/codagt-872-org-scope-model-overrides branch from 91d8efc to d75e734 Compare August 24, 2026 09:44
@ethanndickson

Copy link
Copy Markdown
Member

@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: 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge 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 👍 / 👎.

Comment on lines +598 to +600

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge 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 👍 / 👎.

ibetitsmike and others added 16 commits August 24, 2026 10:04
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.
@ethanndickson
ethanndickson force-pushed the mike/codagt-872-org-scope-model-overrides branch from d75e734 to 117310c Compare August 24, 2026 10:07
@ethanndickson
ethanndickson merged commit 0ef331f into main Aug 24, 2026
31 of 52 checks passed
@ethanndickson
ethanndickson deleted the mike/codagt-872-org-scope-model-overrides branch August 24, 2026 10:20
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants