Files
openclaw/extensions/github-copilot/provider-policy-api.test.ts
Rain 110eb787a1 fix(github-copilot): preserve catalog thinking efforts in requests (#107834)
* fix(github-copilot): preserve catalog thinking efforts in requests

Unify discovered and bundled capability mapping with the provider thinking policy. Preserve supported xhigh/max Responses efforts and map minimal to the supported low minimum, while respecting explicit account opt-outs and transport limits.

Fixes #107792

Co-authored-by: Pluviobyte <Pluviobyte@users.noreply.github.com>

* fix(github-copilot): resolve nullable thinking policy transport

Accept the public policy API context and resolve missing transports before enforcing Claude and Gemini effort restrictions. Cover undefined and null API values without changing explicit Responses routes.

* refactor(github-copilot): normalize manifest models as one catalog

Use the canonical batch model provider builder after the single-row helper was removed on main. Preserve model transport and compatibility decoration without a legacy API shim.

* refactor(github-copilot): decorate owned catalog rows in place

Keep the normalized manifest batch as the sole owner of runtime rows and apply transport metadata directly, avoiding redundant row copies.

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
Co-authored-by: Pluviobyte <Pluviobyte@users.noreply.github.com>
2026-08-26 21:09:21 -07:00

130 lines
4.0 KiB
TypeScript

// Github Copilot tests cover provider policy api plugin behavior.
import { describe, expect, it } from "vitest";
import { resolveThinkingProfile } from "./provider-policy-api.js";
describe("github-copilot provider-policy-api", () => {
it("returns the base level set for non-xhigh GitHub Copilot models", () => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "claude-haiku-4.5",
})?.levels.map((level) => level.id),
).toEqual(["off", "minimal", "low", "medium", "high"]);
});
it("appends xhigh for current static GPT Copilot xhigh ids", () => {
for (const modelId of [
"gpt-5.6-sol",
"gpt-5.6-terra",
"gpt-5.6-luna",
"gpt-5.5",
"gpt-5.4",
"gpt-5.3-codex",
]) {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId,
})?.levels.map((level) => level.id),
`model=${modelId}`,
).toContain("xhigh");
}
});
it("appends xhigh when catalog compat advertises it", () => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "future-copilot-model",
compat: { supportedReasoningEfforts: ["low", "medium", "high", "xhigh"] },
})?.levels.map((level) => level.id),
).toContain("xhigh");
});
it("appends max when catalog compat advertises it", () => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "claude-fable-5",
compat: { supportedReasoningEfforts: ["low", "medium", "high", "max"] },
})?.levels.map((level) => level.id),
).toContain("max");
});
it("appends max when GPT catalog compat advertises it", () => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "gpt-5.6-sol",
compat: { supportedReasoningEfforts: ["low", "medium", "high", "max"] },
})?.levels.map((level) => level.id),
).toContain("max");
});
it.each([undefined, null])("does not expose older Claude adaptive effort with api=%s", (api) => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "claude-opus-4-5",
api,
compat: { supportedReasoningEfforts: ["low", "medium", "high", "max"] },
})?.levels.map((level) => level.id),
).not.toContain("max");
});
it.each([
{ supportedReasoningEfforts: ["low", "medium", "high"] },
{ supportedReasoningEfforts: [] },
{ supportsReasoningEffort: false, supportedReasoningEfforts: ["xhigh", "max"] },
])("honors explicit catalog limits before static GPT metadata: %j", (compat) => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "gpt-5.6-luna",
compat,
})?.levels.map(({ id }) => id),
).toEqual(["off", "minimal", "low", "medium", "high"]);
});
it.each(["openai-completions", undefined, null])(
"does not expose Gemini max with api=%s",
(api) => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "gemini-3.6-flash",
api,
compat: { supportedReasoningEfforts: ["low", "medium", "high", "max"] },
})?.levels.map(({ id }) => id),
).not.toContain("max");
},
);
it("appends xhigh for static Copilot metadata overrides", () => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "claude-opus-4.7-1m-internal",
})?.levels.map((level) => level.id),
).toContain("xhigh");
});
it("normalizes the model id casing before xhigh membership checks", () => {
expect(
resolveThinkingProfile({
provider: "github-copilot",
modelId: "GPT-5.4",
})?.levels.map((level) => level.id),
).toContain("xhigh");
});
it("returns null for non-GitHub Copilot providers", () => {
expect(
resolveThinkingProfile({
provider: "openai",
modelId: "gpt-5.4",
}),
).toBeNull();
});
});