fix: expire automatic model fallback pins#79678
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Thanks for the context here. I did a careful shell check against current Current main and the latest release already solve the central sticky auto-fallback-pin problem with shipped primary recovery probes, so this conflicting TTL branch is no longer needed. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the shipped primary-probe recovery implementation and close this parallel TTL branch instead of adding another persisted expiry field. Do we have a high-confidence way to reproduce the issue? No, not on current main: source, docs, and tests show auto fallback pins are now periodically probed and cleared after primary recovery. The PR body does provide a valid branch-side terminal proof for the old TTL approach. Is this the best way to solve the issue? Yes, current main is the better repository solution: it clears auto fallback state after a real primary recovery probe instead of expiring pins after a fixed 30 seconds regardless of provider health. Security review: Security review cleared: No concrete security or supply-chain concern was found; the PR changes session model-selection logic, tests, docs, and a reserved session key only. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 23e9bc8c0b61; fix evidence: release v2026.5.22, commit a374c3a5bfd5. |
There was a problem hiding this comment.
Pull request overview
This PR adds an expiry mechanism for automatically-created (“auto”) session model override pins so that temporary fallback selections will fail back to the configured default model after a short TTL, instead of persisting indefinitely across turns.
Changes:
- Introduces
modelOverrideExpiresAtonSessionEntryplus helpers to compute/clear expiry for auto overrides. - Clears expired auto overrides early in agent/model selection paths so subsequent turns retry the primary/default model.
- Extends fallback pin persistence logic and tests to cover TTL behavior and legacy/non-expiring overrides.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/sessions/model-overrides.ts | Adds TTL constant, expiry detection, and clearing logic; writes expiry when applying auto overrides. |
| src/sessions/model-overrides.test.ts | Adds coverage for expiry creation, expiry clearing, and legacy/user override behavior. |
| src/plugins/session-entry-slot-keys.ts | Reserves modelOverrideExpiresAt to prevent plugin slot collisions. |
| src/config/sessions/types.ts | Adds modelOverrideExpiresAt?: number to SessionEntry. |
| src/auto-reply/reply/model-selection.ts | Clears expired auto overrides before persisted override resolution (and persists store updates when applicable). |
| src/auto-reply/reply/model-selection.test.ts | Verifies expired auto overrides are cleared and default model is re-selected. |
| src/auto-reply/reply/agent-runner-execution.ts | Includes modelOverrideExpiresAt in fallback selection state snapshots and sets expiry when pinning fallbacks. |
| src/auto-reply/reply/agent-runner-execution.test.ts | Asserts fallback pins now include a numeric expiry timestamp. |
| src/agents/agent-command.ts | Clears expired auto overrides before model selection and persists updated session entry. |
|
Added the requested follow-up in
The proof uses OpenClaw's actual model-selection path with a temporary session store. It starts with an expired persisted Fresh verification: @clawsweeper re-review Re-review progress:
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
modelOverrideSource: "auto")docs/concepts/model-failover.mdReal behavior proof
Redacted local proof against the PR branch using OpenClaw's actual
createModelSelectionStatepath and a temporary session store:What this proves:
fallback-provider/fallback-model) and an expiredmodelOverrideExpiresAtprimary-provider/primary-model)Verification
pnpm test -- --run src/sessions/model-overrides.test.ts src/auto-reply/reply/model-selection.test.ts src/auto-reply/reply/agent-runner-execution.test.tssrc/sessions/model-overrides.test.ts: 9 passedsrc/auto-reply/reply/model-selection.test.ts: 32 passedsrc/auto-reply/reply/agent-runner-execution.test.ts: 68 passedNODE_OPTIONS=--max-old-space-size=8192 pnpm tsgo:core:testpnpm format:check docs/concepts/model-failover.md src/sessions/model-overrides.ts src/sessions/model-overrides.test.ts src/agents/agent-command.ts src/auto-reply/reply/model-selection.ts src/auto-reply/reply/model-selection.test.ts src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/agent-runner-execution.test.ts src/config/sessions/types.ts src/plugins/session-entry-slot-keys.ts