mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix(copilot): eliminate redundant catalog fetch in api_mode resolution (#11008)
copilot_model_api_mode() called normalize_copilot_model_id() which fetched the GitHub model catalog via HTTP, then the secondary endpoint check fetched it again because the catalog was never passed through. Fix: fetch the catalog once at the top of copilot_model_api_mode() and pass it to normalize_copilot_model_id(). The secondary check then sees a non-None catalog and skips the redundant fetch. For a Claude model switch on Copilot this eliminates one 5-second- timeout HTTP call from the interactive /model path. Surfaced during review of PR #10533. Co-authored-by: kshitijk4poor <kshitijk4poor@users.noreply.github.com>
This commit is contained in:
@@ -1570,6 +1570,11 @@ def copilot_model_api_mode(
|
||||
primary signal. Falls back to the catalog's ``supported_endpoints``
|
||||
only for models not covered by the pattern check.
|
||||
"""
|
||||
# Fetch the catalog once so normalize + endpoint check share it
|
||||
# (avoids two redundant network calls for non-GPT-5 models).
|
||||
if catalog is None and api_key:
|
||||
catalog = fetch_github_model_catalog(api_key=api_key)
|
||||
|
||||
normalized = normalize_copilot_model_id(model_id, catalog=catalog, api_key=api_key)
|
||||
if not normalized:
|
||||
return "chat_completions"
|
||||
@@ -1579,9 +1584,6 @@ def copilot_model_api_mode(
|
||||
return "codex_responses"
|
||||
|
||||
# Secondary: check catalog for non-GPT-5 models (Claude via /v1/messages, etc.)
|
||||
if catalog is None and api_key:
|
||||
catalog = fetch_github_model_catalog(api_key=api_key)
|
||||
|
||||
if catalog:
|
||||
catalog_entry = next((item for item in catalog if item.get("id") == normalized), None)
|
||||
if isinstance(catalog_entry, dict):
|
||||
|
||||
Reference in New Issue
Block a user