mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-08 13:12:08 +00:00
fix(copilot): recognize enterprise subdomains in host checks
The earlier enterprise base URL change (proxy-ep parsing) gave us URLs
like `api.enterprise.githubcopilot.com`, but ~15 host-matching call
sites still hard-coded `api.githubcopilot.com`. Enterprise users would
therefore drop the `Copilot-Integration-Id: vscode-chat` header at
client-build time, and upstream rejected requests with:
The requested model is not available for integrator "zed"
(or "copilot-language-server") — verify the correct
Copilot-Integration-Id header is being sent.
The header was correct in copilot_default_headers(); it just never
made it into default_headers for non-default hostnames because every
detector compared against the exact string "api.githubcopilot.com".
This commit broadens all those checks to "githubcopilot.com" via
base_url_host_matches (which already does proper subdomain matching),
so api.enterprise.githubcopilot.com, api.business.githubcopilot.com,
etc. all share the same headers, vision routing, max_completion_tokens
selection, and reasoning-effort detection as the default endpoint.
Also adds ".githubcopilot.com" to _URL_TO_PROVIDER so context-window
resolution via models.dev works for enterprise base URLs, and tightens
_is_github_copilot_url to use suffix matching instead of strict equality.
Tests:
- New: enterprise Copilot endpoint preserves Copilot-Integration-Id
- New: enterprise endpoint returns max_completion_tokens (not max_tokens)
- Existing 333 base_url / copilot / aux-client / credential-pool tests pass
Parts 5 of #7731.
This commit is contained in:
parent
fbd15e285c
commit
fb07215844
7 changed files with 60 additions and 14 deletions
10
run_agent.py
10
run_agent.py
|
|
@ -1133,7 +1133,9 @@ class AIAgent:
|
|||
hostname = getattr(self, "_base_url_hostname", "") or base_url_hostname(
|
||||
getattr(self, "_base_url_lower", "")
|
||||
)
|
||||
return hostname == "api.githubcopilot.com"
|
||||
if not hostname:
|
||||
return False
|
||||
return hostname == "api.githubcopilot.com" or hostname.endswith(".githubcopilot.com")
|
||||
|
||||
def _resolved_api_call_timeout(self) -> float:
|
||||
"""Resolve the effective per-call request timeout in seconds.
|
||||
|
|
@ -3837,7 +3839,7 @@ class AIAgent:
|
|||
# unaffected (they don't go through here).
|
||||
request_kwargs["max_retries"] = 0
|
||||
if (
|
||||
base_url_host_matches(str(request_kwargs.get("base_url", "")), "api.githubcopilot.com")
|
||||
base_url_host_matches(str(request_kwargs.get("base_url", "")), "githubcopilot.com")
|
||||
and self._api_kwargs_have_image_parts(api_kwargs or {})
|
||||
):
|
||||
request_kwargs["default_headers"] = self._copilot_headers_for_request(is_vision=True)
|
||||
|
|
@ -4099,7 +4101,7 @@ class AIAgent:
|
|||
self._client_kwargs["default_headers"] = build_nvidia_nim_headers(base_url)
|
||||
elif base_url_host_matches(base_url, "api.routermint.com"):
|
||||
self._client_kwargs["default_headers"] = _routermint_headers()
|
||||
elif base_url_host_matches(base_url, "api.githubcopilot.com"):
|
||||
elif base_url_host_matches(base_url, "githubcopilot.com"):
|
||||
from hermes_cli.models import copilot_default_headers
|
||||
|
||||
self._client_kwargs["default_headers"] = copilot_default_headers()
|
||||
|
|
@ -4995,7 +4997,7 @@ class AIAgent:
|
|||
return True
|
||||
if (
|
||||
base_url_host_matches(self._base_url_lower, "models.github.ai")
|
||||
or base_url_host_matches(self._base_url_lower, "api.githubcopilot.com")
|
||||
or base_url_host_matches(self._base_url_lower, "githubcopilot.com")
|
||||
):
|
||||
try:
|
||||
from hermes_cli.models import github_model_reasoning_efforts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue