Skip to content

fix(model): normalize native provider-prefixed model ids - #6943

Closed
bobashopcashier wants to merge 3 commits into
NousResearch:mainfrom
bobashopcashier:fix/6211-model-normalize-native-prefixes
Closed

fix(model): normalize native provider-prefixed model ids#6943
bobashopcashier wants to merge 3 commits into
NousResearch:mainfrom
bobashopcashier:fix/6211-model-normalize-native-prefixes

Conversation

@bobashopcashier

@bobashopcashier bobashopcashier commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Normalizes native provider-prefixed model IDs only when the prefix matches the active Hermes provider, and applies that same rule everywhere Hermes can send a direct-provider model unchanged: CLI startup, AIAgent runtime initialization, fallback activation, and auxiliary routing (including vision/main-provider resolution).

Related Issue

Fixes #6211
Supersedes the narrower direct-provider overlap in #6224 by covering both main runtime and auxiliary routing with the same active-provider-only rule
Related: #6242
Context: #5910 is already fixed separately in the current codebase
Separate env/pairing hardening is tracked in PR #6956

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • kept hermes_cli/model_normalize.py as the shared normalization source for active-provider-only prefix stripping
  • applied the same normalization outcome in direct auxiliary provider routing so resolve_provider_client() returns the provider-native model slug it will actually send
  • updated fallback activation in run_agent.py to consume the resolved normalized model instead of keeping the raw prefixed config value
  • added focused regression coverage for matching-provider stripping, non-matching prefix passthrough, aggregator preservation, vision/main-provider routing, and fallback activation

How to Test

  1. Run /Users/kennyxie/Documents/Code/clawspace/hermes-agent/.venv/bin/python -m pytest tests/hermes_cli/test_model_normalize.py -q
  2. Run /Users/kennyxie/Documents/Code/clawspace/hermes-agent/.venv/bin/python -m pytest tests/agent/test_auxiliary_named_custom_providers.py -q
  3. Run /Users/kennyxie/Documents/Code/clawspace/hermes-agent/.venv/bin/python -m pytest tests/run_agent/test_run_agent.py::TestProviderModelNormalization tests/run_agent/test_fallback_model.py::TestTryActivateFallback -q
  4. Configure a direct provider with a matching prefixed model like zai/glm-5.1 and verify Hermes sends the native slug glm-5.1
  5. Verify unrelated slash-bearing IDs such as aggregator slugs or non-matching prefixes remain unchanged

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 26.4

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

  • /Users/kennyxie/Documents/Code/clawspace/hermes-agent/.venv/bin/python -m pytest tests/hermes_cli/test_model_normalize.py tests/agent/test_auxiliary_named_custom_providers.py tests/run_agent/test_run_agent.py::TestProviderModelNormalization tests/run_agent/test_fallback_model.py::TestTryActivateFallback -q67 passed

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #7187. All 3 commits cherry-picked with your authorship preserved. Thorough fix for the prefix normalization — thanks!

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

Labels

None yet

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