Skip to content

fix(models): resolve provider-qualified aliases in session switches#75198

Closed
sahilsatralkar wants to merge 1 commit into
openclaw:mainfrom
sahilsatralkar:fix/issue-75163-model-alias-resolution
Closed

fix(models): resolve provider-qualified aliases in session switches#75198
sahilsatralkar wants to merge 1 commit into
openclaw:mainfrom
sahilsatralkar:fix/issue-75163-model-alias-resolution

Conversation

@sahilsatralkar

Copy link
Copy Markdown
Contributor

Summary

Describe the problem and fix in 2–5 bullets:

If this PR fixes a plugin beta-release blocker, title it fix(<plugin-id>): beta blocker - <summary> and link the matching Beta blocker: <plugin-name> - <summary> issue labeled beta-blocker. Contributors cannot label PRs, so the title is the PR-side signal for maintainers and automation.

  • Problem: Control UI/TUI session model switching could pass a provider-qualified display alias like lmstudio-moe/MoE through sessions.patch, which let the provider receive MoE instead of the canonical local model id.
  • Why it matters: LM Studio and other local providers reject display aliases as invalid model identifiers, breaking user-selected mid-session model switches.
  • What changed: Shared model selection now resolves provider/Alias through the configured alias index when the provider matches the alias target, before existing allowlist/catalog validation and persistence.
  • What did NOT change (scope boundary): No fallback behavior, provider-specific LM Studio logic, Telegram behavior, or broad Control UI state handling changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write N/A. If the cause is unclear, write Unknown.

  • Root cause: resolveModelRefFromString resolved aliases only when the entire raw model string matched a configured alias. Bare MoE resolved, but lmstudio-moe/MoE was parsed as provider lmstudio-moe and model MoE.
  • Missing detection / guardrail: Existing tests covered bare aliases and slash-form aliases, but not provider-qualified display aliases emitted by session/model selection paths.
  • Contributing context (if known): Control UI/TUI session state can combine a server-reported model alias with its provider into provider/Alias, then send that value through sessions.patch.

Regression Test Plan (if applicable)

For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write N/A.

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
    • Target test or file: src/agents/model-selection.test.ts, src/gateway/sessions- patch.test.ts
    • Scenario the test should lock in: lmstudio-moe/MoE resolves and persists as lmstudio-moe/ qwen3.6-35b-a3b when MoE is configured as that model’s alias.
    • Why this is the smallest reliable guardrail: The resolver test locks the shared canonicalization rule; the Gateway patch test proves the user session persistence boundary stores the canonical override.
    • Existing test that already covers this (if any): Existing tests covered bare aliases and explicit provider/model refs, but not provider-qualified aliases.
    • If no new test is added, why not: N/A

User-visible / Behavior Changes

Users can switch to configured aliased local/provider models from Control UI/TUI without the provider receiving the display alias as the model id.

Diagram (if applicable)

For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write N/A.

  Before:
  [model switch: lmstudio-moe/MoE] -> [sessions.patch stores/parses MoE as model] -> [provider
  rejects invalid model id]

  After:
  [model switch: lmstudio-moe/MoE] -> [shared alias resolver maps to qwen3.6-35b-a3b] ->
  [sessions.patch persists canonical override]

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS local dev environment
  • Runtime/container: Node/pnpm workspace
  • Model/provider: LM Studio-style local provider alias (lmstudio-moe/MoE) covered by regression tests
  • Integration/channel (if any): Control UI/TUI session model switching via sessions.patch
  • Relevant config (redacted): agents.defaults.models["lmstudio-moe/qwen3.6-35b-a3b"].alias = "MoE"

Steps

  1. Configure an allowed model with alias MoE for canonical ref lmstudio-moe/qwen3.6-35b-a3b.
  2. Send sessions.patch with model lmstudio-moe/MoE.
  3. Inspect the persisted session override.

Expected

  • Session override persists provider lmstudio-moe and model qwen3.6-35b-a3b.

