Skip to content

Session modelOverride persists across gateway restarts, silently overrides config default #51251

@Ike-li

Description

@Ike-li

Bug type

Behavior bug (incorrect state without crash)

Summary

When a session-level model override is set via /model, it persists in the session store across gateway restarts. After changing the default model in openclaw.json and restarting, existing (and even /new-ed) sessions still use the stale override instead of the updated config default.

Steps to reproduce

  1. In a DM session, pin a model: /model newapi/gpt-5.4
  2. Verify with /status — shows newapi/gpt-5.4
  3. Edit openclaw.json, change agents.defaults.model.primary (or agent-level model) to openrouter/xiaomi/mimo-v2-pro
  4. Restart gateway (openclaw gateway restart)
  5. In the same DM session, run /status — still shows newapi/gpt-5.4 (stale override)
  6. Run /new — the new session also inherits or retains the old override instead of the new config default

Expected behavior

After changing the default model in config and restarting gateway:

  • Existing sessions should either respect the new default OR clearly indicate they have a session-level override
  • /new should create a fresh session with no override, picking up the new config default
  • At minimum, there should be a way to clear all session model overrides

Actual behavior

modelOverride in ~/.openclaw/agents/main/sessions/sessions.json persists across restarts with highest precedence. The config default change is effectively invisible to any session that was ever touched by /model.

Root cause

Session-level modelOverride is stored in the session store and survives gateway restarts. Model resolution order gives session override higher precedence than config defaults, with no mechanism to clear stale overrides after config changes.

Impact

Suggested fix

  1. On /new: always start fresh without inheriting modelOverride from the previous session
  2. Model resolution precedence: consider making config-specified model higher priority than stale session overrides, or add an explicit "clear override" mechanism
  3. Visibility: /status should clearly distinguish between "using config default" and "using session override" so users can tell when an override is active
  4. Bulk reset: add a command like /model reset or /model inherit to clear session-level override and fall back to config

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions