openclaw - 💡(How to fix) Fix Live model switch falsely triggers on openai-codex → openai provider alias mismatch [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

shouldSwitchToLiveModel triggers a LiveSessionModelSwitchError when the persisted model selection resolves to a different provider string than the actively running session. In this case it resolved openai (direct API) when the session was running on openai-codex (Codex runtime). These are not aliases — they are fundamentally different runtime paths. The switch kills the active codex app-server turn mid-execution and changes the entire runtime architecture.

Error Message

Gateway log:

16:00:42 [agent/embedded] live session model switch requested during active attempt
  for 633a9e17: openai-codex/gpt-5.5 -> openai/gpt-5.5

Root Cause

In resolveLiveSessionModelSelection (src/agents/live-model-switch.ts), when no explicit override is set, the resolved provider falls through to defaultModelRef.provider (from resolveDefaultModelForAgent), which returns the config-level default provider (openai). The running session uses openai-codex — same upstream API, but a completely different runtime (codex binary vs direct HTTP). The comparison in hasDifferentLiveSessionModelSelection sees the provider mismatch and triggers a switch that should never happen.

The persisted selection should preserve the runtime provider identity (openai-codex) rather than resolving through the config default (openai). A session started on the Codex runtime should never be switched to direct API mode by the live-switch mechanism.

Fix Action

Fixed

Code Example

16:00:42 [agent/embedded] live session model switch requested during active attempt
  for 633a9e17: openai-codex/gpt-5.5 -> openai/gpt-5.5
RAW_BUFFERClick to expand / collapse

Summary

shouldSwitchToLiveModel triggers a LiveSessionModelSwitchError when the persisted model selection resolves to a different provider string than the actively running session. In this case it resolved openai (direct API) when the session was running on openai-codex (Codex runtime). These are not aliases — they are fundamentally different runtime paths. The switch kills the active codex app-server turn mid-execution and changes the entire runtime architecture.

Observed behavior

Gateway log:

16:00:42 [agent/embedded] live session model switch requested during active attempt
  for 633a9e17: openai-codex/gpt-5.5 -> openai/gpt-5.5

The session was running on openai-codex/gpt-5.5 (Codex runtime: binary subprocess, stdio JSON-RPC, sandbox, tool approval). The live-switch check resolved the persisted selection as openai/gpt-5.5 (direct OpenAI API from the gateway — completely different execution path). Since openai-codex !== openai, hasDifferentLiveSessionModelSelection returned true and the active turn was aborted via LiveSessionModelSwitchError.

No user-initiated /model switch occurred. The session died mid-turn.

Root cause

In resolveLiveSessionModelSelection (src/agents/live-model-switch.ts), when no explicit override is set, the resolved provider falls through to defaultModelRef.provider (from resolveDefaultModelForAgent), which returns the config-level default provider (openai). The running session uses openai-codex — same upstream API, but a completely different runtime (codex binary vs direct HTTP). The comparison in hasDifferentLiveSessionModelSelection sees the provider mismatch and triggers a switch that should never happen.

The persisted selection should preserve the runtime provider identity (openai-codex) rather than resolving through the config default (openai). A session started on the Codex runtime should never be switched to direct API mode by the live-switch mechanism.

Impact

  • Kills active codex app-server turns mid-execution with no user action
  • Changes runtime architecture silently — from Codex binary (sandbox, tool approval, stdio JSON-RPC) to direct API (gateway HTTP client)
  • Session appears frozen to the user ("typing..." with no response)
  • Non-deterministic — depends on whether the config default provider string matches the runtime provider string
  • No liveModelSwitchPending flag was set by the user — the false trigger comes purely from provider resolution fallthrough

Environment

  • OpenClaw 2026.5.26-beta.1
  • Codex runtime (openai-codex) with gpt-5.5
  • Config default provider: openai

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Live model switch falsely triggers on openai-codex → openai provider alias mismatch [1 pull requests]