9router / tests /unit /github-responses-routing.test.js
2api
feat: configurable stream stall timeout + per-provider UI
88c4c60
Raw
History Blame Contribute Delete
2.34 kB
/**
* 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");
});
});