Files
openclaw/extensions/xai/provider-policy-api.test.ts
kiranmagic7 095f3e1a44 feat(xai): add Grok 4.6 catalog and preserve OAuth xhigh (#122762)
* feat(xai): add Grok 4.6 catalog and preserve OAuth xhigh

Add first-class Grok 4.6 discovery, pricing, and reasoning metadata while
keeping the existing Grok 4.3 API-key and server-tool defaults unchanged.
Preserve xhigh only for Grok 4.6 so OAuth auto no longer inherits the
Grok 4.5 high downgrade.

Closes nothing; tracks #122734.

* fix(xai): resolve the OAuth auto alias to its canonical model in the thinking policy

The OAuth catalog row keeps id "auto" and records the provider-selected
target in params.canonicalModelId; judging the raw alias collapsed the
default OAuth route to an off-only thinking picker for every model.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(xai): refresh catalog-order assertions and restore stream deadlines for Grok 4.6

Exact-order catalog and onboarding arrays now include the new row with its
metadata assertion; payload-capture timeouts return to their original
values, Grok 4.5 off-clamp and Grok 4.3 modern-model coverage are
restored, and the Grok 4.6 xhigh boundary test passes its id explicitly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(agents): add Grok 4.6 to the curated high-signal live matrix

xai is a curated-only high-signal provider, so the new flagship was
structurally excluded from default live sweeps; add it alongside
Grok 4.5 with its test and docs mirrors, matching the 4.5 precedent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(xai): align Grok frontier metadata

* fix(xai): align Grok 4.6 catalog contract

Remove the unsupported moving alias, centralize OAuth auto target resolution, correct cached pricing, and keep live coverage on the stable xhigh completion path.

Co-authored-by: Kiran Magic <262980978+kiranmagic7@users.noreply.github.com>

---------

Co-authored-by: Kiran Magic <262980978+kiranmagic7@users.noreply.github.com>
Co-authored-by: Kiran Magic <kiran@Alices-Laptop.local>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Kiran <kiranmagic7@users.noreply.github.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-08-12 21:29:51 -07:00

110 lines
3.2 KiB
TypeScript

// Xai tests cover provider policy api plugin behavior.
import { describe, expect, it } from "vitest";
import { resolveThinkingProfile } from "./provider-policy-api.js";
describe("xai provider thinking policy", () => {
it.each([
["xai", "grok-4.3"],
["xai", "grok-4.3-latest"],
["xai", "grok-latest"],
["x-ai", "grok-4.3"],
["x-ai", "grok-4.3-latest"],
["x-ai", "grok-latest"],
])("exposes Grok 4.3 thinking levels for %s/%s", (provider, modelId) => {
const profile = resolveThinkingProfile({
provider,
modelId,
});
expect(profile.defaultLevel).toBe("low");
expect(profile.levels.map((level) => level.id)).toEqual([
"off",
"minimal",
"low",
"medium",
"high",
]);
});
it.each([
["xai", "grok-4.5"],
["xai", "grok-4.5-latest"],
["xai", "grok-build-latest"],
["x-ai", "grok-4.5"],
["x-ai", "grok-4.5-latest"],
["x-ai", "grok-build-latest"],
])("uses xAI's high reasoning default for %s/%s", (provider, modelId) => {
const profile = resolveThinkingProfile({
provider,
modelId,
});
expect(profile).toEqual({
levels: [{ id: "low" }, { id: "medium" }, { id: "high" }],
defaultLevel: "high",
});
});
it.each(["xai", "x-ai"])("exposes Grok 4.6 xhigh reasoning for %s", (provider) => {
expect(resolveThinkingProfile({ provider, modelId: "grok-4.6" })).toEqual({
levels: [{ id: "low" }, { id: "medium" }, { id: "high" }, { id: "xhigh" }],
defaultLevel: "high",
});
});
it.each([
["grok-4.6", [{ id: "low" }, { id: "medium" }, { id: "high" }, { id: "xhigh" }]],
["grok-4.5", [{ id: "low" }, { id: "medium" }, { id: "high" }]],
] as const)(
"resolves the OAuth auto alias to its canonical %s target",
(canonicalModelId, levels) => {
expect(
resolveThinkingProfile({
provider: "xai",
modelId: "auto",
reasoning: true,
params: { canonicalModelId },
}),
).toEqual({ levels, defaultLevel: "high" });
},
);
it("keeps the OAuth auto alias off-only without a canonical target", () => {
expect(resolveThinkingProfile({ provider: "xai", modelId: "auto", reasoning: true })).toEqual({
levels: [{ id: "off" }],
defaultLevel: "off",
});
});
it("keeps non-reasoning and non-xai routes off-only", () => {
expect(
resolveThinkingProfile({
provider: "xai",
modelId: "grok-4-fast-non-reasoning",
reasoning: false,
}),
).toEqual({ levels: [{ id: "off" }], defaultLevel: "off" });
expect(
resolveThinkingProfile({
provider: "openrouter",
modelId: "x-ai/grok-4.3",
reasoning: true,
}),
).toEqual({ levels: [{ id: "off" }], defaultLevel: "off" });
});
it.each([
["xai", "grok-build-0.1"],
["xai", "grok-4.20-0309-reasoning"],
["xai", "grok-4.20-beta-latest-reasoning"],
["x-ai", "grok-build-0.1"],
["x-ai", "grok-4.20-0309-reasoning"],
["x-ai", "grok-4.20-beta-latest-reasoning"],
])("does not advertise configurable reasoning for %s/%s", (provider, modelId) => {
expect(resolveThinkingProfile({ provider, modelId })).toEqual({
levels: [{ id: "off" }],
defaultLevel: "off",
});
});
});