Follow-up to the #103857 salvage. The Copilot provider profile and the main-agent GitHub reasoning path each carried the same clamp-then-medium fallback. Both now call hermes_cli.models.clamp_github_reasoning_effort. The offline Astra tests move next to the other Copilot effort tests, along with a check that a structured catalog entry still wins. The main-agent clamp now has a test pinning max/ultra -> high on the GPT-5 ladder. The transport test no longer writes config.yaml. The two effort comments now say the same thing.
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""Copilot / GitHub Models provider profile.
|
|
|
|
Core routes GPT-5+/Codex -> codex_responses and Claude -> anthropic_messages;
|
|
this profile covers the chat_completions remainder: editor attribution headers
|
|
(copilot_default_headers()) and catalog-gated GitHub Models reasoning.
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
from providers import register_provider
|
|
from providers.base import ProviderProfile
|
|
|
|
|
|
class CopilotProfile(ProviderProfile):
|
|
"""GitHub Copilot / GitHub Models — editor headers + reasoning."""
|
|
|
|
def build_api_kwargs_extras(
|
|
self, *, model: str | None = None, reasoning_config: dict | None = None,
|
|
supports_reasoning: bool = False, **ctx,
|
|
) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
if not (supports_reasoning and model):
|
|
return {}, {}
|
|
try:
|
|
from hermes_cli.models import clamp_github_reasoning_effort, github_model_reasoning_efforts
|
|
|
|
supported = github_model_reasoning_efforts(model)
|
|
if not supported:
|
|
return {}, {}
|
|
if not reasoning_config:
|
|
return {"reasoning": {"effort": "medium"}}, {}
|
|
# Never drop straight to medium, which inverted the ladder (ultra < high). See #74295.
|
|
effort = clamp_github_reasoning_effort(reasoning_config.get("effort"), supported)
|
|
return {"reasoning": {"effort": effort}}, {}
|
|
except Exception:
|
|
return {}, {}
|
|
|
|
|
|
copilot = CopilotProfile(
|
|
name="copilot", aliases=("github-copilot", "github-models", "github-model", "github"),
|
|
env_vars=("COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"), base_url="https://api.githubcopilot.com",
|
|
auth_type="copilot",
|
|
)
|
|
|
|
register_provider(copilot)
|