Skip to content

fix(sessions): preserve user /model override across daily/idle session rollover (#90119) - #90128

Merged
sallyom merged 1 commit into
openclaw:mainfrom
Marvinthebored:fix-model-override-daily-rollover
Jun 11, 2026
Merged

sallyom merged 1 commit into
openclaw:mainfrom
Marvinthebored:fix-model-override-daily-rollover

Conversation

@Marvinthebored

@Marvinthebored Marvinthebored commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #90119

Problem

A user-driven /model (or sessions.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 the Model set to ... for this session ack. The same override correctly survives an explicit /new or /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 when resetTriggered was true:

} else {
  sessionId = crypto.randomUUID();
  isNewSession = true;
  ...
  if (resetTriggered && entry) {            // gated on resetTriggered only
    ...
    const preservedSelection = resolveResetPreservedSelection({ entry });
    persistedModelOverride = preservedSelection.modelOverride;
    ...
  }
}

An implicit daily/idle stale rollover takes this branch with resetTriggered === false, so resolveResetPreservedSelection never runs. The new entry then resolves modelOverride: persistedModelOverride ?? baseEntry?.modelOverride → undefined ?? undefined → dropped.

resolveResetPreservedSelection already 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//reset and implicit stale daily/idle. Behavior-level carryover (thinking/verbose/reasoning/ttsAuto) and spawn metadata remain scoped to explicit reset triggers, keeping the change tight. Because resolveResetPreservedSelection only preserves modelOverrideSource: "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 existing initSessionState harness):

  • user override survives a daily stale rollover — seed an entry started ~48h ago (stale under default atHour: 4) with a user-driven override, send a normal (non-/new) message, assert isNewSession === true, resetTriggered === false, and the override (provider/model/source) persists in both the result and the store.
  • auto-fallback override is still cleared on a daily stale rollover — same setup but with fallback-origin provenance instead of user; assert the override is dropped.

Real behavior proof

Behavior or issue addressed: A user-driven /model override (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@9c2b5e2 in a real worktree at /Users/admin/openclaw-model-rollover. The harness drives the actual initSessionState from src/auto-reply/reply/session.ts against 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:

$ node --import tsx /tmp/pr90128-proof/harness.mts
# harness: writes a real sessions.json with a 48h-old entry
#   { modelOverride: "claude-opus-4-8", providerOverride: "pioneer", modelOverrideSource: "user" }
# then calls the real initSessionState({ ctx: { Provider:"discord", Body:"what's the time" }, cfg, commandAuthorized:true })
# (Body is a NORMAL message, NOT /new or /reset), then re-reads the persisted store.

Evidence after fix: live stdout JSON from the node --import tsx harness run shows returnedModelOverride=claude-opus-4-8 and persistedModelOverride=claude-opus-4-8 for 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 / source user). The auto-fallback override on the identical rollover is cleared to null, so resets still return to the configured default. Both behaviors observed from live execution of the real initSessionState, 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 initSessionState seam, which is where the regression lived). The wall-clock daily-reset scheduler itself is unchanged.


Filed with AI assistance (OpenClaw agent). Review: @Peetiegonzalez

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.
@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 4, 2026
@Marvinthebored
Marvinthebored marked this pull request as ready for review June 4, 2026 02:43
@clawsweeper

clawsweeper Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 6, 2026, 11:16 PM ET / 03:16 UTC.

Summary
The PR moves reset-preserved model/auth selection copying out of the explicit reset-only branch in initSessionState and adds stale rollover regression tests.

PR surface: Source +7, Tests +105. Total +112 across 2 files.

Reproducibility: yes. at source level: a stale entry with resetTriggered === false skips the only preservation helper on current main, and the PR's added seam tests exercise the same implicit rollover path. I did not run a live current-main repro in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] I did not run the Vitest target in this read-only review; maintainers should rely on CI or run the focused session test before landing.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow helper reuse with regression coverage after normal CI or maintainer test verification, keeping auto-fallback clearing intact.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No ClawSweeper repair lane is needed because this PR already applies the narrow code and test fix; the remaining action is ordinary maintainer merge validation.

Security
Cleared: No concrete security or supply-chain issue found; the diff only changes session state preservation and colocated tests, without adding dependencies, scripts, permissions, or secret access.

Review details

Best 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 resetTriggered === false skips the only preservation helper on current main, and the PR's added seam tests exercise the same implicit rollover path. I did not run a live current-main repro in this read-only review.

Is this the best way to solve the issue?

Yes. Reusing resolveResetPreservedSelection in the existing new-session branch is the narrowest maintainable fix because it shares the established user-vs-auto selection contract instead of duplicating reset logic.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against cfeed10b01f8.

Label changes

Label changes:

  • add P2: This is a normal-priority session/auth-provider state bug with a narrow patch and limited blast radius.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes post-patch live stdout from a Node/tsx harness calling the real initSessionState against an on-disk session store for both user-override preservation and auto-fallback clearing.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes post-patch live stdout from a Node/tsx harness calling the real initSessionState against an on-disk session store for both user-override preservation and auto-fallback clearing.
  • remove rating: 🌊 off-meta tidepool: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority session/auth-provider state bug with a narrow patch and limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes post-patch live stdout from a Node/tsx harness calling the real initSessionState against an on-disk session store for both user-override preservation and auto-fallback clearing.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes post-patch live stdout from a Node/tsx harness calling the real initSessionState against an on-disk session store for both user-override preservation and auto-fallback clearing.
Evidence reviewed

PR surface:

Source +7, Tests +105. Total +112 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 20 13 +7
Tests 1 105 0 +105
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 125 13 +112

What I checked:

  • Root policy read: Read the full root AGENTS.md; its session/auth-provider state and read-beyond-diff review rules applied to this PR. (AGENTS.md:1, cfeed10b01f8)
  • Current-main root cause: On current main, stale rollover enters the new-session branch, but resolveResetPreservedSelection is only called inside if (resetTriggered && entry), so implicit daily/idle rollovers skip it. (src/auto-reply/reply/session.ts:522, cfeed10b01f8)
  • No stale-entry fallback after rollover: For new sessions, baseEntry is undefined, so model/auth overrides must be explicitly copied before the new sessionEntry is built. (src/auto-reply/reply/session.ts:564, cfeed10b01f8)
  • Preservation helper contract: resolveResetPreservedSelection preserves user or legacy explicit model selections and user auth-profile selections, while excluding auto-fallback provenance. (src/config/sessions/reset-preserved-selection.ts:26, cfeed10b01f8)
  • Daily and idle freshness contract: The reset policy defaults to daily reset at 4 and evaluates daily freshness from sessionStartedAt and idle freshness from lastInteractionAt, matching the reported lazy rollover path. (src/config/sessions/reset-policy.ts:22, cfeed10b01f8)
  • Runtime caller checked: The normal reply flow calls initSessionState through reply.init_session_state, so the changed seam is on the user/channel message path. (src/auto-reply/reply/get-reply.ts:464, cfeed10b01f8)

Likely related people:

  • Peter Steinberger: Git history shows Peter introduced the daily reset policy and earlier session reset override preservation work in the same surface. (role: feature-history owner; confidence: high; commits: 367826f6e4e9, 13e2dd97a78a, 384028e12e53; files: src/auto-reply/reply/session.ts, src/auto-reply/reply/session.test.ts, src/config/sessions/reset-policy.ts)
  • Tak Hoffman: Git history shows several reset-continuity fixes around behavior config, CLI continuity, and spawned metadata that share the same new-session preservation invariant. (role: adjacent reset behavior contributor; confidence: medium; commits: cb0a75215688, 1a9abb13bd33, 8a687bdbd72a; files: src/auto-reply/reply/session.ts, src/auto-reply/reply/session.test.ts)
  • Frank Yang: The auto-fallback clearing behavior used by this PR is tied to the session reset fix commit that added user-vs-auto override preservation semantics. (role: introduced auto-fallback reset behavior; confidence: medium; commits: 5d46e4dc4f45; files: src/auto-reply/reply/session.ts, src/config/sessions/reset-preserved-selection.ts, src/auto-reply/reply/session.test.ts)
  • Vincent Koc: Current shallow blame and recent git history show Vincent maintained the session/reset-policy area and release baseline around the reviewed code. (role: recent adjacent contributor; confidence: medium; commits: 1ce84627e8ec, c70be4b4afd0, 2e08f0f4221f; files: src/auto-reply/reply/session.ts, src/config/sessions/reset-policy.ts, src/auto-reply/reply/session.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label Jun 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 7, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 7, 2026
@sallyom sallyom self-assigned this Jun 11, 2026
@sallyom

sallyom commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

@sallyom
sallyom merged commit 8e81bf7 into openclaw:main Jun 11, 2026
265 of 278 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 11, 2026
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]>
harjothkhara added a commit to harjothkhara/openclaw that referenced this pull request Jun 13, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: User /model override silently dropped on daily/idle session rollover (survives /new but not the 4AM reset)

2 participants