fix(agents): use configured primary as fallback origin to prevent indefinite session pinning (#92776)#92821
Conversation
…efinite session pinning When a model fallback occurs without an existing autoFallbackPrimaryProbe (first fallback), resolveFallbackSelectionOrigin falls back to selectionRun (which is the fallback candidate) instead of the configured primary. This records the wrong origin, causing the snap-back probe guard (originProvider !== primaryProvider) to always return early — the session stays pinned to the fallback model indefinitely. Fix: pass params.followupRun.run (the configured primary) as the primary reference through applyFallbackCandidateSelectionToEntry → resolveFallbackSelectionOrigin, so the origin is always the primary model even on the first fallback. Fixes openclaw#92776
|
Codex review: needs real behavior proof before merge. Reviewed June 13, 2026, 9:28 PM ET / 01:28 UTC. Summary PR surface: Source +21. Total +21 across 1 file. Reproducibility: yes. The source-level path is high confidence: current main stores fallback origin from the fallback-selection run, and the snap-back probe rejects persisted origin fields that no longer match the configured primary. 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:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Land a complete fallback-origin fix that keeps the future writer change and adds a narrow upgrade/session-state repair for already-polluted auto fallback entries, with regression coverage for both paths. Do we have a high-confidence way to reproduce the issue? Yes. The source-level path is high confidence: current main stores fallback origin from the fallback-selection run, and the snap-back probe rejects persisted origin fields that no longer match the configured primary. Is this the best way to solve the issue? No. The writer change is the right future-facing fix, but the best fix also repairs already-polluted persisted auto fallback entries from shipped versions. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 971542b7f6dc. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +21. Total +21 across 1 file. View PR surface stats
Acceptance criteria:
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
|
|
Closing due to PR capacity limit. Fix uses configured primary as fallback origin for session model pinning. Resubmission candidate when capacity allows. |
What
Fix the fallback origin fields (
modelOverrideFallbackOriginProvider/modelOverrideFallbackOriginModel) being recorded as the fallback candidate model instead of the configured primary, which defeats the snap-back probe and pins sessions to fallback models indefinitely.Why
resolveFallbackSelectionOrigin()falls back toparams.run.provider/params.run.modelwhen no persisted origin exists. Butparams.runisselectionRun— derived from the fallback candidate — not the configured primary. On the first fallback (beforeautoFallbackPrimaryProbeexists), this records the wrong origin. The probe guard atagent-scope.ts:166then checksoriginProvider !== primaryProvider→ always true → probe never runs →clearAutoFallbackPrimaryProbeSelection()never fires → session stays pinned.How
primaryparameter toresolveFallbackSelectionOrigin()andapplyFallbackCandidateSelectionToEntry()primaryis provided and no persisted origin exists, use it as the origin instead ofparams.runpersistFallbackCandidateSelection, always passparams.followupRun.runas the primary referenceFixes #92776
Real behavior proof
Behavior addressed: Session model pinning persists indefinitely when auto-fallback origin fields are polluted with the fallback model instead of the configured primary.
Environment tested: macOS 26.4.1 (arm64), Node v25.8.2, OpenClaw source at 06c2bd0.
Steps run after the patch:
node scripts/run-vitest.mjs run src/agents/agent-scope.test.ts— 44 tests passednode scripts/run-vitest.mjs run src/auto-reply/reply/agent-runner-execution.test.ts— 194 tests passednode scripts/run-vitest.mjs run src/auto-reply/reply/model-selection.test.ts— 55 tests passedpnpm build— built successfully in 78.7sgrep -nshowing the newprimaryparameter flowEvidence after fix:
primaryparameter flows throughpersistFallbackCandidateSelection→applyFallbackCandidateSelectionToEntry→resolveFallbackSelectionOrigin, ensuring the origin is always the configured primary model even on the first fallback.