Skip to content

The agent that grows with you

Merge copilot-seams/l3 into integration

Tekniumcce1efe34650
diff --cc plugins/model-providers/copilot/__init__.py
index 3e50eb19623,96e9ee9dfa9..198f2240b4d
--- a/plugins/model-providers/copilot/__init__.py
+++ b/plugins/model-providers/copilot/__init__.py
@@@ -10,12 -10,10 +10,13 @@@ from typing import An
from providers import register_provider
from providers.base import ProviderProfile
+from .catalog import HOSTNAMES, METADATA_HOSTNAMES, MODELS_DEV_ID, CopilotCatalogMixin
+from .credentials import CopilotCredentialsMixin
+ from .responses import RESPONSES_PROFILE_FIELDS, CopilotResponsesMixin
+from .wire import CopilotWireMixin
- class CopilotProfile(CopilotWireMixin, CopilotCatalogMixin, CopilotCredentialsMixin, ProviderProfile):
-class CopilotProfile(CopilotResponsesMixin, ProviderProfile):
++class CopilotProfile(CopilotWireMixin, CopilotResponsesMixin, CopilotCatalogMixin, CopilotCredentialsMixin, ProviderProfile):
"""GitHub Copilot / GitHub Models — editor headers + reasoning."""
def build_api_kwargs_extras(
@@@ -42,8 -40,7 +43,8 @@@
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", ambient_credentials=True,
- auth_type="copilot", **RESPONSES_PROFILE_FIELDS,
++ auth_type="copilot", ambient_credentials=True, **RESPONSES_PROFILE_FIELDS,
+ hostnames=HOSTNAMES, metadata_hostnames=METADATA_HOSTNAMES, models_dev_id=MODELS_DEV_ID,
)
register_provider(copilot)
diff --cc providers/base.py
index a7d4c3d62ca,dda1c619491..4a3fc2c05b4
--- a/providers/base.py
+++ b/providers/base.py
@@@ -576,64 -537,31 +576,93 @@@ class ProviderProfile
logger.debug("fetch_models(%s): %s", self.name, exc)
return None
+ # ── Lane L4: catalog / metadata seams ─────────────────────
+ # Hosts (exact or any subdomain) that serve THIS provider's API, so a ``custom`` endpoint or an
+ # auto-routed aux client at one of them is recognised as this provider (``providers.profile_for_host``).
+ hostnames: tuple = ()
+ # Hosts that identify this provider's catalog for model metadata (context length, models.dev) but
+ # take other credentials; matched only by ``profile_for_host(url, metadata=True)``.
+ metadata_hostnames: tuple = ()
+ # models.dev provider id when it differs from ``name`` (e.g. ``fireworks`` -> ``fireworks-ai``).
+ models_dev_id: str = ""
+
+ def live_context_length(self, model: str, *, api_key: str = "", base_url: str = "") -> int | None:
+ """Context window from the provider's live, credentialed catalog; consulted after the persistent cache."""
+ return None
+
+ def normalize_model_id(self, model: str, *, api_key: str = "") -> str | None:
+ """Provider-native id for *model* (alias table, catalog repair); None = core's generic normalization."""
+ return None
+
+ # ── Lane L2: provider-owned credential seams ──────────────────────────────
+ # Credentials are commonly ambient (another tool's login, a token exported for other purposes):
+ # never auto-detected as the inference provider, and the auxiliary fallback chain skips the
+ # provider unless the user explicitly configured it.
+ ambient_credentials: bool = field(default=False, kw_only=True)
+
+ def resolve_api_key_secret(self) -> tuple[str, str] | None:
+ """Provider-owned ``(runtime_api_key, source)`` resolution; None = generic env/pool ladder."""
+ return None
+
+ def runtime_base_url(self, *, api_key: str, default: str, env_url: str) -> str | None:
+ """Runtime base URL derived from the credential (e.g. an account endpoint); None = env or default."""
+ return None
+
+ def prepare_pool_entry(self, entry: Any, api_key: str) -> str:
+ """Turn the selected pool row's secret into the runtime key (may update ``entry``); default as-is."""
+ return api_key
+
+ def seed_pool_credentials(self, *, is_suppressed: Callable[[str], bool],
+ explicitly_configured: Callable[[], bool]) -> list[dict] | None:
+ """Pool rows ``{source, access_token, base_url, label}`` this provider seeds itself; None = generic env seeding."""
+ return None
+
+ def remove_credential_source(self, source: str) -> tuple[tuple[str, ...], tuple[str, ...]] | None:
+ """``hermes auth remove`` of *source*: ``(sources_to_suppress, hints)``; None = generic removal."""
+ return None
+
+ def refresh_runtime_credentials(self, *, reason: str) -> tuple[str, str | None] | None:
+ """Re-mint the live client's ``(api_key, base_url or None)`` on ``reason`` (``unauthorized`` |
+ ``stale`` | ``auxiliary_unauthorized``); None = nothing fresher. Error path only, I/O allowed."""
+ return None
+
+ def is_stale_credential_error(self, *, status_code: int | None, message: str) -> bool:
+ """True when a non-auth error really means the credential went stale (pure, no I/O)."""
+ return False
+
+ def request_rejection_hint(self, *, status_code: int | None, base_url: str) -> tuple[str, ...]:
+ """User-facing lines explaining an endpoint's hard rejection of *any* route (pure); default none."""
+ return ()
+
+ def external_auth_evidence(self) -> tuple[bool, str | None] | None:
+ """Subprocess-free ``(verified, source)`` login evidence for an external CLI; None = binary resolves."""
+ return None
++
+ # ── Lane L3: Responses-route quirks and message-level reasoning carriers ───
+ # Every field and hook below applies only on endpoints the profile claims via ``serves_endpoint``;
+ # the defaults are the generic wire. Hot path: answers must be pure and cheap (no I/O).
+ responses_replay_item_ids: bool = True # replayed Responses ``message`` items keep their ``id``
+ responses_prompt_cache_key: bool = True # the Responses body carries ``prompt_cache_key``
+ responses_issuer_kind: str = "" # persisted stamp for encrypted reasoning minted here ("" = URL-derived)
+ responses_trusts_completed_status: bool = True # False: a reasoning-only ``completed`` response continues
+ responses_native_compaction: bool = True # False: never send ``context_management``
+ responses_profile_reasoning: bool = False # True: ``reasoning`` = ``reasoning_payload`` + summary, no ``include``
+ message_carrier_opaque: str = "" # top-level assistant key of an opaque reasoning blob (latest streamed wins)
+ message_carrier_text: str = "" # top-level assistant key of readable reasoning text (streamed parts concatenate)
+ replays_tool_call_signatures: bool = False # tool calls keep Gemini ``extra_content`` signatures (by provider name)
+
+ def serves_endpoint(self, base_url: str) -> bool:
+ """True when *base_url* is this provider's own backend, so the L3 fields and hooks apply to it."""
+ return False
+
+ def reasoning_payload(self, model: str | None, reasoning_config: dict | None, *, base_url: str) -> dict | None:
+ """Verbatim ``reasoning`` object the endpoint takes for *model* (catalog-clamped), or None for none."""
+ return None
+
+ def replay_message_carriers(self, values: dict[str, Any], *, model: str | None, base_url: str) -> dict[str, Any]:
+ """Captured message carriers (``message_carrier_*`` keys) to put back on a replayed assistant message."""
+ return {}
+
+ def replays_function_thought_signature(self, *, model: str | None, base_url: str) -> bool:
+ """True when replayed tool calls keep ``function.thought_signature`` (stripped everywhere else)."""
+ return False