fix(providers): pin all Actual routes to chat completions (E-1047)
This commit is contained in:
+8
-1
@@ -372,8 +372,9 @@ _EXPLICIT_API_MODES = {
|
||||
|
||||
def _resolve_api_mode(agent, api_mode, provider_name, base_url):
|
||||
"""Set ``agent.api_mode`` (and provider rewrites) — ordered ladder, first match wins."""
|
||||
from hermes_cli.providers import is_actual_route
|
||||
host, url = agent._base_url_hostname, agent._base_url_lower
|
||||
if agent.provider == "actual":
|
||||
if is_actual_route(agent.provider, base_url):
|
||||
agent.api_mode = "chat_completions"
|
||||
elif api_mode in _EXPLICIT_API_MODES:
|
||||
agent.api_mode = api_mode
|
||||
@@ -418,6 +419,7 @@ def _resolve_api_mode(agent, api_mode, provider_name, base_url):
|
||||
|
||||
|
||||
def _finalize_routing(agent, api_mode, credential_pool):
|
||||
from hermes_cli.providers import is_actual_route
|
||||
# Credential-pool validation runs AFTER provider auto-detection so a pool scoped to
|
||||
# "anthropic" isn't rejected for provider=None + anthropic.com URL.
|
||||
# Regression from #63048 which placed this check before the URL-based auto-detection block above (fixed
|
||||
@@ -470,6 +472,7 @@ def _finalize_routing(agent, api_mode, credential_pool):
|
||||
# upgrade for Azure (openai.azure.com), even though it looks OpenAI-compatible.
|
||||
api_mode is None
|
||||
and agent.api_mode == "chat_completions"
|
||||
and not is_actual_route(agent.provider, agent.base_url)
|
||||
and agent.provider != "copilot-acp"
|
||||
and not _base_lower.startswith(("acp://", "acp+tcp://"))
|
||||
and not agent._is_azure_openai_url()
|
||||
@@ -2243,6 +2246,10 @@ def init_agent(
|
||||
agent.skip_background_review = bool(skip_background_review)
|
||||
agent.log_prefix = f"{log_prefix} " if log_prefix else ""
|
||||
# Effective base URL for feature detection (prompt caching, reasoning, etc.)
|
||||
from hermes_cli.providers import is_actual_route
|
||||
if is_actual_route(provider, base_url):
|
||||
from hermes_cli.auth import normalize_actual_base_url
|
||||
base_url = normalize_actual_base_url(base_url)
|
||||
agent.base_url = base_url or ""
|
||||
provider_name = provider.strip().lower() if isinstance(provider, str) and provider.strip() else None
|
||||
agent.provider = provider_name or ""
|
||||
|
||||
Reference in New Issue
Block a user