Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions agent/auxiliary_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2960,6 +2960,7 @@ def _wrap_if_needed(client_obj, final_model_str: str, base_url_str: str = "",
PROVIDER_REGISTRY,
resolve_api_key_provider_credentials,
resolve_external_process_provider_credentials,
resolve_minimax_oauth_runtime_credentials,
)
except ImportError:
logger.debug("hermes_cli.auth not available for provider %s", provider)
Expand All @@ -2970,7 +2971,7 @@ def _wrap_if_needed(client_obj, final_model_str: str, base_url_str: str = "",
logger.warning("resolve_provider_client: unknown provider %r", provider)
return None, None

if pconfig.auth_type == "api_key":
if pconfig.auth_type in {"api_key", "oauth_minimax"}:
if provider == "anthropic":
client, default_model = _try_anthropic(explicit_api_key=explicit_api_key)
if client is None:
Expand All @@ -2979,7 +2980,10 @@ def _wrap_if_needed(client_obj, final_model_str: str, base_url_str: str = "",
final_model = _normalize_resolved_model(model or default_model, provider)
return (_to_async_client(client, final_model, is_vision=is_vision) if async_mode else (client, final_model))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve MiniMax credentials with as_token_provider=True and preserve the resulting callable rather than flowing it into the following str(...) coercion. Current hermes_cli/auth.py:7759-7791 documents that this is required to refresh MiniMax's short-lived OAuth access token per request.


creds = resolve_api_key_provider_credentials(provider)
if pconfig.auth_type == "oauth_minimax":
creds = resolve_minimax_oauth_runtime_credentials()
else:
creds = resolve_api_key_provider_credentials(provider)
api_key = str(creds.get("api_key", "")).strip()
# Honour an explicit api_key override (e.g. from a fallback_model entry
# or a custom_providers entry) so callers that pass an explicit
Expand Down
19 changes: 19 additions & 0 deletions tests/agent/test_auxiliary_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,25 @@ def test_resolve_provider_client_passes_explicit_api_key_to_anthropic(self):
"resolve_provider_client must forward explicit_api_key to _try_anthropic()"
)

def test_resolve_provider_client_supports_minimax_oauth(self):
"""MiniMax OAuth should resolve via its runtime credential helper."""
fake_client = MagicMock()
with patch(
"hermes_cli.auth.resolve_minimax_oauth_runtime_credentials",
return_value={
"provider": "minimax-oauth",
"api_key": "oauth-token",
"base_url": "https://api.minimax.io/anthropic",
"source": "oauth",
},
), patch("agent.auxiliary_client.OpenAI", return_value=fake_client) as mock_openai:
client, model = resolve_provider_client("minimax-oauth")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid asserting a provider-default model literal here: current minimax-oauth declares MiniMax-M2.7 at plugins/model-providers/minimax/__init__.py:82-93. Pass an explicit model and assert the OAuth callable reaches the current Anthropic transport path instead.

assert client is not None
assert model == "MiniMax-M2.7-highspeed"
assert mock_openai.call_args.kwargs["api_key"] == "oauth-token"
assert mock_openai.call_args.kwargs["base_url"] == "https://api.minimax.io/v1"


# ── Auxiliary unhealthy-provider TTL cache (issue #23570) ────────────────

Expand Down
Loading