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
+1
View File
@@ -1,6 +1,7 @@
# v0.4.63 (2026-05-26) # v0.4.63 (2026-05-26)
## Fixes ## Fixes
- GitHub Copilot: never route Gemini/Claude models to the `/responses` endpoint; prevents misleading "does not support Responses API" 400s (#1062)
- proxyFetch: restore missing `Readable` import causing runtime `ReferenceError` in DNS-bypass fetch path - proxyFetch: restore missing `Readable` import causing runtime `ReferenceError` in DNS-bypass fetch path
## Improvements ## Improvements
+16 -2
View File
@@ -159,11 +159,22 @@ export class GithubExecutor extends BaseExecutor {
return transformed; 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) { async execute(options) {
const { model, log } = options; const { model, log } = options;
// Only use /responses for models that are explicitly known to need it (e.g. gpt codex models) // 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}`); log?.debug("GITHUB", `Using cached /responses route for ${model}`);
return this.executeWithResponsesEndpoint(options); return this.executeWithResponsesEndpoint(options);
} }
@@ -177,7 +188,10 @@ export class GithubExecutor extends BaseExecutor {
const result = await super.execute({ ...sanitizedOptions, proxyOptions: options.proxyOptions || null }); 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(); 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")) { if (errorBody.includes("not accessible via the /chat/completions endpoint") || errorBody.includes("The requested model is not supported")) {
@@ -0,0 +1,56 @@
/**
* Regression test for #1062:
* GitHub Copilot's /responses endpoint only serves OpenAI (gpt/codex) models.
* Gemini/Claude models must never be routed/escalated there, otherwise they
* fail with a misleading 400 "does not support Responses API".
*/
import { describe, it, expect, vi } from "vitest";
import { GithubExecutor } from "../../open-sse/executors/github.js";
describe("GithubExecutor.supportsResponsesEndpoint", () => {
const exec = new GithubExecutor();
it("excludes Gemini models from the /responses endpoint", () => {
expect(exec.supportsResponsesEndpoint("gemini-3.1-pro-preview")).toBe(false);
expect(exec.supportsResponsesEndpoint("gemini-3.1-pro-low")).toBe(false);
});
it("excludes Claude models from the /responses endpoint", () => {
expect(exec.supportsResponsesEndpoint("claude-sonnet-4.6")).toBe(false);
expect(exec.supportsResponsesEndpoint("claude-opus-4.7")).toBe(false);
});
it("allows OpenAI/codex models on the /responses endpoint", () => {
expect(exec.supportsResponsesEndpoint("gpt-5.5-codex")).toBe(true);
expect(exec.supportsResponsesEndpoint("o4-mini")).toBe(true);
expect(exec.supportsResponsesEndpoint("gpt-4.1")).toBe(true);
});
it("is null-safe", () => {
expect(exec.supportsResponsesEndpoint(undefined)).toBe(true);
expect(exec.supportsResponsesEndpoint("")).toBe(true);
});
});
describe("GithubExecutor.execute cached-route guard (#1062)", () => {
it("does NOT use /responses for a Gemini model even if it was wrongly cached as codex", async () => {
const exec = new GithubExecutor();
// Simulate a prior misclassification that cached the Gemini model.
exec.knownCodexModels.add("gemini-3.1-pro-preview");
const respSpy = vi
.spyOn(exec, "executeWithResponsesEndpoint")
.mockResolvedValue({ via: "responses" });
// Short-circuit the /chat/completions path (BaseExecutor.execute).
const baseSpy = vi
.spyOn(Object.getPrototypeOf(Object.getPrototypeOf(exec)), "execute")
.mockResolvedValue({ response: { status: 200 }, via: "chat" });
const result = await exec.execute({ model: "gemini-3.1-pro-preview", body: { messages: [] }, log: null });
expect(respSpy).not.toHaveBeenCalled();
expect(baseSpy).toHaveBeenCalled();
expect(result.via).toBe("chat");
});
});