🤖 fix: fall back to an allowed model when admin policy excludes the VS Code webview's selection - #4811
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c080dcf990
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0a2f6f3b2
ℹ️ 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".
e0a2f6f to
1cc93ee
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1cc93ee31f
ℹ️ 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".
1cc93ee to
cab8bac
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cab8bac8ed
ℹ️ 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".
Summary
When the enforced admin policy excludes the VS Code webview's selected model, the composer now uses the first allowed model from its list for display and send, and a status line says which model the policy rejected and which one is used. The stored choice is never overwritten. If no listed model is allowed, the composer keeps the stored model and the status line asks the user to choose an allowed one. Before, every send failed with
policy_deniedwith no hint until the user picked another model.Background
The selected model can be one the policy disallows: persisted earlier, seeded from the workspace (#4778), or revoked by a policy refresh. Since #4807 the dropdown hides disallowed models, but the composer still showed and sent the stored one. Found in review of #4807. The desktop composer has no such reconciliation to reuse (it only filters the model lists), so this is webview-local.
Implementation
vscode/src/webview/ChatComposer.tsx(webview only):isAllowedByPolicyOnActiveRoutefrom the shareduseModelsFromSettingshook, the same predicate the model list uses, because the backend enforces policy after routing. The check uses the gateway-preserving identity (normalizeSelectedModel), so an explicitly pinned gateway model is checked on that gateway.modelslist that passes the same check. That model drives the selector, the thinking control, model cycling, and the send'smodeloption. The send overridesmodelonly in this case, so the normal send keeps the stored model string as before.localStoragechange and noupdateAgentAISettingscall, because webview persistence is off (🤖 fix: VS Code webview first send overwrites workspace AI settings with webview defaults #4755/🤖 feat: persist explicit AI-setting changes from the VS Code webview #4781). If the policy later allows the stored model again, it comes back by itself.role="status"text line above the model selector, using thetext-content-secondarytoken.Review history: round 1 asked for the route-aware check and for
/vimto keep working in a "Send disabled" state; round 2 found the check dropped explicit gateway IDs and the disabled button still blocked/vimby mouse. Both rounds clustered on the blocking state, so it was removed (scope reduction) instead of adding more special cases.Validation
App.test.tsx(TestBridge now has ananswer(path, value)helper that plays the host'sorpcResponse), withpolicy.getanswered with an enforced policy and the stored modelanthropic:claude-opus-5-5:openai:gpt-5.6-terra: the status line names the rejected model, the send carriesmodel: "openai:gpt-5.6-terra", the stored model is unchanged, and noupdateAgentAISettingsis posted. Onmain: no status line, and the send carriesanthropic:claude-opus-5-5.main: no status line.policy.getanswered with an enforced policy allowingopenai:gpt-5.6-terraandgpt-5.6-sol, stored model Opus 5.5):workspace.sendMessagewithmodel: "openai:gpt-5.6-terra"andskipAiSettingsPersistence: true; noupdateAgentAISettingspost;localStorage["model:ws-demo"]stayed"anthropic:claude-opus-5-5". 0 console errors.Fallback, 800px:
Fallback, 390px:
No allowed listed model, 800px:
Risks
Low, webview only. The webview does not load routing preferences or the providers config until #4766, so today the active route is the default one and "first allowed model" means the first allowed built-in model.
Fixes #4808
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$4.48