docs: document openai live compat tests · openclaw/openclaw@48d67e8
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Live-sweeps discovered model profiles with optional provider/model filters and probes. |
1 | 2 | import { writeSync } from "node:fs"; |
2 | 3 | import { normalizeProviderId } from "@openclaw/model-catalog-core/provider-id"; |
3 | 4 | import { type Api, completeSimple, type Model } from "openclaw/plugin-sdk/llm"; |
@@ -132,6 +133,7 @@ function parseModelFilter(raw?: string): Set<string> | null {
|
132 | 133 | function parseExplicitLiveModelRefs( |
133 | 134 | filter: Set<string> | null, |
134 | 135 | ): Array<{ provider: string; id: string }> { |
| 136 | +// Explicit refs use provider/model syntax; bare provider filters are handled elsewhere. |
135 | 137 | if (!filter) { |
136 | 138 | return []; |
137 | 139 | } |
@@ -202,6 +204,7 @@ function resolveLiveProviderDiscoveryProviderIds(params: {
|
202 | 204 | explicitRefs: readonly { provider: string; id: string }[]; |
203 | 205 | priorityRefs?: readonly { provider: string; id: string }[]; |
204 | 206 | }): string[] | undefined { |
| 207 | +// Narrow startup discovery to providers that can affect the requested live target set. |
205 | 208 | const providers = new Set<string>(); |
206 | 209 | for (const provider of params.providerFilter ?? []) { |
207 | 210 | const normalized = normalizeProviderId(provider); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Live smoke test for Moonshot OpenAI-compatible completions behavior. |
1 | 2 | import { completeSimple, type Model } from "openclaw/plugin-sdk/llm"; |
2 | 3 | import { describe, expect, it } from "vitest"; |
3 | 4 | import { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies OpenAI-compatible payloads contain at least one sendable conversation turn. |
1 | 2 | import { describe, expect, it } from "vitest"; |
2 | 3 | import { hasOpenAICompatibleConversationTurn } from "./openai-compatible-conversation-turn.js"; |
3 | 4 | |
@@ -40,6 +41,7 @@ describe("hasOpenAICompatibleConversationTurn", () => {
|
40 | 41 | }); |
41 | 42 | |
42 | 43 | it("accepts assistant tool calls even when assistant content is empty", () => { |
| 44 | +// Tool-call turns are sendable even when visible assistant text is absent. |
43 | 45 | expect( |
44 | 46 | hasOpenAICompatibleConversationTurn([ |
45 | 47 | { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies OpenAI-compatible endpoint defaults for streaming usage and reasoning payloads. |
1 | 2 | import { describe, expect, it } from "vitest"; |
2 | 3 | import { |
3 | 4 | detectOpenAICompletionsCompat, |
@@ -50,6 +51,7 @@ describe("resolveOpenAICompletionsCompatDefaults", () => {
|
50 | 51 | it.each(["vllm", "sglang", "lmstudio"])( |
51 | 52 | "enables streaming usage compat for manifest-declared local provider %s", |
52 | 53 | (provider) => { |
| 54 | +// Manifest capability, not provider id alone, enables local streaming usage compat. |
53 | 55 | expect( |
54 | 56 | resolveOpenAICompletionsCompatDefaults({ |
55 | 57 | provider, |
@@ -118,6 +120,7 @@ describe("detectOpenAICompletionsCompat", () => {
|
118 | 120 | |
119 | 121 | describe("xiaomi compat detection", () => { |
120 | 122 | it("sets thinkingFormat to deepseek for xiaomi-native endpoint", () => { |
| 123 | +// Xiaomi's OpenAI-compatible route uses DeepSeek-style reasoning payloads. |
121 | 124 | expect( |
122 | 125 | resolveOpenAICompletionsCompatDefaults({ |
123 | 126 | provider: "xiaomi", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Live checks for OpenAI reasoning compatibility and repaired tool replay payloads. |
1 | 2 | import type { AgentMessage } from "openclaw/plugin-sdk/agent-core"; |
2 | 3 | import { SessionManager } from "openclaw/plugin-sdk/agent-sessions"; |
3 | 4 | import type { Model } from "openclaw/plugin-sdk/llm"; |
@@ -32,6 +33,7 @@ async function completeReplyWithRetry(params: {
|
32 | 33 | apiKey: string; |
33 | 34 | message: string; |
34 | 35 | }): Promise<{ text: string; errorMessage?: string }> { |
| 36 | +// Some reasoning targets spend the first tiny budget without visible text. |
35 | 37 | const runOnce = async (maxTokens: number) => { |
36 | 38 | const response = await completeSimpleWithTimeout( |
37 | 39 | params.model, |
@@ -74,13 +76,15 @@ async function completeReplyWithRetry(params: {
|
74 | 76 | } |
75 | 77 | |
76 | 78 | function isKnownLiveBlocker(errorMessage: string): boolean { |
| 79 | +// Live lane should skip account/usage blockers rather than fail unrelated compat checks. |
77 | 80 | return ( |
78 | 81 | /not supported when using codex with a chatgpt account/i.test(errorMessage) || |
79 | 82 | /hit your chatgpt usage limit/i.test(errorMessage) |
80 | 83 | ); |
81 | 84 | } |
82 | 85 | |
83 | 86 | function resolveTargetModelRef(): { provider: string; modelId: string } { |
| 87 | +// Keep env override parsing strict so live runs never silently target the wrong model. |
84 | 88 | const [provider, ...rest] = TARGET_MODEL_REF.split("/"); |
85 | 89 | const modelId = rest.join("/").trim(); |
86 | 90 | if (!provider?.trim() || !modelId) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies model-specific OpenAI reasoning-effort normalization and disablement. |
1 | 2 | import { describe, expect, it } from "vitest"; |
2 | 3 | import { |
3 | 4 | resolveOpenAIReasoningEffortForModel, |
@@ -38,6 +39,7 @@ describe("OpenAI reasoning effort support", () => {
|
38 | 39 | }); |
39 | 40 | |
40 | 41 | it("allows provider-native compat values when explicitly declared", () => { |
| 42 | +// Some OpenAI-compatible providers expose their own reasoning effort labels. |
41 | 43 | const model = { |
42 | 44 | provider: "groq", |
43 | 45 | id: "qwen/qwen3-32b", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。