Skip to content

fix(copilot): route /responses-only models via the Responses API - #86075

Open
angaba92 wants to merge 2 commits into
NousResearch:mainfrom
angaba92:fix/copilot-responses-only-model-routing
Open

fix(copilot): route /responses-only models via the Responses API#86075
angaba92 wants to merge 2 commits into
NousResearch:mainfrom
angaba92:fix/copilot-responses-only-model-routing

Conversation

@angaba92

Copy link
Copy Markdown

Summary

Fixes model routing for Github Copilot models that only support the /responses endpoint (e.g. grok-4.5, gpt-5.5, gpt-5.6-*).

Problem

Previously, copilot_model_api_mode() determined whether to use codex_responses vs chat_completions solely based on the regex ^gpt-(\d+) (inherited from OpenCode logic). Models like grok-4.5 served over GitHub Copilot only expose /responses, causing chat_completions requests to fail with HTTP 400 unsupported_api_for_model.

Fix

  1. Dynamic endpoint checking: copilot_model_api_mode() now inspects the live catalogue's supported_endpoints field first before falling back to name heuristics.
  2. Curated model list refresh: Updated the fallback list with 25 active models verified against the live API (including grok-4.5, claude-opus-5, gpt-5.6-*).
  3. Tests: Added regression tests covering /responses-only models, chat_completions-only models, and dual-endpoint models.

andres added 2 commits August 14, 2026 14:52
copilot_model_api_mode() decided the API mode purely from the model-name
pattern ^gpt-(\d+), ported from opencode's shouldUseCopilotResponsesApi.
Any non-GPT model that Copilot exposes only on /responses was therefore
routed to /chat/completions and rejected upstream with:

    400 model "grok-4.5" is not accessible via the /chat/completions
        endpoint   (code: unsupported_api_for_model)

Verified against a live Copilot Business catalogue: grok-4.5 advertises
supported_endpoints == ["/responses"] exclusively, so it was unusable via
the Copilot provider regardless of the user's entitlements.

The catalogue already carries the answer, so consult it first and keep the
name heuristic only as a fallback:

  * /responses only             -> codex_responses
  * /chat/completions only      -> chat_completions
  * both, or no catalogue entry -> existing ^gpt-N heuristic

Claude keeps its current behaviour: it advertises /v1/messages alongside
/chat/completions, and the dual-endpoint branch leaves it on
chat_completions so the OpenAI-compatible auth/wire shape is preserved
(the reason the pre-existing test asserts that).

ws:/responses variants are normalised so they are not mistaken for a chat
endpoint.

Sampled 13 models from the live catalogue: all 13 now resolve to the mode
the API actually accepts; 6 of them previously resolved to a mode that
returned HTTP 400.
The curated Copilot fallback list had drifted from what the API actually
serves. It still offered retired models and was missing three families.

Removed (retired upstream, per GitHub's model-retirement table):
  gpt-5.2-codex, claude-sonnet-4, gemini-3-pro-preview,
  gemini-3-flash-preview, gemini-2.5-pro

Added (live in the catalogue, previously unreachable from the picker):
  claude-opus-5 / 4.8 / 4.8-fast / 4.7 / 4.6 / 4.5, claude-sonnet-5,
  gpt-5.6-sol / terra / luna, gpt-5.5, gemini-3.6-flash, gemini-3.5-flash,
  grok-4.5

grok-4.5 is only usable together with the preceding commit, as it is a
/responses-only model.

This list is a fallback for when the live catalogue cannot be fetched, so
it is deliberately limited to models available on a standard Business
tenant; policy-gated models are resolved dynamically instead.
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard provider/copilot GitHub Copilot (ACP + Chat) P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Aug 14, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #58835: both patches make copilot_model_api_mode() use catalog supported_endpoints to route Responses-only non-GPT Copilot models correctly. #58835 is the earlier open implementation.

@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

fix(copilot): route /responses-only models via the Responses API

  • lstrip("ws:") strips a character set, not a prefix: "wss:/responses" (and pathological ids like "sws:/responses") lose all leading w/s/:/ characters. str.removeprefix("ws:") expresses the intent exactly and avoids surprising matches.
  • Catalog entries advertising neither endpoint: a model whose supported_endpoints contains only an Anthropic-style /v1/messages (no /chat/completions, no /responses) hits break and falls through to the name-pattern heuristic → routed to chat_completions, which can reproduce the same 400 class this PR fixes for grok-4.5. An explicit branch for "unknown endpoint set" that fails safe (e.g. responses for non-GPT vendors) would close that gap.
  • Exact-match on _item.get("id") != normalized: if the live catalog ever uses vendor-prefixed ids (e.g. "anthropic/claude-opus-5") while callers pass the bare name, the catalog branch never matches and routing silently degrades to the heuristic. Prefix-tolerant matching would be more robust.

The regression test for grok-4.5 (responses-only, non-GPT) is exactly the right test for the reported failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/copilot GitHub Copilot (ACP + Chat) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants