fix(agents): detect Venice provider proxying xAI/Grok models for schema cleaning (#35355)

Merged via squash.

Prepared head SHA: 8bfdec257b
Co-authored-by: Sid-Qin <201593046+Sid-Qin@users.noreply.github.com>
Co-authored-by: shakkernerd <165377636+shakkernerd@users.noreply.github.com>
Reviewed-by: @shakkernerd
This commit is contained in:
Sid
2026-03-05 13:29:25 +08:00
committed by GitHub
parent 1805735c63
commit 987e473364
3 changed files with 19 additions and 1 deletions

View File

@@ -29,6 +29,18 @@ describe("isXaiProvider", () => {
it("handles undefined provider", () => {
expect(isXaiProvider(undefined)).toBe(false);
});
it("matches venice provider with grok model id", () => {
expect(isXaiProvider("venice", "grok-4.1-fast")).toBe(true);
});
it("matches venice provider with venice/ prefixed grok model id", () => {
expect(isXaiProvider("venice", "venice/grok-4.1-fast")).toBe(true);
});
it("does not match venice provider with non-grok model id", () => {
expect(isXaiProvider("venice", "llama-3.3-70b")).toBe(false);
});
});
describe("stripXaiUnsupportedKeywords", () => {

View File

@@ -48,8 +48,13 @@ export function isXaiProvider(modelProvider?: string, modelId?: string): boolean
if (provider.includes("xai") || provider.includes("x-ai")) {
return true;
}
const lowerModelId = modelId?.toLowerCase() ?? "";
// OpenRouter proxies to xAI when the model id starts with "x-ai/"
if (provider === "openrouter" && modelId?.toLowerCase().startsWith("x-ai/")) {
if (provider === "openrouter" && lowerModelId.startsWith("x-ai/")) {
return true;
}
// Venice proxies to xAI/Grok models
if (provider === "venice" && lowerModelId.includes("grok")) {
return true;
}
return false;