fix: never route GitHub Copilot Gemini/Claude models to /responses (#1062) (#1536)

GitHub Copilot's /responses endpoint only serves OpenAI (gpt/codex)
models. gemini-3.1-pro-preview was failing on /chat/completions with a
"not supported" error, getting cached as a codex model, then escalated
to /responses where it 400s with "does not support Responses API".

Add GithubExecutor.supportsResponsesEndpoint() and gate both the cached
/responses route and the 400-fallback on it, so Gemini/Claude always
stay on /chat/completions and the real upstream error surfaces.

Adds tests/unit/github-responses-routing.test.js (5 tests).

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Delcado
2026-05-29 15:40:42 +07:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 9742074b38
commit 88224b80ca
3 changed files with 73 additions and 2 deletions
+16 -2
View File
@@ -159,11 +159,22 @@ export class GithubExecutor extends BaseExecutor {
return transformed;
}
// GitHub Copilot's /responses endpoint only serves OpenAI (gpt/codex) models.
// Gemini and Claude models are not available there and reject with a 400
// "does not support Responses API" (unsupported_api_for_model). They must
// therefore never be escalated to /responses, even if /chat/completions
// returned a "not supported" error for an unrelated reason. Fixes #1062.
supportsResponsesEndpoint(model) {
const m = (model || "").toLowerCase();
return !(m.includes("gemini") || m.includes("claude"));
}
async execute(options) {
const { model, log } = options;
// Only use /responses for models that are explicitly known to need it (e.g. gpt codex models)
if (this.knownCodexModels.has(model)) {
// and that the /responses endpoint actually serves (excludes Gemini/Claude, see #1062).
if (this.knownCodexModels.has(model) && this.supportsResponsesEndpoint(model)) {
log?.debug("GITHUB", `Using cached /responses route for ${model}`);
return this.executeWithResponsesEndpoint(options);
}
@@ -177,7 +188,10 @@ export class GithubExecutor extends BaseExecutor {
const result = await super.execute({ ...sanitizedOptions, proxyOptions: options.proxyOptions || null });
if (result.response.status === HTTP_STATUS.BAD_REQUEST) {
// Only escalate to /responses for models that endpoint can actually serve.
// Gemini/Claude would otherwise loop into a misleading "does not support
// Responses API" 400 instead of surfacing the real /chat/completions error (#1062).
if (result.response.status === HTTP_STATUS.BAD_REQUEST && this.supportsResponsesEndpoint(model)) {
const errorBody = await result.response.clone().text();
if (errorBody.includes("not accessible via the /chat/completions endpoint") || errorBody.includes("The requested model is not supported")) {