openclaw - ✅(Solved) Fix [Bug]: configure wizard Model section silently overwrites agents.defaults.model.primary to openrouter/auto [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70696Fetched 2026-04-24 05:54:34
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
cross-referenced ×2labeled ×2

Severity: P1 (Critical) Environment: OpenClaw: 2026.4.22 (00bd2cf) OS: Linux 6.6.87.2-microsoft-standard-WSL2 (x64) Node: 22.22.2 Description: The openclaw configure --section model wizard has a critical bug: it silently overwrites agents.defaults.model.primary back to openrouter/auto whenever any model selection is made, completely ignoring the user's intended default. Steps to reproduce: Run openclaw configure (or openclaw config with no subcommand) Select section: model Notice it shows current default as openrouter/auto Select/deselect models from the allowlist picker Confirm and complete the wizard Run openclaw config get agents.defaults.model.primary — it resets to openrouter/auto Any prior change to agents.defaults.model.primary (via direct CLI) is silently clobbered Separate finding — feature gap: The Model section of the wizard operates on agents.defaults.models (the ALLOWLIST), NOT on agents.defaults.model.primary (the actual default model). Per official docs: https://docs.openclaw.ai/cli/configure

"The Model section now includes a multi-select for the agents.defaults.models allowlist (what shows up in /model and the model picker)." There is no interactive path in the wizard to change the global default model. The Control UI Quick Settings also only changes the session-level override, not the global default. The only working path is:

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Workaround (verified):

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Root Cause

Severity: P1 (Critical) Environment: OpenClaw: 2026.4.22 (00bd2cf) OS: Linux 6.6.87.2-microsoft-standard-WSL2 (x64) Node: 22.22.2 Description: The openclaw configure --section model wizard has a critical bug: it silently overwrites agents.defaults.model.primary back to openrouter/auto whenever any model selection is made, completely ignoring the user's intended default. Steps to reproduce: Run openclaw configure (or openclaw config with no subcommand) Select section: model Notice it shows current default as openrouter/auto Select/deselect models from the allowlist picker Confirm and complete the wizard Run openclaw config get agents.defaults.model.primary — it resets to openrouter/auto Any prior change to agents.defaults.model.primary (via direct CLI) is silently clobbered Separate finding — feature gap: The Model section of the wizard operates on agents.defaults.models (the ALLOWLIST), NOT on agents.defaults.model.primary (the actual default model). Per official docs: https://docs.openclaw.ai/cli/configure

"The Model section now includes a multi-select for the agents.defaults.models allowlist (what shows up in /model and the model picker)." There is no interactive path in the wizard to change the global default model. The Control UI Quick Settings also only changes the session-level override, not the global default. The only working path is:

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Workaround (verified):

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Fix Action

Fix / Workaround

Severity: P1 (Critical) Environment: OpenClaw: 2026.4.22 (00bd2cf) OS: Linux 6.6.87.2-microsoft-standard-WSL2 (x64) Node: 22.22.2 Description: The openclaw configure --section model wizard has a critical bug: it silently overwrites agents.defaults.model.primary back to openrouter/auto whenever any model selection is made, completely ignoring the user's intended default. Steps to reproduce: Run openclaw configure (or openclaw config with no subcommand) Select section: model Notice it shows current default as openrouter/auto Select/deselect models from the allowlist picker Confirm and complete the wizard Run openclaw config get agents.defaults.model.primary — it resets to openrouter/auto Any prior change to agents.defaults.model.primary (via direct CLI) is silently clobbered Separate finding — feature gap: The Model section of the wizard operates on agents.defaults.models (the ALLOWLIST), NOT on agents.defaults.model.primary (the actual default model). Per official docs: https://docs.openclaw.ai/cli/configure

"The Model section now includes a multi-select for the agents.defaults.models allowlist (what shows up in /model and the model picker)." There is no interactive path in the wizard to change the global default model. The Control UI Quick Settings also only changes the session-level override, not the global default. The only working path is:

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Workaround (verified):

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Steps to reproduce: Run openclaw configure (or openclaw config with no subcommand) Select section: model Notice it shows current default as openrouter/auto Select/deselect models from the allowlist picker Confirm and complete the wizard Run openclaw config get agents.defaults.model.primary — it resets to openrouter/auto Any prior change to agents.defaults.model.primary (via direct CLI) is silently clobbered Separate finding — feature gap: The Model section of the wizard operates on agents.defaults.models (the ALLOWLIST), NOT on agents.defaults.model.primary (the actual default model). Per official docs: https://docs.openclaw.ai/cli/configure

"The Model section now includes a multi-select for the agents.defaults.models allowlist (what shows up in /model and the model picker)." There is no interactive path in the wizard to change the global default model. The Control UI Quick Settings also only changes the session-level override, not the global default. The only working path is:

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Workaround (verified):

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

PR fix notes

PR #70793: fix: wizard no clobber model.primary on re-run

Description (problem / solution / changelog)

Summary

  • Problem: Configure wizard silently overwrites agents.defaults.model.primary when user re-runs model section. Two separate code paths clobber the user's chosen primary model.
  • Why it matters: User explicitly picks a primary model via CLI, re-runs wizard for provider auth, and their choice is silently replaced — no warning, no indication.
  • What changed: Two one-line fixes: (1) applyDefaultModel() now preserves existing primary instead of unconditionally overwriting; (2) applyModelFallbacksFromSelection() no longer injects a phantom primary when none was configured.
  • What did NOT change (scope boundary): No changes to wizard flow, provider auth logic, model resolution, or config schema. Only the two assignment expressions that clobber model.primary.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #70696
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause (Bug 1): applyDefaultModel() in src/plugins/provider-auth-choice-helpers.ts:138 sets primary: model unconditionally. When wizard re-runs with setDefaultModel: true, the provider's default model (e.g. openrouter/auto) overwrites whatever the user had previously configured.
  • Root cause (Bug 2): applyModelFallbacksFromSelection() in src/flows/model-picker.ts:833 uses primary: existingPrimary ?? resolvedKey. When no primary was configured, existingPrimary is undefined and resolvedKey (the hardcoded default) gets injected as a phantom primary the user never chose.
  • Missing detection / guardrail: No test asserted that existing primary survives re-application of default model or that absent primary stays absent after fallback selection.
  • Contributing context: The restoreConfiguredPrimaryModel helper at line 299 of provider-auth-choice.ts already handles the setDefaultModel: false path correctly — the setDefaultModel: true path was simply missed.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • src/plugins/provider-auth-choice-helpers.test.ts — 4 new tests for applyDefaultModel
    • src/commands/model-picker.test.ts — 1 new test for phantom primary injection
  • Scenario the test should lock in:
    • applyDefaultModel preserves an existing primary instead of overwriting
    • applyDefaultModel preserves existing fallbacks alongside existing primary
    • applyModelFallbacksFromSelection does not inject phantom primary when none configured
  • Why this is the smallest reliable guardrail: Both bugs are pure data transformation (config in → config out) with no side effects, so unit tests on the helper functions are sufficient.
  • Existing test that already covers this (if any): None — these helpers had no applyDefaultModel tests and no phantom-primary assertion.

User-visible / Behavior Changes

  • User's configured agents.defaults.model.primary is no longer silently overwritten when re-running the configure wizard's provider auth section.
  • When no primary model is configured, the fallback selection flow no longer injects a default model as primary.

Diagram (if applicable)

Before (Bug 1):
[wizard re-run] -> applyDefaultModel(config, "openrouter/auto")
  -> primary: "openrouter/auto"  (CLOBBERS user's "anthropic/claude-opus-4-6")

After (Bug 1):
[wizard re-run] -> applyDefaultModel(config, "openrouter/auto")
  -> primary: "anthropic/claude-opus-4-6"  (PRESERVED, provider default ignored)

Before (Bug 2):
[no primary configured] -> applyModelFallbacksFromSelection(config, selections)
  -> { primary: "openai/gpt-5.5", fallbacks: [...] }  (PHANTOM primary injected)

After (Bug 2):
[no primary configured] -> applyModelFallbacksFromSelection(config, selections)
  -> { fallbacks: [...] }  (no primary key — correct)

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Linux (CachyOS/Arch)
  • Runtime/container: Node 22+, pnpm
  • Model/provider: Any (reproduces with OpenRouter, OpenAI)
  • Relevant config: agents.defaults.model.primary set to any non-default value

Steps

  1. Run openclaw configure wizard, set a primary model (e.g. anthropic/claude-opus-4-6)
  2. Re-run wizard, go through provider auth section (triggers applyDefaultModel with provider's default)
  3. Check ~/.openclaw/default.yamlagents.defaults.model.primary is now the provider's default, not user's choice

Expected

  • agents.defaults.model.primary remains anthropic/claude-opus-4-6

Actual

  • agents.defaults.model.primary silently changed to provider default (e.g. openrouter/auto)

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

5 new tests added covering both bugs. All 22 tests pass in affected test files. 0 lint errors on all 4 changed files.

Human Verification (required)

  • Verified scenarios: Both fixes verified via unit tests — applyDefaultModel preserves existing primary, applyModelFallbacksFromSelection does not inject phantom primary. Full test suite (22/22) passes. Typecheck via pnpm check:changed passes. Lint (oxlint) clean on all 4 files.
  • Edge cases checked: No existing primary (should set it), existing primary with fallbacks (should preserve both), string-form existing model config (should extract primary correctly).
  • What you did not verify: Full e2e wizard flow on a live instance (no connected provider accounts in dev env).

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: Edge case where existingModel is a plain string (legacy config format) and extraction of existingPrimary fails silently.
    • Mitigation: applyDefaultModel now handles both string and object model formats via explicit type checks (lines 126–132). Covered by test.

AI-assisted PR (OpenCode + Claude). Fully tested. I understand what the code does — traced both bugs through the full wizard flow before writing fixes.

Changed files

  • src/commands/model-picker.test.ts (modified, +17/-0)
  • src/flows/model-picker.ts (modified, +1/-1)
  • src/plugins/provider-auth-choice-helpers.test.ts (modified, +54/-1)
  • src/plugins/provider-auth-choice-helpers.ts (modified, +7/-1)

PR #3: fix(configure): preserve custom primary model when reconfiguring auth

Description (problem / solution / changelog)

Summary

  • openclaw configure --section model (or openclaw configure > Model section) silently resets agents.defaults.model.primary to the provider's default (e.g. openrouter/auto) even when the user has previously set a custom primary model via openclaw config set.
  • Root cause: applyDefaultModelChoice with setDefaultModel: true unconditionally called applyDefaultConfig, which calls applyAgentDefaultModelPrimary on every provider handler, overwriting whatever primary was already in config.
  • Fix: check for an existing primary before branching. If one is set, call applyProviderConfig instead (sets up auth/allowlist without touching primary). Only call applyDefaultConfig on a fresh setup where no primary has been configured yet.

Root Cause

src/commands/auth-choice.default-model.ts:applyDefaultModelChoice - the setDefaultModel: true branch:

// before
if (params.setDefaultModel) {
  const next = params.applyDefaultConfig(params.config);  // always clobbers primary
  ...
}

Every provider's applyDefaultConfig (e.g. applyOpenrouterConfig) ends with applyAgentDefaultModelPrimary(cfg, PROVIDER_DEFAULT_MODEL), which unconditionally writes the provider default into agents.defaults.model.primary. On a first-time run this is correct. On a reconfigure run it clobbers any custom value the user set via CLI.

Fix

src/commands/auth-choice.default-model.ts - 12 lines added:

const existingPrimary = resolveAgentModelPrimaryValue(params.config.agents?.defaults?.model);
if (existingPrimary) {
  const next = params.applyProviderConfig(params.config);
  return { config: next };
}

applyProviderConfig (e.g. applyOpenrouterProviderConfig) adds the provider model to the allowlist without touching primary.

Test Plan

  • 4 new unit tests in src/commands/auth-choice.default-model.test.ts:
    • fresh install (no existing primary) - sets provider default, shows note
    • existing object-form primary - preserved, applyDefaultConfig NOT called (regression for #70696)
    • existing string-form primary - preserved
    • setDefaultModel: false path - unchanged behavior, agentModelOverride returned
  • All 4 tests pass
  • Existing model-picker.test.ts (7 tests) still pass
  • Lint + format clean

Closes #70696


Generated by Claude Code

<!-- devin-review-badge-begin -->
<a href="https://app.devin.ai/review/suboss87/openclaw/pull/3" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open in Devin Review"> </picture> </a> <!-- devin-review-badge-end -->

Changed files

  • src/commands/auth-choice.default-model.test.ts (added, +141/-0)
  • src/commands/auth-choice.default-model.ts (modified, +12/-0)

Code Example

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

---

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

---

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

---

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

---

Requested Fix:
Fix the silent overwrite — wizard must NOT reset `agents.defaults.model.primary` on save
Add a "Default primary model" step to the Model section of the configure wizard
Add global default model selector to Control UI (Quick Settings or new Settings tab)
Evidence:
Diff of `openclaw.json.bak` vs `openclaw.json` after wizard run: primary changed from `anthropic/claude-opus-4-7` back to `openrouter/auto` after running wizard
Docs confirm Model section = allowlist only: https://docs.openclaw.ai/cli/configure
Confirmed via code inspection of `agents-DScFL3VN.js` — per-agent model select exists but no global default picker
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Severity: P1 (Critical) Environment: OpenClaw: 2026.4.22 (00bd2cf) OS: Linux 6.6.87.2-microsoft-standard-WSL2 (x64) Node: 22.22.2 Description: The openclaw configure --section model wizard has a critical bug: it silently overwrites agents.defaults.model.primary back to openrouter/auto whenever any model selection is made, completely ignoring the user's intended default. Steps to reproduce: Run openclaw configure (or openclaw config with no subcommand) Select section: model Notice it shows current default as openrouter/auto Select/deselect models from the allowlist picker Confirm and complete the wizard Run openclaw config get agents.defaults.model.primary — it resets to openrouter/auto Any prior change to agents.defaults.model.primary (via direct CLI) is silently clobbered Separate finding — feature gap: The Model section of the wizard operates on agents.defaults.models (the ALLOWLIST), NOT on agents.defaults.model.primary (the actual default model). Per official docs: https://docs.openclaw.ai/cli/configure

"The Model section now includes a multi-select for the agents.defaults.models allowlist (what shows up in /model and the model picker)." There is no interactive path in the wizard to change the global default model. The Control UI Quick Settings also only changes the session-level override, not the global default. The only working path is:

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Workaround (verified):

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Steps to reproduce

Steps to reproduce: Run openclaw configure (or openclaw config with no subcommand) Select section: model Notice it shows current default as openrouter/auto Select/deselect models from the allowlist picker Confirm and complete the wizard Run openclaw config get agents.defaults.model.primary — it resets to openrouter/auto Any prior change to agents.defaults.model.primary (via direct CLI) is silently clobbered Separate finding — feature gap: The Model section of the wizard operates on agents.defaults.models (the ALLOWLIST), NOT on agents.defaults.model.primary (the actual default model). Per official docs: https://docs.openclaw.ai/cli/configure

"The Model section now includes a multi-select for the agents.defaults.models allowlist (what shows up in /model and the model picker)." There is no interactive path in the wizard to change the global default model. The Control UI Quick Settings also only changes the session-level override, not the global default. The only working path is:

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Workaround (verified):

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Expected behavior

model selected from model picker in terminal/cli should stick once gateway updated as new default model.

Actual behavior

its not sticking

OpenClaw version

2026.4.22

Operating system

OS: Linux 6.6.87.2-microsoft-standard-WSL2 (x64)

Install method

npm global

Model

openrouter/auto , any model selected.

Provider / routing chain

openclaw-->any provider

Additional provider/model setup details

Requested Fix: Fix the silent overwrite — wizard must NOT reset agents.defaults.model.primary on save Add a "Default primary model" step to the Model section of the configure wizard Add global default model selector to Control UI (Quick Settings or new Settings tab) Evidence: Diff of openclaw.json.bak vs openclaw.json after wizard run: primary changed from anthropic/claude-opus-4-7 back to openrouter/auto after running wizard Docs confirm Model section = allowlist only: https://docs.openclaw.ai/cli/configure Confirmed via code inspection of agents-DScFL3VN.js — per-agent model select exists but no global default picker

Logs, screenshots, and evidence

Requested Fix:
Fix the silent overwrite — wizard must NOT reset `agents.defaults.model.primary` on save
Add a "Default primary model" step to the Model section of the configure wizard
Add global default model selector to Control UI (Quick Settings or new Settings tab)
Evidence:
Diff of `openclaw.json.bak` vs `openclaw.json` after wizard run: primary changed from `anthropic/claude-opus-4-7` back to `openrouter/auto` after running wizard
Docs confirm Model section = allowlist only: https://docs.openclaw.ai/cli/configure
Confirmed via code inspection of `agents-DScFL3VN.js` — per-agent model select exists but no global default picker

Impact and severity

Requested Fix: Fix the silent overwrite — wizard must NOT reset agents.defaults.model.primary on save Add a "Default primary model" step to the Model section of the configure wizard Add global default model selector to Control UI (Quick Settings or new Settings tab) Evidence: Diff of openclaw.json.bak vs openclaw.json after wizard run: primary changed from anthropic/claude-opus-4-7 back to openrouter/auto after running wizard Docs confirm Model section = allowlist only: https://docs.openclaw.ai/cli/configure Confirmed via code inspection of agents-DScFL3VN.js — per-agent model select exists but no global default picker

Additional information

Requested Fix: Fix the silent overwrite — wizard must NOT reset agents.defaults.model.primary on save Add a "Default primary model" step to the Model section of the configure wizard Add global default model selector to Control UI (Quick Settings or new Settings tab) Evidence: Diff of openclaw.json.bak vs openclaw.json after wizard run: primary changed from anthropic/claude-opus-4-7 back to openrouter/auto after running wizard Docs confirm Model section = allowlist only: https://docs.openclaw.ai/cli/configure Confirmed via code inspection of agents-DScFL3VN.js — per-agent model select exists but no global default picker

extent analysis

TL;DR

To fix the issue, use the verified workaround: set the default model via CLI and restart the gateway.

Guidance

  • The openclaw configure wizard silently overwrites the agents.defaults.model.primary setting, so avoid using it to change the default model.
  • Use the CLI command openclaw config set agents.defaults.model.primary to set the default model, followed by openclaw gateway restart.
  • Verify the change by running openclaw config get agents.defaults.model.primary after restarting the gateway.
  • Note that the Model section of the wizard only operates on the agents.defaults.models allowlist, not the agents.defaults.model.primary setting.

Example

openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-7"
openclaw gateway restart

Notes

The issue is specific to the openclaw configure wizard and does not affect the CLI commands. The verified workaround provides a reliable way to set the default model until the wizard is fixed.

Recommendation

Apply the workaround: use the CLI command to set the default model and restart the gateway, as it is a verified solution to the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

model selected from model picker in terminal/cli should stick once gateway updated as new default model.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: configure wizard Model section silently overwrites agents.defaults.model.primary to openrouter/auto [2 pull requests, 1 participants]