Skip to content

fix(ui): saving a provider key says when the model policy hides its models - #189917

Merged
obviyus merged 2 commits into
mainfrom
fix/provider-dialog-policy-warning
Nov 1, 2026
Merged

obviyus merged 2 commits into
mainfrom
fix/provider-dialog-policy-warning

Conversation

@obviyus

@obviyus obviyus commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: saving an API key in Settings → Models → Connect provider succeeds silently when agents.defaults.modelPolicy.allow hides every model of that provider, so the provider never appears in the model picker and nothing says why.

User Impact

User impact: after the key saves, the dialog stays open and says that the model policy hides the provider's models, with the provider/* entry to add: to agents.entries.<agent>.modelPolicy.allow when the selected agent sets its own policy (it replaces the default), otherwise to agents.defaults.modelPolicy.allow. Saves for providers the policy allows close the dialog as before.

Why This Change Was Made

The Gateway already decides policy visibility: models.list with view: "all" marks each model manualSelectionAllowed from the agent's model policy. After a successful key save, the provider page reads that list for the saved provider and warns only when the Gateway marks every model hidden. The UI does not match allowlist patterns itself. models.list does not say which config level owns the policy, so the warning names both instead of adding a protocol field. The warning uses the existing post-save warning path, which already keeps the dialog open for discovery failures.

Evidence

Mocked-Gateway Control UI run of the real dialog flow (policy allow: ["openai/*"], save a Particle key; models.list view=all provider=particle returns manualSelectionAllowed: false):

Before (main): the dialog closes with no explanation.

Before: dialog closes silently

After: the dialog stays open with the policy warning.

After: dialog names the model policy

  • pnpm test ui/src/pages/model-providers/model-providers-page.test.ts --maxWorkers=1: 35 passed, 1.8 s wall. The new cases check the warning when every model is hidden and no warning when one model is allowed; both fail with the fix reverted.
  • Gateway side is existing coverage: src/gateway/server-methods/models.prepared.test.ts publishes modelPolicy.allow: ["test/first"] and checks view: "all" marks other models manualSelectionAllowed: false.
  • pnpm check:changed (dead-code skipped) and pnpm ui:i18n:verify pass.
  • No overlap with Pash/Sarah changes.

Merge danger: two-way door. UI-only; a revert restores the silent close. Blast radius: the Models settings key dialogs (add and edit) gain one extra models.list read per successful save; a failure of that read shows as a warning, not a failed save.

🤖 Generated with Claude Code

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@obviyus
obviyus marked this pull request as ready for review November 1, 2026 01:12
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

After saving a provider key, Models settings warns when model policy hides every model from that provider.

Example: Save a Particle key while the selected agent's model policy allows only openai/*.

  • Before: The dialog closes without explaining why Particle models remain absent.
  • After: The dialog stays open, confirms the save, and names the default and agent-level policy settings.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused patch with the prior finding resolved and green exact-head checks; supplied evidence establishes presentation behavior with limited integration confidence.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; inspected before/after browser screenshots establish the changed dialog presentation against a mocked Gateway, without proving real policy integration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Saving a provider key gives no explanation when an explicit model policy prevents its models from appearing.
Reason: The collaborator-authored direction repairs a concrete silent outcome while preserving policy restrictions, credential ownership, and existing defaults.

Merge readiness

✅ Ready for maintainer review

This PR provides a focused repair still missing from main; the latest head resolves the previous policy-scope finding, and no new blocking defect was found.

Priority: P2
Reviewed head: 58b3200b8a5ecd37292c82e75ff27bf749b234bc

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A real-Gateway save under default and per-agent restrictions is not demonstrated; the supplied browser scenario mocks catalog responses, while the PR reports base-failing and head-passing page tests.
Agent review details

How this fits together

Models settings saves credentials through the existing mutation owner, refreshes provider data, then consumes Gateway-owned model visibility flags to display feedback.

flowchart TD
  A[Provider key dialog] --> B[Credential mutation owner]
  B --> C[Gateway credential save]
  C --> D[Provider refresh]
  D --> E[Provider scoped model catalog]
  E --> F[Policy warning or dialog close]
