|
3 | 3 | import { completeSimple, type Model } from "openclaw/plugin-sdk/llm"; |
4 | 4 | import { Type } from "typebox"; |
5 | 5 | import { describe, expect, it } from "vitest"; |
6 | | -import { |
7 | | - isBillingErrorMessage, |
8 | | - isOverloadedErrorMessage, |
9 | | -} from "./embedded-agent-helpers/failover-matches.js"; |
10 | 6 | import { applyExtraParamsToAgent } from "./embedded-agent-runner/extra-params.js"; |
11 | 7 | import { |
12 | 8 | createSingleUserPromptMessage, |
13 | 9 | extractNonEmptyAssistantText, |
14 | 10 | isLiveTestEnabled, |
15 | 11 | } from "./live-test-helpers.js"; |
| 12 | +import { shouldSkipLiveProviderDrift } from "./live-test-provider-drift.js"; |
16 | 13 | import { createOpenAIResponsesTransportStreamFn } from "./openai-transport-stream.js"; |
17 | 14 | import { createWebSearchTool } from "./tools/web-search.js"; |
18 | 15 |
|
@@ -86,12 +83,13 @@ async function runXaiLiveCase(label: string, run: () => Promise<void>): Promise< |
86 | 83 | await run(); |
87 | 84 | } catch (error) { |
88 | 85 | 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}`); |
95 | 93 | return; |
96 | 94 | } |
97 | 95 | if (/\b403\b/.test(message) && /model .+ is not available in your region/i.test(message)) { |
@@ -258,8 +256,13 @@ describeLive("xai live", () => { |
258 | 256 | details.error && details.message |
259 | 257 | ? `${details.error} ${details.message}` |
260 | 258 | : 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}`); |
263 | 266 | return; |
264 | 267 | } |
265 | 268 |
|
|
0 commit comments