mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
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:
co-authored by
Claude Opus 4.8
parent
9742074b38
commit
88224b80ca
@@ -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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user