-
Notifications
You must be signed in to change notification settings - Fork 240
fix(controller): clear model config when no providers configured #1080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
500a648
3727875
deaf677
2c8c70e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -312,21 +312,48 @@ export class OpenClawSyncService { | |
| } | ||
|
|
||
| // 2. Always write files once (persistence + watcher hot-reload path). | ||
| const hasAnyProvider = | ||
| Object.keys(compiled.models?.providers ?? {}).length > 0; | ||
|
|
||
| // When no model provider is configured (e.g. after link logout with no | ||
| // BYOK keys), strip the model from agents so OpenClaw cannot fall back | ||
| // to its built-in registry with the bare model name. This is a | ||
| // hot-reload-safe change (agents.list → dynamic reads, no gateway restart). | ||
| if (!hasAnyProvider) { | ||
| if (compiled.agents.defaults?.model) { | ||
| compiled.agents.defaults = { | ||
|
Comment on lines
+322
to
+324
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The config hash check ( Useful? React with 👍 / 👎. |
||
| ...compiled.agents.defaults, | ||
| model: undefined, | ||
| }; | ||
| } | ||
| for (const agent of compiled.agents.list ?? []) { | ||
| if (agent.model) { | ||
| agent.model = undefined; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| await this.configWriter.write(compiled); | ||
| await this.authProfilesWriter.writeForAgents( | ||
| compiled, | ||
| config.models.providers, | ||
| ); | ||
| this.gatewayService.noteConfigWritten(compiled); | ||
| const runtimeModelRef = resolvePrimaryModelRef( | ||
| compiled.agents.defaults?.model, | ||
| config, | ||
| compiled, | ||
| this.env, | ||
| oauthState, | ||
| ); | ||
| const runtimeModelRef = hasAnyProvider | ||
| ? resolvePrimaryModelRef( | ||
| compiled.agents.defaults?.model, | ||
| config, | ||
| compiled, | ||
| this.env, | ||
| oauthState, | ||
| ) | ||
| : null; | ||
| logger.info({ seq, runtimeModelRef }, "doSync: resolved runtime model"); | ||
| await this.runtimeModelWriter.write(runtimeModelRef); | ||
| if (runtimeModelRef) { | ||
| await this.runtimeModelWriter.write(runtimeModelRef); | ||
| } else { | ||
| await this.runtimeModelWriter.clear(); | ||
| } | ||
| // Write locale state for the credit-guard patch in OpenClaw runtime. | ||
| // Match the controller's own locale default: unset → "en" (not "zh-CN"). | ||
| const locale = | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting the runtime-model state file here does not actually clear the active override while OpenClaw stays running: the
nexu-runtime-modelplugin’sloadState()returns its in-memorycachedStateon file-read errors (includingENOENT), so the previously selected model keeps being applied after logout until process restart. In the no-provider flow this means conversations can still route with the stale model despite the sync intending to disable model usage.Useful? React with 👍 / 👎.