fix(session): clear stale auto fallback origins#92790
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 13, 2026, 5:46 PM ET / 21:46 UTC. Summary PR surface: Source +133, Tests +113. Total +246 across 7 files. Reproducibility: yes. Current main source shows a polluted-origin auto fallback entry can keep its stored model override while the primary probe returns undefined, matching the linked issue's reproduction shape. Review metrics: 1 noteworthy metric.
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 cleanup that treats only auto or recovered-auto mismatched fallback-origin pins as stale across normal model-selection entry points while preserving user overrides and auth-profile validation. Do we have a high-confidence way to reproduce the issue? Yes. Current main source shows a polluted-origin auto fallback entry can keep its stored model override while the primary probe returns undefined, matching the linked issue's reproduction shape. Is this the best way to solve the issue? Yes. The PR uses existing override reset helpers and a shared stale-origin predicate across auto-reply and direct agent-command paths, which is narrower than adding a config surface or broad migration path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ae68006a8fba. Label changesLabel justifications:
Evidence reviewedPR surface: Source +133, Tests +113. Total +246 across 7 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
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
maintainer deep review found the stale-fallback bug is real, but this PR is not safe to keep extending or land. After two repair passes, final autoreview still found four cross-surface inconsistencies: cleanup happens before unrelated read-only slash commands are dispatched; pre-dispatch harness delivery policy still reads the stale override; non-mutating/preserve-state agent-command paths can carry fallback-specific auth into the new primary; and the normal reply path reports stale-origin repair as a false allowlist rejection. Those are symptoms of cleanup being implemented independently in multiple selection/dispatch paths. The canonical fix needs one prepared model-selection result, including delivery policy and auth semantics, carried through the whole turn before any persistent cleanup occurs. I am closing this PR rather than landing more one-sided guards. The underlying issue should remain open for that bounded owner-boundary refactor. Focused repair proof passed (137 tests), but final autoreview correctly remains blocking. |
Summary
Fixes #92776.
Verification
pnpm install --frozen-lockfilepnpm exec oxfmt --write --threads=1 src/auto-reply/reply/get-reply.ts src/auto-reply/reply/model-selection.test.ts src/auto-reply/reply/model-selection.ts src/auto-reply/reply/stored-model-override.tsnode scripts/run-vitest.mjs src/auto-reply/reply/model-selection.test.tsnode scripts/run-vitest.mjs src/agents/agent-scope.test.tsnode scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/followup-runner.test.tsnode scripts/run-vitest.mjs src/agents/agent-command.live-model-switch.test.tspnpm lint:corepnpm tsgo:coreReal behavior proof
Behavior addressed: Auto-created fallback model pins with polluted
modelOverrideFallbackOriginProvider/modelOverrideFallbackOriginModelno longer keep normal turns on the fallback indefinitely when the current configured primary differs from the stored origin.Real environment tested: Local OpenClaw source checkout at
b63a5e3df4f062be5206015c4d09673a4ae55eacon macOS with Nodev24.15.0and pnpm11.2.2, running the production model-selection module throughnode --import tsxagainst a temporary session-store entry shaped like #92776.Exact steps or command run after this patch:
Evidence after fix: terminal output from that command:
{ "selected": { "provider": "anthropic", "model": "claude-opus-4-8" }, "resetModelOverride": true, "resetModelOverrideRef": "anthropic/claude-opus-4-7", "persistedEntry": { "providerOverride": null, "modelOverride": null, "modelOverrideSource": null, "originProvider": null, "originModel": null } }Observed result after fix: The selected model is the current primary
anthropic/claude-opus-4-8,resetModelOverrideis true for the stale fallback pin, and the stored override plus fallback-origin fields are cleared from the session entry.What was not tested: I did not run a live provider-outage reproduction or call a real Anthropic account; this proof exercises the production OpenClaw model-selection path on a local checkout with the persisted session-state shape from #92776.