Loading

Technical review

Best possible solution:

Keep the Gateway as the visibility owner and present its provider-specific policy result through the existing saved-key warning path.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the silent-close path under a restrictive model policy, and inspected browser screenshots demonstrate the presentation difference with mocked catalog responses; this read-only review ran no reproduction.

Is this the best way to solve the issue?

The patch is appropriately small: it consumes existing Gateway visibility flags, preserves discovery-warning precedence and mutation settlement, and adds no competing policy implementation or persisted state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 418bb925ca47.

Provenance checked

  • Provider-specific post-save warnings keeps the original intent (10a6e4f: Prevent discovery failures from another provider from making the saved provider appear broken.)
  • Credential mutation presentation keeps the original intent (a90fc1e: Use Solid actions for presentation while retaining plain-owner admission, settlement, and reconciliation.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a90fc1e adds ui/src/pages/model-providers/config-actions.ts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a90fc1e8a87d; files: ui/src/pages/model-providers/config-actions.ts)

PR surface

Source +23, Tests +42. Total +65 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 24 1 +23
Tests 1 42 0 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 66 1 +65

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: An explicitly restricted provider saves successfully but remains absent without explanation; existing model access and credential persistence continue working.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Optional: demonstrate a saved provider key against a real Gateway with default and per-agent policy restrictions.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-01T01:27:59.127Z sha 6bb3b18 :: needs changes before merge. :: [P2] Name the effective policy instead of always directing edits to defaults

Reviewed October 31, 2026, 10:07 PM ET / November 1, 2026, 02:07 UTC (Revision 2).

@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 1, 2026
@obviyus
obviyus merged commit afe8191 into main Nov 1, 2026
99 checks passed
@obviyus
obviyus deleted the fix/provider-dialog-policy-warning branch November 1, 2026 02:09
@obviyus

