Skip to content

fix(xiaomi): preserve Token Plan base URLs during auth recovery - #46700

Closed
teknium1 wants to merge 1 commit into
mainfrom
salvage/xiaomi-mimo-base-url-routing
Closed

fix(xiaomi): preserve Token Plan base URLs during auth recovery#46700
teknium1 wants to merge 1 commit into
mainfrom
salvage/xiaomi-mimo-base-url-routing

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Preserves configured Xiaomi MiMo Token Plan base URLs through auth add, credential rotation, and model switches. A valid Token Plan key should not get re-pinned from model.base_url back to the standard registry endpoint after pool recovery.

Changes

  • run_agent.py: keep the current configured base URL when a rotated pool entry only carries the provider registry default.
  • agent/agent_runtime_helpers.py: detach stale credential pools when /model switches to another provider.
  • hermes_cli/auth_commands.py: persist the active provider's model.base_url into manually added pool credentials.
  • plugins/model-providers/xiaomi: add current MiMo V2.5 fallback models without adding new user-facing env-var guidance.
  • Tests: add credential-swap, auth-add, and Xiaomi fallback-model coverage.

Salvaged from

Validation

Check Result
scripts/run_tests.sh tests/run_agent/test_44070_credential_swap_base_url.py tests/hermes_cli/test_auth_commands.py tests/hermes_cli/test_xiaomi_provider.py tests/hermes_cli/test_model_switch_opencode_anthropic.py 125 passed
E2E import/probe for credential rotation preserving Xiaomi Token Plan base URL passed
python3 -m py_compile run_agent.py agent/agent_runtime_helpers.py hermes_cli/auth_commands.py plugins/model-providers/xiaomi/__init__.py tests/run_agent/test_44070_credential_swap_base_url.py tests/hermes_cli/test_auth_commands.py tests/hermes_cli/test_xiaomi_provider.py scripts/release.py passed
git diff --check passed

Infographic

Hermes Agent Base URL Routing

Salvages Xiaomi MiMo base-url routing fixes from #44099/#33648/#42699 while keeping base-url configuration in config.yaml rather than expanding env-var guidance.

Co-authored-by: AIalliAI <285906080+AIalliAI@users.noreply.github.com>

Co-authored-by: Jim Dawdy <262052366+jimdawdy-hub@users.noreply.github.com>

Co-authored-by: mlaihk <25972362+mlaihk@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: salvage/xiaomi-mimo-base-url-routing vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 10929 on HEAD, 10929 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5757 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard provider/xiaomi Xiaomi MiLM P2 Medium — degraded but workaround exists labels Jun 15, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor

Code Review: Token Plan base URL preservation across credential rotation

The core fix — _pool_entry_swap_base_url() in run_agent.py — correctly handles the scenario where a credential pool entry carries the provider's registry-default URL while the runtime has been resolved to a non-default endpoint (e.g., Xiaomi Token Plan hosts). The logic:

  1. If the entry has no runtime_base_url or base_url → keep current URL (safe fallback)
  2. If the entry's URL matches the provider registry default AND the current URL differs → keep current URL (prevents Token Plan downgrade)
  3. Otherwise → adopt the entry's URL (normal rotation)

This is conservative and correct. The auth_commands.py change to inherit model.base_url from config when adding manual credentials for the active provider is complementary — it ensures hermes auth add xiaomi stores the Token Plan URL, not the registry default.

The switch_model change to drop the credential pool when switching providers prevents cross-provider rotation bugs. Test coverage is comprehensive across both the auth-commands and runtime-provider-resolution test files.

No issues found.

@teknium1

Copy link
Copy Markdown
Contributor Author

Closing this salvage PR as wrong-premise for this batch.

It addresses a different Xiaomi Token Plan/base-url preservation problem, not the reported Nous endpoint failure for xiaomi/mimo-v2.5-pro. The screenshot that triggered this batch is already using provider nous and https://inference-api.nousresearch.com/v1; preserving direct Xiaomi Token Plan base URLs would not explain or fix that failure.

Parts of this may be valid for the separate #44070-style base-url bug, but it needs its own focused review and reproduction, not inclusion in this MiMo/NouS provider-error cluster.

Thanks to the original contributors whose fixes were credited here; this consolidation was our mistake.

@teknium1 teknium1 closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/xiaomi Xiaomi MiLM type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants