-
-
Notifications
You must be signed in to change notification settings - Fork 79.2k
[Bug]: sessions.patch model:null leaves liveModelSwitchPending=true on disk; produces ghost model labels in /model after provider removal #83192
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.Auth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug type
Behavior bug / partial state cleanup
Beta release blocker
No
Summary
sessions.patchwithmodel: nullreturns success and clearsmodelOverride,providerOverride, andmodelOverrideSourcefrom the session entry, but leavesliveModelSwitchPending: trueon disk. The orphan flag causes downstream resolvers (e.g./modelrendering) to reconstruct a ghost selection from the session's.jsonltrajectory, which produces nonsensical model labels in chat when the originally-pinned model/provider no longer exists in config.This is distinct from #69951 (override silently ignored), #77322 (
session.modelcache survives/new), and #73090 (modelProvider metadata not normalized for CLI runtimes).Environment
2026.5.12 (f066dd2)/usr/lib/node_modules/openclaw)Steps to reproduce
Pure gateway-call repro, no UI required.
Expected behavior
T4 should show all four fields as
<unset>.sessions.patch model:nullis the documented way to clear a pinned model and should leave the entry in the same shape as a fresh session.Actual behavior
T4 output:
The orphan
liveModelSwitchPending: truesurvives indefinitely until either (a) anothersessions.patchwith a concrete model triggers a successful live switch (which clears it viaclearLiveModelSwitchPending), or (b) manual JSON edit.Observed downstream impact
In my session this morning, the orphan flag manifested when sending
/modelin Telegram. The handler showed:qwen-7bwas an alias I had defined hours earlier on a now-removedllm-vpsprovider. The provider entry and the alias had both been deleted fromopenclaw.jsonand the gateway restarted. The only remaining trace was the orphanliveModelSwitchPending: trueonagent:main:main. The handler'sresolveLiveSessionModelSelectionpath apparently mined the session's.jsonltrajectory for the most recent/new-style switch, found "qwen-7b" (now an unknown identifier), and fell back to the default provider (openai) to render the bogusopenai/qwen-7blabel.Removing
liveModelSwitchPending: truemanually from the entry, then re-rendering/model, immediately produced the correctCurrent: openai/gpt-5.Suggested fix direction
In the same code path that handles
sessions.patchwithmodel: null(clearing the pin), also callclearLiveModelSwitchPendingfor that session key. The function already exists atlive-model-switch-CgybHLBX.js(bundled name) and is whatmodel_spawnand live-switch retries use to consume the flag — it should be the canonical drain on explicit-clear as well.A defensive measure in
formatCurrentModelLine/resolveLiveSessionModelSelection(don't synthesize a selection from trajectory when the override fields are unset) would also prevent ghost labels even if the orphan flag persists for unrelated reasons.