Skip to content

Commit 3c0654c

Browse files
authored
test(live): classify xAI degraded availability (#107887)
1 parent e905a68 commit 3c0654c

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

src/agents/live-test-provider-drift.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ describe("live test provider drift", () => {
4949
"Service temporarily unavailable. The model is at capacity and currently cannot serve this request.",
5050
),
5151
).toBe(true);
52+
expect(
53+
isLiveProviderUnavailableDrift(
54+
"Error Code unknown: Service temporarily unavailable. The model's availability is currently degraded.",
55+
),
56+
).toBe(true);
5257
});
5358

5459
it("returns explicit skip labels only for enabled drift classes", () => {
@@ -66,5 +71,12 @@ describe("live test provider drift", () => {
6671
allowBilling: true,
6772
}),
6873
).toBeUndefined();
74+
expect(
75+
shouldSkipLiveProviderDrift({
76+
error:
77+
"Error Code unknown: Service temporarily unavailable. The model's availability is currently degraded.",
78+
allowProviderUnavailable: true,
79+
}),
80+
).toEqual({ reason: "provider-unavailable", label: "provider unavailable" });
6981
});
7082
});

src/agents/live-test-provider-drift.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { isCloudflareOrHtmlErrorPage } from "../shared/assistant-error-format.js
99
import {
1010
isAuthErrorMessage,
1111
isBillingErrorMessage,
12+
isOverloadedErrorMessage,
1213
isRateLimitErrorMessage,
14+
isServerErrorMessage,
1315
isTimeoutErrorMessage,
1416
} from "./embedded-agent-helpers/failover-matches.js";
1517
import { isAnthropicBillingError, isApiKeyRateLimitError } from "./live-auth-keys.js";
@@ -84,6 +86,8 @@ export function isLiveProviderUnavailableDrift(error: unknown): boolean {
8486
const htmlCandidate = raw.trim().replace(/^error:\s*/i, "");
8587
const msg = normalizeLowercaseStringOrEmpty(raw);
8688
return (
89+
isOverloadedErrorMessage(raw) ||
90+
isServerErrorMessage(raw) ||
8791
isRawHtmlProviderErrorPage(htmlCandidate) ||
8892
isCloudflareOrHtmlErrorPage(raw) ||
8993
isCloudflareOrHtmlErrorPage(htmlCandidate) ||

src/agents/xai.live.test.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
import { completeSimple, type Model } from "openclaw/plugin-sdk/llm";
44
import { Type } from "typebox";
55
import { describe, expect, it } from "vitest";
6-
import {
7-
isBillingErrorMessage,
8-
isOverloadedErrorMessage,
9-
} from "./embedded-agent-helpers/failover-matches.js";
106
import { applyExtraParamsToAgent } from "./embedded-agent-runner/extra-params.js";
117
import {
128
createSingleUserPromptMessage,
139
extractNonEmptyAssistantText,
1410
isLiveTestEnabled,
1511
} from "./live-test-helpers.js";
12+
import { shouldSkipLiveProviderDrift } from "./live-test-provider-drift.js";
1613
import { createOpenAIResponsesTransportStreamFn } from "./openai-transport-stream.js";
1714
import { createWebSearchTool } from "./tools/web-search.js";
1815

@@ -86,12 +83,13 @@ async function runXaiLiveCase(label: string, run: () => Promise<void>): Promise<
8683
await run();
8784
} catch (error) {
8885
const message = error instanceof Error ? error.message : String(error);
89-
if (isBillingErrorMessage(message)) {
90-
console.warn(`[xai:live] skip ${label}: billing drift: ${message}`);
91-
return;
92-
}
93-
if (isOverloadedErrorMessage(message)) {
94-
console.warn(`[xai:live] skip ${label}: temporary provider capacity: ${message}`);
86+
const drift = shouldSkipLiveProviderDrift({
87+
error,
88+
allowBilling: true,
89+
allowProviderUnavailable: true,
90+
});
91+
if (drift) {
92+
console.warn(`[xai:live] skip ${label}: ${drift.label}: ${message}`);
9593
return;
9694
}
9795
if (/\b403\b/.test(message) && /model .+ is not available in your region/i.test(message)) {
@@ -258,8 +256,13 @@ describeLive("xai live", () => {
258256
details.error && details.message
259257
? `${details.error} ${details.message}`
260258
: details.error || details.message || "";
261-
if (isBillingErrorMessage(errorMessage)) {
262-
console.warn(`[xai:live] skip web-search: billing drift: ${errorMessage}`);
259+
const drift = shouldSkipLiveProviderDrift({
260+
error: errorMessage,
261+
allowBilling: true,
262+
allowProviderUnavailable: true,
263+
});
264+
if (drift) {
265+
console.warn(`[xai:live] skip web-search: ${drift.label}: ${errorMessage}`);
263266
return;
264267
}
265268

0 commit comments

Comments
 (0)