Skip to content

fix: strip provider prefix from model name in /model command#8059

Open
tomqiaozc wants to merge 1 commit into
NousResearch:mainfrom
tomqiaozc:fix/model-switch-strip-provider-prefix
Open

fix: strip provider prefix from model name in /model command#8059
tomqiaozc wants to merge 1 commit into
NousResearch:mainfrom
tomqiaozc:fix/model-switch-strip-provider-prefix

Conversation

@tomqiaozc

Copy link
Copy Markdown

Summary

  • When switching to a non-curated model via /model zai/glm-5.1, the zai/ prefix was stored verbatim in the session override, causing the provider API to reject it with HTTP 400 ("Unknown Model"). This happened because detect_provider_for_model() returned None for models not in the curated list, so normalize_model_for_provider() didn't know which prefix to strip.
  • Adds a fallback check before normalization: if the model contains a / prefix matching a known provider (via _PROVIDER_MODELS or _PROVIDER_ALIASES), extract it as the target provider and strip the prefix. Skips this for aggregator providers (OpenRouter etc.) where vendor/model is the expected slug format.
  • Updates the stale Z.AI curated model list with glm-5.1, glm-4.6, and glm-4.5-air.

Fixes #7922

Test plan

  • test_switch_model_strips_provider_prefix_for_unlisted_model — verifies zai/glm-5.1 becomes glm-5.1 with provider zai
  • All model switch tests: 4/4 passed
  • All model normalize tests: 23/23 passed
  • All variant tag preservation tests: 12/12 passed (no regression for aggregator slugs)

🤖 Generated with Claude Code

When switching to a non-curated model via /model provider/name, the
provider prefix was stored verbatim in the session override, causing
HTTP 400 from the provider API. Extract and strip the prefix when it
matches a known provider (non-aggregator only, since aggregators use
vendor/model as the expected slug format).

Also update the stale zai curated model list with glm-5.1, glm-4.6,
and glm-4.5-air.

Fixes NousResearch#7922

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets provider/zai ZAI provider labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #6211 — same root cause (Z.AI provider prefix not stripped). This PR adds the fallback stripping logic for unlisted models.

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

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists provider/zai ZAI provider type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway /model command sends provider-prefixed slug as raw model name for non-curated models (HTTP 400 Unknown Model)

2 participants