惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Jina AI
Jina AI
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
美团技术团队
腾讯CDC
博客园 - Franky
MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
博客园_首页
V
V2EX
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(openai): quarantine unreadable tool schemas (#92921) ...
steipete · 2026-06-14 · via Recent Commits to openclaw:main
1+

import OpenAI from "openai";

2+

import type { ChatCompletionCreateParamsNonStreaming } from "openai/resources/chat/completions.js";

3+

import type { ResponseCreateParamsNonStreaming } from "openai/resources/responses/responses.js";

4+

import { describe, expect, it } from "vitest";

5+

import type { Context, Model } from "../llm/types.js";

6+

import { isLiveTestEnabled } from "./live-test-helpers.js";

7+

import {

8+

buildOpenAICompletionsParams,

9+

buildOpenAIResponsesParams,

10+

} from "./openai-transport-stream.js";

11+12+

const OPENAI_KEY = process.env.OPENAI_API_KEY ?? "";

13+

const LIVE = isLiveTestEnabled(["OPENAI_LIVE_TEST"]) && Boolean(OPENAI_KEY);

14+

const describeLive = LIVE ? describe : describe.skip;

15+16+

const probeTools = [

17+

{

18+

name: "unreadable_probe",

19+

description: "Unreadable probe.",

20+

parameters: {

21+

type: "object",

22+

get properties(): never {

23+

throw new Error("live unreadable nested schema getter");

24+

},

25+

},

26+

},

27+

{

28+

name: "live_probe",

29+

description: "Return the requested probe value.",

30+

parameters: {

31+

type: "object",

32+

properties: { value: { type: "string" } },

33+

required: ["value"],

34+

additionalProperties: false,

35+

},

36+

},

37+

];

38+39+

const context = {

40+

systemPrompt: "Call the requested function exactly once.",

41+

messages: [

42+

{

43+

role: "user",

44+

content: "Call live_probe with value exactly OPENAI_PROJECTION_OK.",

45+

timestamp: 1,

46+

},

47+

],

48+

tools: probeTools,

49+

} satisfies Context;

50+51+

describeLive("OpenAI tool projection live", () => {

52+

const modelId = process.env.OPENCLAW_LIVE_OPENAI_TOOL_MODEL || "gpt-5.5";

53+

const client = new OpenAI({ apiKey: OPENAI_KEY });

54+55+

it("calls a healthy Responses function after quarantining an unreadable sibling", async () => {

56+

const model = {

57+

id: modelId,

58+

name: modelId,

59+

api: "openai-responses",

60+

provider: "openai",

61+

baseUrl: "https://api.openai.com/v1",

62+

reasoning: true,

63+

input: ["text"],

64+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

65+

contextWindow: 200000,

66+

maxTokens: 256,

67+

} satisfies Model<"openai-responses">;

68+

const params = buildOpenAIResponsesParams(model, context, {

69+

maxTokens: 128,

70+

reasoning: "low",

71+

toolChoice: { type: "function", name: "live_probe" },

72+

});

73+74+

const response = await client.responses.create({

75+

...params,

76+

stream: false,

77+

} as unknown as ResponseCreateParamsNonStreaming);

78+

const toolCall = response.output.find((item) => item.type === "function_call");

79+80+

expect(toolCall).toMatchObject({

81+

type: "function_call",

82+

name: "live_probe",

83+

});

84+

expect(JSON.parse(toolCall?.arguments ?? "{}")).toEqual({

85+

value: "OPENAI_PROJECTION_OK",

86+

});

87+

}, 45_000);

88+89+

it("calls a healthy Chat Completions function after quarantining an unreadable sibling", async () => {

90+

const model = {

91+

id: modelId,

92+

name: modelId,

93+

api: "openai-completions",

94+

provider: "openai",

95+

baseUrl: "https://api.openai.com/v1",

96+

reasoning: false,

97+

input: ["text"],

98+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

99+

contextWindow: 200000,

100+

maxTokens: 256,

101+

} satisfies Model<"openai-completions">;

102+

const params = buildOpenAICompletionsParams(model, context, {

103+

maxTokens: 128,

104+

toolChoice: {

105+

type: "allowed_tools",

106+

allowed_tools: {

107+

mode: "required",

108+

tools: [

109+

{ type: "function", function: { name: "unreadable_probe" } },

110+

{ type: "function", function: { name: "live_probe" } },

111+

],

112+

},

113+

},

114+

});

115+

const { stream_options: _streamOptions, ...nonStreamingParams } = params;

116+117+

const response = await client.chat.completions.create({

118+

...nonStreamingParams,

119+

stream: false,

120+

} as unknown as ChatCompletionCreateParamsNonStreaming);

121+

const toolCall = response.choices[0]?.message.tool_calls?.[0];

122+123+

if (!toolCall || toolCall.type !== "function") {

124+

throw new Error("OpenAI did not return the expected function tool call");

125+

}

126+

expect(toolCall).toMatchObject({

127+

type: "function",

128+

function: { name: "live_probe" },

129+

});

130+

expect(JSON.parse(toolCall.function.arguments)).toEqual({

131+

value: "OPENAI_PROJECTION_OK",

132+

});

133+

}, 45_000);

134+

});