fix(copilot): route /responses-only models via the Responses API - #86075
Open
angaba92 wants to merge 2 commits into
Open
fix(copilot): route /responses-only models via the Responses API#86075angaba92 wants to merge 2 commits into
angaba92 wants to merge 2 commits into
Conversation
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.
Collaborator
Contributor
fix(copilot): route /responses-only models via the Responses API
The regression test for grok-4.5 (responses-only, non-GPT) is exactly the right test for the reported failure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes model routing for Github Copilot models that only support the
/responsesendpoint (e.g.grok-4.5,gpt-5.5,gpt-5.6-*).Problem
Previously,
copilot_model_api_mode()determined whether to usecodex_responsesvschat_completionssolely based on the regex^gpt-(\d+)(inherited from OpenCode logic). Models likegrok-4.5served over GitHub Copilot only expose/responses, causingchat_completionsrequests to fail with HTTP 400unsupported_api_for_model.Fix
copilot_model_api_mode()now inspects the live catalogue'ssupported_endpointsfield first before falling back to name heuristics.grok-4.5,claude-opus-5,gpt-5.6-*)./responses-only models,chat_completions-only models, and dual-endpoint models.