fix: honor configured base URL for manual auth - #33648
Conversation
|
This PR was implemented using AI Assistance (GPT5.5) and a puny human brain. |
|
@teknium1 Friendly ping — this has been open ~2 weeks with no review yet. Small, targeted auth fix with regression tests. Problem: Fix: Tests: Scope: 2 files, no workflow/infra changes. PR body includes repro transcript (redacted key). If someone else owns CLI/auth review, happy to retag — just trying to get eyes on it. Thanks! |
|
Closing this out based on #46700 handles the issue more comprehensivly. |
|
Thanks for the focused fix. The relevant defect remains on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
The PR added coverage for the matching same-provider case (Xiaomi Token Plan) but not the fallback branch it claims. The existing OpenRouter test configures no foreign model.base_url, so `configured_provider != provider` with a non-empty foreign base URL was never exercised. Add a test that configures Xiaomi's Token Plan URL as the active endpoint, adds an Anthropic manual key, and asserts the Anthropic entry does not inherit Xiaomi's URL — locking in the "narrow fix" guarantee. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HwjmsvrgARzuAucSNE4aXA
Fixed in 9eee0e3. Added This locks in the "narrow fix" guarantee: it passes today, and would fail if the same-provider predicate were ever broadened to leak a foreign provider's URL. The Xiaomi test remains the red→green proof of the fix itself. |
Summary
Fixes manual API-key auth so
hermes auth add <provider>honors the activemodel.base_urlwhen the credential is for the same configured provider.This matters for providers with multiple OpenAI-compatible endpoints behind the same provider/key shape. Xiaomi MiMo is the real-world case here: a valid Token Plan key must be used against
https://token-plan-ams.xiaomimimo.com/v1, but manual auth could persist the registry default endpoint instead. After restart/subagent use, Hermes could treat the same valid Xiaomi key as missing/failed because runtime credential resolution was pointed at the wrong host.What changed
hermes_cli/auth_commands.py_provider_base_url()now checks the activemodel.providerandmodel.base_url.tests/hermes_cli/test_auth_commands.pyReal-world incident evidence
The excerpts below are copied from the reporter's chat transcript (
mimotoken). One literal API key appeared in the raw transcript; it is intentionally redacted here.1) Xiaomi auth failed mid-session
Note: after this Xiaomi failure, the reporter switched the session to GPT-5.5 / OpenAI Codex to continue debugging and preserve the Xiaomi/OpenAI privacy boundary.
2) Investigation showed a stored credential existed, but Hermes treated it as failed
3) Re-auth restored Xiaomi, proving the key/provider worked
4) Manual Xiaomi calls succeeded after re-auth
5) The failure reproduced in a child/subagent path
Patch verification
Code-level regression test
Why this fix is narrow
The change only prefers
model.base_urlwhen all of these are true:model.providernormalizes to that same provider; andmodel.base_urlis non-empty.Otherwise the existing registry base URL behavior is preserved.
Test plan
uv run --python /Users/jimdawdy/.local/bin/python3.11 python -m pytest tests/hermes_cli/test_auth_commands.py -q -o 'addopts='