mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-07-09 17:08:29 +00:00
Require explicit model choice after OAuth connect
Stop auto-populating Main and Utility models when an OAuth account is already connected or newly connected. Add a connected-account gate state that routes users to model configuration instead of choosing provider defaults silently. Update OAuth notifications, chat gate copy, DOX contracts, and focused static regressions for the explicit model-selection flow.
This commit is contained in:
parent
04ecaac0cd
commit
b75b0f2c5c
7 changed files with 54 additions and 80 deletions
|
|
@ -28,8 +28,7 @@
|
|||
- OAuth settings pending-auth controls such as device codes, manual callback input, and provider setup fields must render inline under the relevant provider row, not as a detached section below all providers.
|
||||
- OAuth device-code polling must honor provider `interval`, `expires_at`, and `slow_down` updates; do not poll immediately or keep a stale fixed interval after a provider asks the client to slow down.
|
||||
- OAuth settings model slots must keep provider choice editable per slot, list only connected OAuth account providers, and persist the selected provider IDs into `chat_model.provider` and `utility_model.provider`.
|
||||
- The OAuth WebUI store owns connected-provider default selection helpers reused by settings and deferred chat setup gates.
|
||||
- OAuth settings must dispatch `model-configured` when a provider connection completes. If no chat model is configured, the settings flow may apply the connected provider defaults to Main and Utility before notifying deferred send gates.
|
||||
- OAuth settings must dispatch `model-setup-changed` when a provider connection completes, but model selection remains explicit and must not be filled automatically.
|
||||
- `helpers/providers/registry.py` is the source of truth for connectable OAuth providers.
|
||||
- OAuth provider config must not expose the dummy `oauth` API key in `conf/model_providers.yaml`; the dummy key is a runtime-only shim supplied by the `get_api_key` extension after the account provider reports connected.
|
||||
- Usage-plan metadata belongs only to connectable providers. Do not add metadata-only subscription families for providers this plugin cannot connect.
|
||||
|
|
|
|||
|
|
@ -287,15 +287,6 @@ export const store = createStore("oauthConfig", {
|
|||
return status.display_name || providerId;
|
||||
},
|
||||
|
||||
providerDefaultModel(providerId, slotKey = "chat_model") {
|
||||
const status = this.providerStatus(providerId);
|
||||
const defaults = Array.isArray(status.default_models)
|
||||
? status.default_models.map((model) => String(model || "").trim()).filter(Boolean)
|
||||
: [];
|
||||
if (slotKey === "utility_model" && defaults[1]) return defaults[1];
|
||||
return String(status.default_model || defaults[0] || "").trim();
|
||||
},
|
||||
|
||||
providerUseLabel(providerId) {
|
||||
const status = this.providerStatus(providerId);
|
||||
return status.use_label || `Use ${status.short_name || status.display_name || providerId}`;
|
||||
|
|
@ -679,59 +670,16 @@ export const store = createStore("oauthConfig", {
|
|||
}
|
||||
},
|
||||
|
||||
async currentChatModelConfigured() {
|
||||
try {
|
||||
const response = await callJsonApi(`${MODEL_CONFIG_API}/model_config_get`, {});
|
||||
return Boolean(response?.model_configured);
|
||||
} catch (error) {
|
||||
console.error("Could not check model configuration:", error);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
async autoApplyConnectedProviderIfNeeded(providerId) {
|
||||
if (!this.providerConnected(providerId)) return false;
|
||||
if (await this.currentChatModelConfigured()) return false;
|
||||
|
||||
await this.loadModelConfig();
|
||||
if (!this.modelConfig) return false;
|
||||
|
||||
const chatModel = this.providerDefaultModel(providerId, "chat_model");
|
||||
if (!chatModel) return false;
|
||||
const utilityModel = this.providerDefaultModel(providerId, "utility_model") || chatModel;
|
||||
const chat = this.modelSlot("chat_model");
|
||||
const utility = this.modelSlot("utility_model");
|
||||
chat.provider = providerId;
|
||||
chat.name = chatModel;
|
||||
chat.api_base = "";
|
||||
if (!chat.kwargs || typeof chat.kwargs !== "object") chat.kwargs = {};
|
||||
utility.provider = providerId;
|
||||
utility.name = utilityModel;
|
||||
utility.api_base = "";
|
||||
if (!utility.kwargs || typeof utility.kwargs !== "object") utility.kwargs = {};
|
||||
this.activeModelProvider = providerId;
|
||||
this.models = this.activeProviderModels();
|
||||
this.modelConfigDirty = true;
|
||||
this.modelSlotDirty = { chat_model: true, utility_model: true };
|
||||
await this.saveModelConfigIfDirty();
|
||||
return true;
|
||||
},
|
||||
|
||||
notifyModelConfigured(providerId) {
|
||||
notifyModelSetupChanged(providerId) {
|
||||
if (typeof document === "undefined") return;
|
||||
document.dispatchEvent(new CustomEvent("model-configured", {
|
||||
document.dispatchEvent(new CustomEvent("model-setup-changed", {
|
||||
detail: { source: "_oauth", providerId },
|
||||
}));
|
||||
},
|
||||
|
||||
async handleProviderConnected(providerId, { statusLoaded = false } = {}) {
|
||||
if (!statusLoaded) await this.loadStatus();
|
||||
try {
|
||||
await this.autoApplyConnectedProviderIfNeeded(providerId);
|
||||
} catch (error) {
|
||||
void toastFrontendError(messageOf(error), "OAuth Connections");
|
||||
}
|
||||
this.notifyModelConfigured(providerId);
|
||||
this.notifyModelSetupChanged(providerId);
|
||||
},
|
||||
|
||||
async loadStatus() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue