Skip to content

fix: use the configured runtime when switching model providers - #203973

Merged
vyctorbrzezowski merged 2 commits into
mainfrom
openclaw/troca-para-opus-cai-no-runtime-sem-conta-abe866
Nov 25, 2026
Merged

vyctorbrzezowski merged 2 commits into
mainfrom
openclaw/troca-para-opus-cai-no-runtime-sem-conta-abe866

Conversation

@vyctorbrzezowski

@vyctorbrzezowski vyctorbrzezowski commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Related: #180830 (same-model runtime re-selection).

What Problem This Solves

When a chat already has a runtime selected and you switch to a model from another provider, the chat can keep using the old runtime. For example, an OpenClaw chat switched to Anthropic can try API credentials even when Claude CLI is configured, so the next message fails to start.

User Impact

Switching providers without choosing a runtime now uses the new model's configured route. Picking a runtime explicitly still honors that choice if it is available, and compatible selections stay in place for model changes within the same provider.

Why This Change Was Made

The shared model-selection rule clears an inherited runtime pin on a provider change before preparing the new route. The Gateway applies the rule before committing the patch, and command and SDK selections use it too. No config or schema change is needed.

Evidence

  • On the base, switching from OpenAI to Anthropic without specifying a runtime returned openclaw. With the fix, the Gateway replaces that pin with the configured claude-cli route. An explicit, available runtime still takes precedence. A compatible choice survives a model change within the same provider; an incompatible explicit choice leaves the previous selection intact.
  • On 9efeeb5b2a09, an isolated Gateway with real native catalogs switched providers using sessions.patch. The next chat.send did not specify a runtime and completed through Claude CLI. The reply matched in Gateway history, the native transcript, and the transport log. An external test reader reported the previous model after a later turn; repeated sessions.describe calls and fresh SQLite reads showed the new model and runtime.
  • 310 tests passed across seven focused suites: Gateway patch/mutations, model picker, chat directives/model selection, native runtime choice, and tool prefix stability. Type-aware lint (eight TypeScript files), formatting (nine files), and git diff --check passed. Independent review found no actionable source changes. No full UI end-to-end run was claimed.

🦞 Made with OpenClaw

@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Nov 23, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR clears an inherited session runtime pin when switching providers so the selected model uses its configured route.

Example: Switch from openai/gpt-5.6-sol with an openclaw runtime pin to anthropic/claude-sonnet-4-6 configured for claude-cli.

  • Before: The inherited openclaw pin wins and the next turn can require unavailable API credentials.
  • After: The model-only switch selects claude-cli; explicitly requesting openclaw still preserves that choice.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and no actionable code defect was found, but the required real-behavior and existing-state compatibility evidence is incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A provider switch can keep the old runtime and make the next message fail despite a working configured native route.
Reason: The maintainer-authored PR explicitly approves the narrower lifetime of inherited runtime pins and preserves explicit runtime selection.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this maintainer-authored draft open: the provider-switch change is coherent, remains absent from current main, and introduces no definite code defect found in review.

Priority: P2
Reviewed head: 9efeeb5b2a09bded54acb1c71f4cf665a86e71a7

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted Gateway or chat evidence of this head switching a pinned OpenAI session to configured Claude CLI and completing the next turn, including an explicit-runtime control and a latest-stable upgrade preserving existing session settings.
Agent review details

How this fits together

Chat directives, Gateway patches, and SDK selections resolve model and runtime intent before validating and persisting the session selection used by subsequent turns.

flowchart TD
  A[Chat directives] --> D[Runtime selection rule]
  B[Gateway model patch] --> D
  C[SDK model selection] --> D
  D --> E[Configured route preparation]
  E --> F[Session persistence]
  F --> G[Next agent turn]
Loading

Technical review

Best possible solution:

Keep provider-change handling in the existing shared resolver and prepare the configured route without the previous provider's inherited pin.

Do we have a high-confidence way to reproduce the issue?

Current-main source preserves an openclaw pin across an OpenAI-to-Anthropic switch because openclaw is universally compatible; the PR also reports a failing-base/passing-head handler reproduction, which was not rerun during this read-only review.

Is this the best way to solve the issue?

The patch is a focused implementation of the maintainer-approved policy: existing callers supply previous-provider context and route preparation consumes the cleared selection before resolving capabilities.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 90ed7ec5ff01.

Provenance checked

  • Inherited runtime-pin policy changes intended behavior with a stated reason (13d421c: Preserve compatible pins and consent while clearing incompatible inherited pins so model-only switches can proceed.)
  • Runtime preparation and account projection keeps the original intent (d9048fd: Prepare the selected route with its account context and validate runtime eligibility before persisting a selection.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +14, Tests +47, Docs 0. Total +61 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 29 15 +14
Tests 3 53 6 +47
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 83 22 +61

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: This addresses a bounded existing-chat routing failure when changing model providers.
  • add merge-risk: 🚨 compatibility: The maintainer-authored direction intentionally changes the public SDK's runtime unchanged behavior across providers, replacing a previously compatible persisted pin with configured routing.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This addresses a bounded existing-chat routing failure when changing model providers.
  • merge-risk: 🚨 compatibility: The maintainer-authored direction intentionally changes the public SDK's runtime unchanged behavior across providers, replacing a previously compatible persisted pin with configured routing.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 23, 2026, 2:18 AM ET / 07:18 UTC.

@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review November 24, 2026 05:21
@vyctorbrzezowski
vyctorbrzezowski merged commit 5434992 into main Nov 25, 2026
338 of 340 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the openclaw/troca-para-opus-cai-no-runtime-sem-conta-abe866 branch November 25, 2026 12:11
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…law#203973)

* fix: use the configured runtime when switching model providers

* fix: use the configured runtime when switching model providers

OpenClaw-Publication: e9c20c63-2537-49bc-8876-d2d068ff6baa
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
* fix: use the configured runtime when switching model providers

* fix: use the configured runtime when switching model providers

OpenClaw-Publication: e9c20c63-2537-49bc-8876-d2d068ff6baa
(cherry picked from commit 5434992)
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…chiving (#205026)

* fix(sessions): keep inactive chats eligible for cold storage after archiving

* test(sessions): align archive fixtures and identity baseline

* test(sessions): create a private cold backup restore target

(cherry picked from commit 81d69df)

Follow-ups: 7cb8975 fix: keep forked Claude chats separate after a Gateway crash (#208048) [separately ordered lane row]; ece7a74 improve(workboard): apply the Control UI glossary and style to Workboard copy [not selected for this narrow backport]; b616036 refactor(subagents): simplify ACP spawn relay ownership (#207023) [not selected for this narrow backport]; 93ca762 improve: reduce allocations when preparing session rows (#207109) [not selected for this narrow backport]; 9993328 refactor(subagents): simplify kill claim and ownership handling (#207025) [not selected for this narrow backport]; 97815bd refactor(subagents): consolidate registry cleanup and publication guards (#207064) [not selected for this narrow backport]; e94f799 refactor(subagents): centralize requester turn matching (#206584) [not selected for this narrow backport]; ea77ca3 refactor: report update failures from recorded runs (#206700) [not selected for this narrow backport]; 4d7e00b fix: let started participant runs and requests finish after an access change (#206747) [not selected for this narrow backport]; f89ae43 refactor(subagents): use cleanup and terminal owners in sweeps (#206533) [not selected for this narrow backport]; a882e0f fix(agents): preserve task answers when sessions are reused (#126263) [not selected for this narrow backport]; 81fc833 refactor(subagents): own dormant child Stop decisions (#206479) [not selected for this narrow backport]; 91d4912 fix(update): stop using foreign recovery records as admission (#206295) [not selected for this narrow backport]; be3c73e fix(subagents): finish claimed stops after session rotation (#206405) [not selected for this narrow backport]; ed8b883 fix(update): settle after plugins and share one completion summary (#205987) [not selected for this narrow backport]; 1de306e fix: pause interrupted shell turns when their result is unknown (#205859) [separately ordered lane row]; 16a6aa4 fix(memory): keep a child's memory audience after its parent resets (#205887) [not selected for this narrow backport]; 50a7368 feat: let agents snooze a conversation after replying [not selected for this narrow backport]; 40f3903 fix(ci): remove unused role and workflow exports (#205720) [not selected for this narrow backport]; e43debf refactor(state): migrate in place and remove copy-and-swap (#205165) [not selected for this narrow backport]; 8027293 refactor(plugins): plugin tools take the turn's owner bit; delete the requester-owner continuation (OA2 PR 6j) (#205483) [not selected for this narrow backport]; 13e2ec3 feat: let participants publish through the session's shared GitHub account (#204914) [not selected for this narrow backport]; 5434992 fix: use the configured runtime when switching model providers (#203973) [not selected for this narrow backport]; 5271519 fix(feishu): honor the filename override on sent attachments (#205287) [not selected for this narrow backport]; ca087d4 refactor(admission): drop the replay automationAdmin bit and the R7 source re-check (#205268) [not selected for this narrow backport]

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* fix: use the configured runtime when switching model providers

* fix: use the configured runtime when switching model providers

OpenClaw-Publication: e9c20c63-2537-49bc-8876-d2d068ff6baa

(cherry picked from commit 5434992)

Release adaptation: Pass the previous provider alongside the stable resolved model and preserve the stable admitted-operator fixture; keep explicit requests atomic across directives, session patch and picker. Initial gateway shard reported 39 failures (35 passed): the donor referenced an undefined previousModel binding on stable. Resolve it once using the stable fallback owner and rerun all selected shards unchanged.

Companion audit: PR #203973 is the selected owner change; no later follow-up is required for the selected scope.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant