Skip to content

fix: strip provider prefix from model name for direct API providers#6224

Open
MumuTW wants to merge 3 commits into
NousResearch:mainfrom
MumuTW:fix/strip-provider-prefix-from-model
Open

fix: strip provider prefix from model name for direct API providers#6224
MumuTW wants to merge 3 commits into
NousResearch:mainfrom
MumuTW:fix/strip-provider-prefix-from-model

Conversation

@MumuTW

@MumuTW MumuTW commented Apr 8, 2026

Copy link
Copy Markdown

Summary

  • Add defensive prefix stripping for model names when routing to direct API providers
  • Complements the existing guardrail in auth.py:2238 (which only covers the hermes model CLI flow) by also protecting the runtime API call path
  • Only affects users who manually edit config.yaml with prefixed model names

Changes

  • run_agent.py: Strip provider/ prefix after client initialization when not using OpenRouter
  • agent/auxiliary_client.py: Same for the API-key provider resolution path
  • Tests: 11 new tests covering prefix stripping, OpenRouter preservation, and passthrough

Test plan

  • 11 new tests pass
  • 398 existing tests pass with no regressions
  • Manual verification on production deployment

Fixes #6211

MumuTW added 3 commits April 9, 2026 01:55
When model.default is set to "zai/glm-5.1" in config.yaml, the "zai/"
prefix was passed directly to the Z.AI API, causing HTTP 400 errors.
Only OpenRouter natively accepts the "provider/model" format; all other
direct providers (Z.AI, Google, Kimi, MiniMax, DeepSeek, etc.) require
bare model IDs.

- Strip prefix in run_agent.py after client initialization (affects all
  API calls from the main agent loop)
- Strip prefix in auxiliary_client.py for the API-key provider path
- Add comprehensive tests for both code paths

Fixes NousResearch#6211
Keep only the single meaningful test case that exercises the actual
code path changed in auxiliary_client.py.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Z.AI provider prefix not stripped from model name, causing HTTP 400

2 participants