Actual

  • Before this PR, lmstudio-moe/MoE was treated as direct model MoE, causing an invalid model identifier path.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • pnpm test src/agents/model-selection.test.ts
    • pnpm test src/gateway/sessions-patch.test.ts
    • pnpm test src/agents/model-selection.test.ts src/gateway/sessions-patch.test.ts ui/src/ui/
      chat-model-ref.test.ts ui/src/ui/chat-model-select-state.test.ts ui/src/ui/views/
      chat.test.ts
    • pnpm exec oxfmt --check --threads=1 src/agents/model-selection-shared.ts src/agents/model-selection.test.ts src/gateway/sessions-patch.test.ts ui/src/ui/chat-model-ref.ts ui/src/ui/chat-model-ref.test.ts ui/src/ui/chat-model-select-state.test.ts
    • pnpm build
    • git diff --check
    • pnpm dlx codex review --base origin/main
  • Edge cases checked: Existing slash-form alias coverage still passes; explicit allowlisted provider/model refs still pass; provider-qualified alias only resolves when the provider matches the alias target.
  • What you did not verify: Live LM Studio server behavior; Testbox pnpm check:changed was blocked because Blacksmith CLI was not authenticated and no BLACKSMITH_ORG was configured.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk: A provider/Alias string could be mistaken for a real provider/model ref.
    • Mitigation: The new resolution only applies when the suffix matches a configured alias and the prefix provider matches the alias target provider; otherwise existing parsing and allowlist validation are preserved.

Built with Codex

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S labels Apr 30, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open. The PR targets a valid sessions.patch alias bug, but it is not merge-ready because the new provider-qualified lookup still depends on a single global alias entry, real behavior proof is only test-based, and the branch is currently conflicting.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #75163
Summary: This PR is the open candidate fix for the canonical Control UI/TUI sessions.patch alias canonicalization bug, but it is not merge-ready.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

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

Yes, at source level. Current main routes sessions.patch model updates through resolveAllowedModelRef, and the shared resolver does not canonicalize provider/Alias before provider/model parsing while the linked issue supplies matching invalid-model logs.

Is this the best way to solve the issue?

No as submitted. Shared server-side canonicalization is the right layer, but the implementation needs provider-scoped duplicate-safe alias matching, a clean rebase without the changelog edit, and real setup proof before merge.

Security review:

Security review cleared: No concrete security or supply-chain concern was found; the diff is limited to model resolution logic, tests, and a changelog entry.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-30T17:58:22Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is mock_only and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: Peter Steinberger extracted shared model-selection helpers and refactored allowlist parsing around the resolver boundary used by this PR. (role: feature-history contributor; confidence: high; commits: 310d2db31241, 3eed32108187; files: src/agents/model-selection-shared.ts, src/agents/model-selection.ts)
  • vincentkoc: Vincent Koc authored adjacent model-selection and OpenRouter compatibility alias work in the same resolver family. (role: recent area contributor; confidence: medium; commits: d13869aab94d, 117ae85bf5c7; files: src/agents/model-selection.ts, src/agents/model-selection.test.ts)
  • steipete: Peter Steinberger repeatedly touched sessions.patch model/session override handling, including the recent redundant conversion cleanup on the same persistence boundary. (role: adjacent session-patch contributor; confidence: medium; commits: cb3fbe7e50a2, b3ecabbbb722; files: src/gateway/sessions-patch.ts)
  • Mulualem Eshetu: Mulualem Eshetu worked on preserving configured model metadata in the picker, which is adjacent to the UI side of provider-qualified model selection. (role: adjacent Control UI contributor; confidence: medium; commits: 4977c4ab8221; files: ui/src/ui/chat-model-ref.ts, ui/src/ui/chat-model-select-state.ts, src/gateway/session-utils.ts)

Codex review notes: model internal, reasoning high; reviewed against 6cb82eaab865.

@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label May 30, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed stale Marked as stale due to inactivity labels May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jun 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: TUI mid-session model switch passes raw alias instead of resolved model ID

1 participant