mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
fix(aux): preserve provider identity for resolved endpoints
_resolve_task_provider_model() flattened any explicit base_url to provider=custom. Correct for bare/custom endpoints, but wrong for provider-backed routes (anthropic, qwen-oauth, minimax-oauth, openai-codex, etc.) whose provider branch adds auth refresh, transport, or request shaping. MoA reference slots resolved through those providers lost their identity before the aux call, so e.g. a Codex reference hit chatgpt.com/backend-api/codex without its Cloudflare headers and got HTML back (surfacing as a spurious rate-limit). Keep first-class providers intact when paired with a resolved base_url via _preserve_provider_with_base_url(); bare/custom/auto/unknown and the direct openai alias still route through custom. Co-authored-by: Hermes Agent <127238744+teknium1@users.noreply.github.com>
This commit is contained in:
parent
1cae1bd0de
commit
a8841e2a68
3 changed files with 131 additions and 3 deletions
|
|
@ -5238,9 +5238,10 @@ def _resolve_task_provider_model(
|
|||
3. "auto" (full auto-detection chain)
|
||||
|
||||
Returns (provider, model, base_url, api_key, api_mode) where model may
|
||||
be None (use provider default). When base_url is set, provider is forced
|
||||
to "custom" and the task uses that direct endpoint. api_mode is one of
|
||||
"chat_completions", "codex_responses", or None (auto-detect).
|
||||
be None (use provider default). A bare base_url is treated as custom, but
|
||||
a first-class provider plus base_url keeps the provider identity so its
|
||||
auth, transport, and request-shaping behavior still apply. api_mode is one
|
||||
of "chat_completions", "codex_responses", or None (auto-detect).
|
||||
"""
|
||||
cfg_provider = None
|
||||
cfg_model = None
|
||||
|
|
@ -5273,11 +5274,35 @@ def _resolve_task_provider_model(
|
|||
return prov, existing_base
|
||||
return "custom", existing_base or target_base
|
||||
|
||||
def _preserve_provider_with_base_url(prov: Optional[str]) -> bool:
|
||||
normalized = str(prov or "").strip().lower()
|
||||
if normalized in {"", "auto", "custom"} or normalized.startswith("custom:"):
|
||||
return False
|
||||
try:
|
||||
from hermes_cli.providers import get_provider
|
||||
|
||||
return get_provider(normalized) is not None
|
||||
except Exception:
|
||||
# Keep the high-risk provider-backed routes safe even if provider
|
||||
# catalog loading is unavailable during early import/test paths.
|
||||
return normalized in {
|
||||
"anthropic",
|
||||
"copilot",
|
||||
"copilot-acp",
|
||||
"minimax-oauth",
|
||||
"nous",
|
||||
"openai-codex",
|
||||
"qwen-oauth",
|
||||
"xai-oauth",
|
||||
}
|
||||
|
||||
if provider:
|
||||
provider, base_url = _expand_direct_api_alias(provider, base_url)
|
||||
if cfg_provider:
|
||||
cfg_provider, cfg_base_url = _expand_direct_api_alias(cfg_provider, cfg_base_url)
|
||||
|
||||
if base_url and _preserve_provider_with_base_url(provider):
|
||||
return provider, resolved_model, base_url, api_key, resolved_api_mode
|
||||
if base_url:
|
||||
return "custom", resolved_model, base_url, api_key, resolved_api_mode
|
||||
if provider:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue