fix: preserve selected models through hot reloads and fallbacks#103510
Merged
Conversation
Co-authored-by: Ayaan Zaidi <[email protected]>
Contributor
Author
|
Land-ready proof for
Sanitized AWS Crabbox was unavailable because this environment has no usable AWS credentials or instance role; secretless exact-head PR CI is the authoritative remote proof. This replacement preserves @obviyus's turn-local fallback commit/authorship while fixing config freshness at the Telegram operation/turn boundary. |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Jul 10, 2026
…claw#103510) * fix(agents): keep model fallback turn-local instead of persisting over user pins * fix(telegram): use live config snapshots per operation Co-authored-by: Ayaan Zaidi <[email protected]> * test(telegram): fix config snapshot type coverage --------- Co-authored-by: Ayaan Zaidi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #103324.
Supersedes #103417. This replacement retains Ayaan Zaidi's (@obviyus) turn-local fallback commit with original authorship and incorporates his root-cause investigation.
What Problem This Solves
Fixes an issue where Telegram could confirm a
/modelselection from hot-reloaded config, but the next turn still used the Gateway's startup snapshot. The selected model was then rejected, and fallback could permanently overwrite the user's explicit session pin.This was observed when selecting
openai/gpt-5.6-luna:/modeland/statusshowed Luna, while the next message ran another provider and persisted that fallback over the pin.Why This Change Was Made
Fallback candidates are now turn-local and never replace an explicit user model selection. Each Telegram authorization operation owns one live config snapshot; independently, each assembled agent turn captures once after debounce/media/text batching and carries that exact object through routing, context construction, model resolution, and dispatch. Native commands likewise use one live snapshot for auth, routing, delivery settings, and execution. Complete reply-config metadata is tracked out of band so frozen configs and identity-keyed caches remain valid.
This keeps the sound first commit from #103417 while replacing its later approaches:
User Impact
Telegram model selections made after a config hot reload take effect on the next assembled turn without requiring a Gateway restart. If the selected model fails, OpenClaw may use a fallback for that turn and show the existing notice, but later turns retry the user's pinned model instead of silently replacing it. Hot-reloaded Telegram authorization policy is applied consistently, and auth-profile ordering remains unchanged.
Evidence
openai/gpt-5.6-luna, selects it through the Telegram model callback, and proves the next debounced turn dispatches with the exact post-batching live config while preserving the user pin.openai/gpt-5.6-lunaturn can use another provider without changing the persisted user selection.node scripts/run-vitest.mjs extensions/telegram/src/bot.test.ts extensions/telegram/src/bot-native-commands.session-meta.test.ts extensions/telegram/src/bot-native-commands.group-auth.test.ts extensions/telegram/src/bot-native-commands.test.ts extensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.ts extensions/telegram/src/bot.media.stickers-and-fragments.e2e.test.ts(178 passed)node scripts/run-vitest.mjs src/auto-reply/reply/get-reply.config-override.test.ts src/auto-reply/reply/get-reply.fast-path.test.ts src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts.agents/skills/autoreview/scripts/autoreview --mode local --codex-bin <Codex 0.144.1>(clean, no actionable findings)git diff --checkSanitized AWS Crabbox was unavailable because this environment had no usable AWS credentials or instance role; secretless PR CI is the authoritative remote proof.