obviyus commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in afe8191. Bug: saving a provider key closed the dialog silently when the model policy hid every model of that provider. Fix: after the save, the page reads the Gateway's per-model policy marks for that provider and keeps the dialog open with a warning that names both policy levels. Proof: focused page tests (35 passed, both new cases fail with the fix reverted), mocked-Gateway before/after screenshots, green CI and ClawSweeper ready on 58b3200.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
…odels (openclaw#189917)

## What Problem This Solves

Fixes: saving an API key in **Settings → Models → Connect provider** succeeds silently when `agents.defaults.modelPolicy.allow` hides every model of that provider, so the provider never appears in the model picker and nothing says why.

## User Impact

User impact: after the key saves, the dialog stays open and says that the model policy hides the provider's models, with the `provider/*` entry to add: to `agents.entries.<agent>.modelPolicy.allow` when the selected agent sets its own policy (it replaces the default), otherwise to `agents.defaults.modelPolicy.allow`. Saves for providers the policy allows close the dialog as before.

## Why This Change Was Made

The Gateway already decides policy visibility: `models.list` with `view: "all"` marks each model `manualSelectionAllowed` from the agent's model policy. After a successful key save, the provider page reads that list for the saved provider and warns only when the Gateway marks every model hidden. The UI does not match allowlist patterns itself. `models.list` does not say which config level owns the policy, so the warning names both instead of adding a protocol field. The warning uses the existing post-save warning path, which already keeps the dialog open for discovery failures.

## Evidence

Mocked-Gateway Control UI run of the real dialog flow (policy `allow: ["openai/*"]`, save a Particle key; `models.list view=all provider=particle` returns `manualSelectionAllowed: false`):

Before (main): the dialog closes with no explanation.

![Before: dialog closes silently](https://github.com/user-attachments/assets/88c4d47c-50c3-4980-ac0e-b26fa498773f)

After: the dialog stays open with the policy warning.

![After: dialog names the model policy](https://github.com/user-attachments/assets/ed03db88-d142-479f-b8f9-5ad896604025)

- `pnpm test ui/src/pages/model-providers/model-providers-page.test.ts --maxWorkers=1`: 35 passed, 1.8 s wall. The new cases check the warning when every model is hidden and no warning when one model is allowed; both fail with the fix reverted.
- Gateway side is existing coverage: `src/gateway/server-methods/models.prepared.test.ts` publishes `modelPolicy.allow: ["test/first"]` and checks `view: "all"` marks other models `manualSelectionAllowed: false`.
- `pnpm check:changed` (dead-code skipped) and `pnpm ui:i18n:verify` pass.
- No overlap with Pash/Sarah changes.

Merge danger: two-way door. UI-only; a revert restores the silent close. Blast radius: the Models settings key dialogs (add and edit) gain one extra `models.list` read per successful save; a failure of that read shows as a warning, not a failed save.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 1, 2026
…#190019)

## What Problem This Solves

Adding a provider did not make it usable when a model allowlist (`modelPolicy.allow`) existed. On the Team server, saving a Particle API key in **Settings → Models → Connect provider** succeeded, but no Particle model appeared in the model picker: the allowlist hid them all. Sign-in flows (CLI, chat `/login`, Telegram, Control UI wizard) asked **Show all &lt;Provider&gt; models / Keep current restrictions** with Keep as the default. The API-key save path skipped even that, and #189917 only added a text warning that told the user to edit config by hand.

## Fix

Saving credentials for a provider is now the request to use its models. When the allowlist that governs the agent hides **every** model of that provider, the save adds `<provider>/*` to that allowlist, through the existing model-policy owner (`src/commands/models/auth-model-policy.ts`):

- per-agent `agents.entries.<id>.modelPolicy.allow` when the agent sets its own policy, otherwise `agents.defaults.modelPolicy.allow`;
- an unmigrated legacy `agents.defaults.models` allowlist gets the wildcard key, so none of its models is dropped.

Nothing changes when there is no allowlist, or when the allowlist already names some of the provider's models (an exact ref such as `openai/gpt-x`, or a narrower wildcard such as `clawrouter/anthropic/*`). The policy owner decides that: the check reads providers from `createModelVisibilityPolicy(...).allowedKeys`, which resolves exact refs, aliases and bare legacy refs (inferring their provider from configured provider rows) the same way the picker does. A deliberate exact list is never widened.

Paths:

- API key / token save (`models.authSetApiKey`, `openclaw models auth paste-api-key`, `paste-token`): the wildcard is added in the same config write as the credential's auth profile.
- Sign-in (`openclaw models auth login`, Control UI wizard, chat `/login`, Telegram `/login`): after the credential is saved, one write adds the wildcard. The login result carries `modelAccess: { message, applied }`; chat and Telegram append "Added `<provider>/*` to allowed models." to the completion message; the Control UI wizard reports an unconfirmed apply as before.

Removed: the post-save select prompt, the deferred `onModelAccessRequested` request, `offerProviderLoginModelAccess` / `answerProviderLoginModelAccess`, the `/login access` and `/login choice` model-access commands, `createLoginChoicePrompt`, `ProviderModelPolicyChangedError`, and the #189917 Control UI warning. `provider-auth-login-flow-runtime` is a private-local SDK subpath (docs/plugins/sdk-subpaths.md), so its only consumers are bundled (core chat `/login`, Telegram), migrated here.

Authority: every `models.authSetApiKey` save now checks live requester authority (`readGatewayRequestMutationAuthority`, the guard `config.patch` uses) before its credential and config writes. Before, browser saves without `expectedOwnerId` passed no guard; the save now also widens the allowlist, so a requester whose connection or scopes end mid-save cannot commit it. Owner-bound CLI saves keep their owner check and add the same requester check.

Plugin setup defaults still cannot change restrictions (`withoutProviderModelPolicy` is unchanged); only the credential save does.

This reverses the ask-first default from #144468 by maintainer decision.

No undo button: the `models.authSetApiKey` result has no field for the change, and adding one is a protocol change; the change is a single visible `provider/*` allowlist entry.

## User Impact

Add a provider key or sign in → its models show in the model picker, even under an existing allowlist that did not mention the provider. Operators who listed specific models of that provider keep exactly their list.

## Evidence

Real Gateway, real config write (`src/gateway/server-methods/models-auth-api-key.integration.test.ts`): config `agents.defaults.modelPolicy.allow: ["other/*"]`, `models.authSetApiKey` for `fixture` → saved config `["other/*", "fixture/*"]`. Negative control: with the new line disabled, the test fails `expected [ 'other/*' ] to deeply equal [ 'other/*', 'fixture/*' ]`.

Policy owner (`src/commands/models/auth-model-policy.test.ts`, real config file):

- per-agent policy widened, defaults untouched;
- no allowlist / provider already allowed → config bytes unchanged;
- allowlist with exact `sample/one`, `sample/two` → unchanged; with `sample/family/*` → unchanged (both fail when the check is reverted to "literal `sample/*` missing");
- deferred legacy map keeps `existing-model` and gains `sample/*`;
- migrated model map is not treated as an allowlist;
- authority revoked during the writer's preflight → no write.

Sign-in end to end against a real plugin and config (`src/commands/models.auth.provider-resolution.test.ts`): `access`, `access-legacy`, `access-legacy-set-default` cases save the credential, add `authstore-proof/*` with no prompt, and log the notice.

Real key writer under revocation (`src/commands/models/auth-api-key.test.ts`, real auth store and config file): with an allowlist present, authority revoked inside the config write leaves the config bytes unchanged (no auth binding, no `sample/*`); unrevoked, the same write saves the binding and `["other/*", "sample/*"]`.

Gateway-to-writer revocation chain (`src/commands/models/auth-api-key.test.ts`): the real `models.authSetApiKey` handler, its `readGatewayRequestMutationAuthority` guard and the real key/config writer, with the requester's authority ending inside the config write. The RPC fails with "Gateway requester authority changed"; the config file bytes are unchanged (no auth binding, allowlist still `["other/*"]`). The key itself committed earlier, while the requester was still authorized, and stays saved. Negative control: with the handler guard replaced by a no-op, the test fails. Run output (synthetic keys only):

```
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=false) 1511ms
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=true) 914ms
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=false) 1392ms
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=true) 1067ms
✓ |commands| src/commands/models/auth-api-key.test.ts > models.authSetApiKey writes no binding or allowlist once the requester is revoked 977ms
Tests  5 passed | 42 skipped (47)
```

Upgrade compatibility: no stored schema or config shape changes. Existing configs load as before and keep working: explicit `modelPolicy.allow` (defaults and per-agent), unmigrated legacy `agents.defaults.models` allowlists (wildcard added as a map key, every existing model kept), migrated maps with the `modelPolicyAllowlist` marker (not treated as an allowlist), and configs without an allowlist (never written). Each case runs against a real config file in `auth-model-policy.test.ts` and `models.auth.provider-resolution.test.ts`. The removed chat model-access questions were in-memory only, so no stored state refers to them.

Existing data, real CLI entry point: a temporary state directory seeded with the Team server's pre-change allowlist shape (exact `openai/...` refs plus `clawrouter/anthropic/...` refs, and a legacy `agents.defaults.models` map), then `openclaw models auth paste-api-key` from this branch for three providers (synthetic keys, the first run's output trimmed to the resulting list):

```
Team pre-change allowlist (exact openai refs + clawrouter/anthropic refs), no Gateway running
== openclaw models auth paste-api-key --provider openai
allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5']
== openclaw models auth paste-api-key --provider particle
Auth profile: particle:manual (particle/api_key)
Added particle/* to allowed models.
allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*']
== openclaw models auth paste-api-key --provider clawrouter
Auth profile: clawrouter:manual (clawrouter/api_key)
allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*']
```

OpenAI and ClawRouter keep the operator's exact lists; only Particle, which the list did not mention, gains `particle/*`.

Bare legacy ref (`auth-model-policy.test.ts`): legacy map `{ tiny: {} }` with a configured `sample` provider that has `tiny` → saving a `sample` credential leaves config unchanged (fails against the earlier `DEFAULT_PROVIDER` parse).

Requester authority (`src/gateway/server-methods/models-auth-status.set-api-key.test-support.ts`): authority ends during the save → the RPC fails with "Gateway requester authority changed" and the writer's `assertCurrent` throws before commit. Negative control: with the handler's default guard replaced by a no-op, the test fails.

Surface tests: chat `/login` and Telegram completion messages include the notice; Control UI wizard reports unconfirmed apply; mocked-Gateway Control UI E2E (`model-provider-login.e2e.test.ts`) passes.

Control UI, mocked Gateway, policy `allow: ["openai/*"]`, save a Particle key:

Before (main, #189917): the dialog stays open with a config-editing instruction.

![Before: dialog tells the user to edit modelPolicy.allow](https://github.com/user-attachments/assets/793cafbe-5e2d-4be0-b111-a95265d6db8a)

After: the Gateway widens the policy during the save; the dialog closes like any successful save.

![After: dialog closes after save](https://github.com/user-attachments/assets/480dced1-3ec3-4fed-b092-c2b6842ba31b)

Commands:

- `pnpm test src/commands/models/auth-model-policy.test.ts --maxWorkers=1`: 7 passed.
- `pnpm test src/gateway/server-methods/models-auth-api-key.integration.test.ts --maxWorkers=1`: 1 passed (~12.5 s, real Gateway, existing test extended; no new boot).
- `pnpm test src/commands/models/auth.test.ts src/commands/models.auth.provider-resolution.test.ts --maxWorkers=1`: 80 passed.
- Chat/Gateway/Telegram/UI suites: passed.
- `pnpm tsgo:core`, `pnpm tsgo:extensions`, `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 pnpm check:changed`.

No overlap with Pash/Sarah changes.

Merge danger: one-way for configs: a credential save can now write `<provider>/*` into a model allowlist. A revert stops new writes but does not remove entries already added. Blast radius: operators who rely on an allowlist that does not mention a provider to keep that provider hidden after someone adds its credentials. Only admins can save credentials.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…openclaw#190019)

## What Problem This Solves

Adding a provider did not make it usable when a model allowlist (`modelPolicy.allow`) existed. On the Team server, saving a Particle API key in **Settings → Models → Connect provider** succeeded, but no Particle model appeared in the model picker: the allowlist hid them all. Sign-in flows (CLI, chat `/login`, Telegram, Control UI wizard) asked **Show all &lt;Provider&gt; models / Keep current restrictions** with Keep as the default. The API-key save path skipped even that, and openclaw#189917 only added a text warning that told the user to edit config by hand.

## Fix

Saving credentials for a provider is now the request to use its models. When the allowlist that governs the agent hides **every** model of that provider, the save adds `<provider>/*` to that allowlist, through the existing model-policy owner (`src/commands/models/auth-model-policy.ts`):

- per-agent `agents.entries.<id>.modelPolicy.allow` when the agent sets its own policy, otherwise `agents.defaults.modelPolicy.allow`;
- an unmigrated legacy `agents.defaults.models` allowlist gets the wildcard key, so none of its models is dropped.

Nothing changes when there is no allowlist, or when the allowlist already names some of the provider's models (an exact ref such as `openai/gpt-x`, or a narrower wildcard such as `clawrouter/anthropic/*`). The policy owner decides that: the check reads providers from `createModelVisibilityPolicy(...).allowedKeys`, which resolves exact refs, aliases and bare legacy refs (inferring their provider from configured provider rows) the same way the picker does. A deliberate exact list is never widened.

Paths:

- API key / token save (`models.authSetApiKey`, `openclaw models auth paste-api-key`, `paste-token`): the wildcard is added in the same config write as the credential's auth profile.
- Sign-in (`openclaw models auth login`, Control UI wizard, chat `/login`, Telegram `/login`): after the credential is saved, one write adds the wildcard. The login result carries `modelAccess: { message, applied }`; chat and Telegram append "Added `<provider>/*` to allowed models." to the completion message; the Control UI wizard reports an unconfirmed apply as before.

Removed: the post-save select prompt, the deferred `onModelAccessRequested` request, `offerProviderLoginModelAccess` / `answerProviderLoginModelAccess`, the `/login access` and `/login choice` model-access commands, `createLoginChoicePrompt`, `ProviderModelPolicyChangedError`, and the openclaw#189917 Control UI warning. `provider-auth-login-flow-runtime` is a private-local SDK subpath (docs/plugins/sdk-subpaths.md), so its only consumers are bundled (core chat `/login`, Telegram), migrated here.

Authority: every `models.authSetApiKey` save now checks live requester authority (`readGatewayRequestMutationAuthority`, the guard `config.patch` uses) before its credential and config writes. Before, browser saves without `expectedOwnerId` passed no guard; the save now also widens the allowlist, so a requester whose connection or scopes end mid-save cannot commit it. Owner-bound CLI saves keep their owner check and add the same requester check.

Plugin setup defaults still cannot change restrictions (`withoutProviderModelPolicy` is unchanged); only the credential save does.

This reverses the ask-first default from openclaw#144468 by maintainer decision.

No undo button: the `models.authSetApiKey` result has no field for the change, and adding one is a protocol change; the change is a single visible `provider/*` allowlist entry.

## User Impact

Add a provider key or sign in → its models show in the model picker, even under an existing allowlist that did not mention the provider. Operators who listed specific models of that provider keep exactly their list.

## Evidence

Real Gateway, real config write (`src/gateway/server-methods/models-auth-api-key.integration.test.ts`): config `agents.defaults.modelPolicy.allow: ["other/*"]`, `models.authSetApiKey` for `fixture` → saved config `["other/*", "fixture/*"]`. Negative control: with the new line disabled, the test fails `expected [ 'other/*' ] to deeply equal [ 'other/*', 'fixture/*' ]`.

Policy owner (`src/commands/models/auth-model-policy.test.ts`, real config file):

- per-agent policy widened, defaults untouched;
- no allowlist / provider already allowed → config bytes unchanged;
- allowlist with exact `sample/one`, `sample/two` → unchanged; with `sample/family/*` → unchanged (both fail when the check is reverted to "literal `sample/*` missing");
- deferred legacy map keeps `existing-model` and gains `sample/*`;
- migrated model map is not treated as an allowlist;
- authority revoked during the writer's preflight → no write.

Sign-in end to end against a real plugin and config (`src/commands/models.auth.provider-resolution.test.ts`): `access`, `access-legacy`, `access-legacy-set-default` cases save the credential, add `authstore-proof/*` with no prompt, and log the notice.

Real key writer under revocation (`src/commands/models/auth-api-key.test.ts`, real auth store and config file): with an allowlist present, authority revoked inside the config write leaves the config bytes unchanged (no auth binding, no `sample/*`); unrevoked, the same write saves the binding and `["other/*", "sample/*"]`.

Gateway-to-writer revocation chain (`src/commands/models/auth-api-key.test.ts`): the real `models.authSetApiKey` handler, its `readGatewayRequestMutationAuthority` guard and the real key/config writer, with the requester's authority ending inside the config write. The RPC fails with "Gateway requester authority changed"; the config file bytes are unchanged (no auth binding, allowlist still `["other/*"]`). The key itself committed earlier, while the requester was still authorized, and stays saved. Negative control: with the handler guard replaced by a no-op, the test fails. Run output (synthetic keys only):

```
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=false) 1511ms
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after credential commit (revoked=true) 914ms
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=false) 1392ms
✓ |commands| src/commands/models/auth-api-key.test.ts > checks requester authority after config transform (revoked=true) 1067ms
✓ |commands| src/commands/models/auth-api-key.test.ts > models.authSetApiKey writes no binding or allowlist once the requester is revoked 977ms
Tests  5 passed | 42 skipped (47)
```

Upgrade compatibility: no stored schema or config shape changes. Existing configs load as before and keep working: explicit `modelPolicy.allow` (defaults and per-agent), unmigrated legacy `agents.defaults.models` allowlists (wildcard added as a map key, every existing model kept), migrated maps with the `modelPolicyAllowlist` marker (not treated as an allowlist), and configs without an allowlist (never written). Each case runs against a real config file in `auth-model-policy.test.ts` and `models.auth.provider-resolution.test.ts`. The removed chat model-access questions were in-memory only, so no stored state refers to them.

Existing data, real CLI entry point: a temporary state directory seeded with the Team server's pre-change allowlist shape (exact `openai/...` refs plus `clawrouter/anthropic/...` refs, and a legacy `agents.defaults.models` map), then `openclaw models auth paste-api-key` from this branch for three providers (synthetic keys, the first run's output trimmed to the resulting list):

```
Team pre-change allowlist (exact openai refs + clawrouter/anthropic refs), no Gateway running
== openclaw models auth paste-api-key --provider openai
allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5']
== openclaw models auth paste-api-key --provider particle
Auth profile: particle:manual (particle/api_key)
Added particle/* to allowed models.
allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*']
== openclaw models auth paste-api-key --provider clawrouter
Auth profile: clawrouter:manual (clawrouter/api_key)
allow = ['openai/gpt-6-luna', 'openai/gpt-6-astra', 'openai/gpt-daybreak-blue-latest', 'openai/gpt-daybreak-red-latest', 'openai/gpt-6.1-sol', 'clawrouter/anthropic/claude-fable-5-1', 'clawrouter/anthropic/claude-opus-5-5', 'particle/*']
```

OpenAI and ClawRouter keep the operator's exact lists; only Particle, which the list did not mention, gains `particle/*`.

Bare legacy ref (`auth-model-policy.test.ts`): legacy map `{ tiny: {} }` with a configured `sample` provider that has `tiny` → saving a `sample` credential leaves config unchanged (fails against the earlier `DEFAULT_PROVIDER` parse).

Requester authority (`src/gateway/server-methods/models-auth-status.set-api-key.test-support.ts`): authority ends during the save → the RPC fails with "Gateway requester authority changed" and the writer's `assertCurrent` throws before commit. Negative control: with the handler's default guard replaced by a no-op, the test fails.

Surface tests: chat `/login` and Telegram completion messages include the notice; Control UI wizard reports unconfirmed apply; mocked-Gateway Control UI E2E (`model-provider-login.e2e.test.ts`) passes.

Control UI, mocked Gateway, policy `allow: ["openai/*"]`, save a Particle key:

Before (main, openclaw#189917): the dialog stays open with a config-editing instruction.

![Before: dialog tells the user to edit modelPolicy.allow](https://github.com/user-attachments/assets/793cafbe-5e2d-4be0-b111-a95265d6db8a)

After: the Gateway widens the policy during the save; the dialog closes like any successful save.

![After: dialog closes after save](https://github.com/user-attachments/assets/480dced1-3ec3-4fed-b092-c2b6842ba31b)

Commands:

- `pnpm test src/commands/models/auth-model-policy.test.ts --maxWorkers=1`: 7 passed.
- `pnpm test src/gateway/server-methods/models-auth-api-key.integration.test.ts --maxWorkers=1`: 1 passed (~12.5 s, real Gateway, existing test extended; no new boot).
- `pnpm test src/commands/models/auth.test.ts src/commands/models.auth.provider-resolution.test.ts --maxWorkers=1`: 80 passed.
- Chat/Gateway/Telegram/UI suites: passed.
- `pnpm tsgo:core`, `pnpm tsgo:extensions`, `OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 pnpm check:changed`.

No overlap with Pash/Sarah changes.

Merge danger: one-way for configs: a credential save can now write `<provider>/*` into a model allowlist. A revert stops new writes but does not remove entries already added. Blast radius: operators who rely on an allowlist that does not mention a provider to keep that provider hidden after someone adds its credentials. Only admins can save credentials.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant