Repository navigation
fix(sessions): preserve user /model override across daily/idle session rollover (#90119) - #90128
Conversation
User-driven /model (and sessions.patch) overrides were dropped when a session rolled over at the daily/idle reset boundary, reverting to the configured default on the next turn despite the 'Model set to ... for this session' ack. The override-preservation carryover in initSessionState was gated on resetTriggered, so implicit stale rollovers (the common case for always-on channel sessions) skipped it. Run resolveResetPreservedSelection for any rollover that mints a new session from an existing entry (explicit /new + /reset AND implicit stale daily/idle). resolveResetPreservedSelection already preserves only user-driven overrides and clears auto-fallback pins, so resets still return to the default. Adds regression tests in session.test.ts covering both cases. Fixes #90119 Filed with AI assistance (OpenClaw agent); reviewed by @Peetiegonzalez.
|
Codex review: needs maintainer review before merge. Reviewed June 6, 2026, 11:16 PM ET / 03:16 UTC. Summary PR surface: Source +7, Tests +105. Total +112 across 2 files. Reproducibility: yes. at source level: a stale entry with Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow helper reuse with regression coverage after normal CI or maintainer test verification, keeping auto-fallback clearing intact. Do we have a high-confidence way to reproduce the issue? Yes, at source level: a stale entry with Is this the best way to solve the issue? Yes. Reusing AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against cfeed10b01f8. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +7, Tests +105. Total +112 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Maintainer review note: this is merge-ready. CI is green, autoreview clean with no accepted/actionable findings, and no breaking changes, migration need, or upgrade compatibility concern. The change makes stale daily/idle rollover match the existing explicit reset behavior: preserve user-selected model/auth overrides while still clearing auto fallback pins. |
openclaw#90128) User-driven /model (and sessions.patch) overrides were dropped when a session rolled over at the daily/idle reset boundary, reverting to the configured default on the next turn despite the 'Model set to ... for this session' ack. The override-preservation carryover in initSessionState was gated on resetTriggered, so implicit stale rollovers (the common case for always-on channel sessions) skipped it. Run resolveResetPreservedSelection for any rollover that mints a new session from an existing entry (explicit /new + /reset AND implicit stale daily/idle). resolveResetPreservedSelection already preserves only user-driven overrides and clears auto-fallback pins, so resets still return to the default. Adds regression tests in session.test.ts covering both cases. Fixes openclaw#90119 Filed with AI assistance (OpenClaw agent); reviewed by @Peetiegonzalez. Co-authored-by: Marvinthebored <[email protected]>
…lover (openclaw#92562) Session-level behavior overrides (/think, /verbose, /reasoning, /trace, ttsAuto) survived an explicit /new but were dropped after the automatic daily/idle session reset. initSessionState carried model/auth overrides unconditionally on any rollover that mints a new session (openclaw#90119/openclaw#90128), but kept the behavior-override carryover gated on resetTriggered, so the implicit stale rollover (resetTriggered === false) reverted them to the default. Move the behavior carries alongside the model/auth preservation so they survive implicit rollover too; keep CLI-rotation/spawn-lineage gated on explicit reset. Adds a regression test mirroring the openclaw#90119 daily-rollover model coverage.
Fixes #90119
Problem
A user-driven
/model(orsessions.patch) model override is silently dropped when a session rolls over at the daily/idle reset boundary, reverting the next turn to the configured default — despite theModel set to ... for this sessionack. The same override correctly survives an explicit/newor/reset.This bites always-on Discord/Telegram channel sessions routinely: switch model after the daily reset hour, get a success ack, then the very next message runs on the default.
Root cause
In
src/auto-reply/reply/session.ts→initSessionState, the new-session branch carried over the preserved model/auth selection only whenresetTriggeredwas true:An implicit daily/idle stale rollover takes this branch with
resetTriggered === false, soresolveResetPreservedSelectionnever runs. The new entry then resolvesmodelOverride: persistedModelOverride ?? baseEntry?.modelOverride→undefined ?? undefined→ dropped.resolveResetPreservedSelectionalready does the right thing (preserve user-driven, clear auto-fallback pins) — it simply wasn't invoked on the implicit-rollover path. This is the completion of #69301's intent.Fix
Run
resolveResetPreservedSelection({ entry })for any rollover that mints a new session from an existing entry — explicit/new//resetand implicit stale daily/idle. Behavior-level carryover (thinking/verbose/reasoning/ttsAuto) and spawn metadata remain scoped to explicit reset triggers, keeping the change tight. BecauseresolveResetPreservedSelectiononly preservesmodelOverrideSource: "user"and clears auto-fallback overrides, explicit resets still return to the configured default.Tests
Added two regression tests in
src/auto-reply/reply/session.test.ts(reusing the existinginitSessionStateharness):atHour: 4) with a user-driven override, send a normal (non-/new) message, assertisNewSession === true,resetTriggered === false, and the override (provider/model/source) persists in both the result and the store.user; assert the override is dropped.Real behavior proof
Behavior or issue addressed: A user-driven
/modeloverride (modelOverrideSource: "user") is silently dropped on an implicit daily/idle stale-session rollover (isNewSession === true,resetTriggered === false), reverting the next turn to the configured default (#90119). Auto-fallback overrides must still be cleared on that same rollover.Real environment tested: macOS (Darwin), Node v25.9.0, running the patched branch
fix-model-override-daily-rollover@9c2b5e2in a real worktree at/Users/admin/openclaw-model-rollover. The harness drives the actualinitSessionStatefromsrc/auto-reply/reply/session.tsagainst a real on-disk session store (temp JSON file) — no assertion mocks, no stubbed session logic. Seeded entry started 48h ago so it is genuinely stale under the default daily reset (atHour: 4).Exact steps or command run after this patch:
Evidence after fix: live stdout JSON from the
node --import tsxharness run showsreturnedModelOverride=claude-opus-4-8andpersistedModelOverride=claude-opus-4-8for the user-override case (full fenced JSON below); the auto-fallback case prints all-null. Raw live stdout (user-override case):{ "isNewSession": true, "resetTriggered": false, "returnedModelOverride": "claude-opus-4-8", "returnedProviderOverride": "pioneer", "returnedModelOverrideSource": "user", "persistedModelOverride": "claude-opus-4-8", "persistedProviderOverride": "pioneer", "persistedModelOverrideSource": "user" }Negative case — same stale rollover, but seed
modelOverrideSource: "fallback"(auto-pin), live stdout:{ "isNewSession": true, "resetTriggered": false, "returnedModelOverride": null, "returnedProviderOverride": null, "returnedModelOverrideSource": null, "persistedModelOverride": null, "persistedProviderOverride": null, "persistedModelOverrideSource": null }Observed result after fix: On a real stale daily rollover (
isNewSession: true,resetTriggered: false), the user override survives in both the returned session state and the persisted store (claude-opus-4-8/pioneer/ sourceuser). The auto-fallback override on the identical rollover is cleared tonull, so resets still return to the configured default. Both behaviors observed from live execution of the realinitSessionState, not from unit-test assertions.What was not tested: End-to-end through a live Discord/Telegram gateway turn (the failure is fully reproduced at the
initSessionStateseam, which is where the regression lived). The wall-clock daily-reset scheduler itself is unchanged.Filed with AI assistance (OpenClaw agent). Review: @Peetiegonzalez