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

推荐订阅源

IT之家
IT之家
Y
Y Combinator Blog
月光博客
月光博客
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
博客园 - 司徒正美
V
Visual Studio Blog
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
A
About on SuperTechFans
The Cloudflare Blog

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): guard post-hook tool payloads (#92928) · ope...
steipete · 2026-06-14 · via Recent Commits to openclaw:main

@@ -2,11 +2,13 @@ import OpenAI from "openai";

22

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

33

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

44

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

5+

import { createCodexNativeWebSearchWrapper } from "../llm/providers/stream-wrappers/openai.js";

56

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

67

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

78

import {

89

buildOpenAICompletionsParams,

910

buildOpenAIResponsesParams,

11+

createOpenAIResponsesTransportStreamFn,

1012

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

11131214

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

@@ -131,4 +133,95 @@ describeLive("OpenAI tool projection live", () => {

131133

value: "OPENAI_PROJECTION_OK",

132134

});

133135

}, 45_000);

136+137+

it("keeps code-mode tools after a payload hook adds an unreadable sibling", async () => {

138+

const model = {

139+

id: modelId,

140+

name: modelId,

141+

api: "openai-responses",

142+

provider: "openai",

143+

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

144+

reasoning: true,

145+

input: ["text"],

146+

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

147+

contextWindow: 200000,

148+

maxTokens: 256,

149+

} satisfies Model<"openai-responses">;

150+

const codeModeContext = {

151+

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

152+

messages: [

153+

{

154+

role: "user",

155+

content: "Call exec with value exactly OPENAI_POST_HOOK_OK.",

156+

timestamp: 1,

157+

},

158+

],

159+

tools: [

160+

{

161+

name: "exec",

162+

description: "Return the requested probe value.",

163+

parameters: {

164+

type: "object",

165+

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

166+

required: ["value"],

167+

additionalProperties: false,

168+

},

169+

},

170+

{

171+

name: "wait",

172+

description: "Wait without doing work.",

173+

parameters: {

174+

type: "object",

175+

properties: {},

176+

additionalProperties: false,

177+

},

178+

},

179+

],

180+

} satisfies Context;

181+

const streamFn = createCodexNativeWebSearchWrapper(createOpenAIResponsesTransportStreamFn(), {

182+

codeModeToolSurfaceEnabled: true,

183+

});

184+

const streamOptions = {

185+

apiKey: OPENAI_KEY,

186+

maxTokens: 128,

187+

reasoning: "low",

188+

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

189+

openclawCodeModeToolSurface: true,

190+

onPayload(payload: unknown) {

191+

const record = payload as Record<string, unknown>;

192+

const tools = record.tools;

193+

if (!Array.isArray(tools) || tools.length !== 2) {

194+

throw new Error("Expected projected exec and wait tools");

195+

}

196+

record.tools = [

197+

tools[0],

198+

{

199+

type: "function",

200+

get function(): { name: string } {

201+

throw new Error("live unreadable post-hook function getter");

202+

},

203+

},

204+

tools[1],

205+

];

206+

return record;

207+

},

208+

} satisfies Parameters<typeof streamFn>[2] & {

209+

reasoning: "low";

210+

toolChoice: { type: "function"; name: string };

211+

openclawCodeModeToolSurface: true;

212+

};

213+

const stream = await Promise.resolve(streamFn(model, codeModeContext, streamOptions));

214+215+

const result = await stream.result();

216+

const toolCall = result.content.find(

217+

(block) => block.type === "toolCall" && block.name === "exec",

218+

);

219+220+

expect(result.stopReason).toBe("toolUse");

221+

expect(toolCall).toMatchObject({

222+

type: "toolCall",

223+

name: "exec",

224+

arguments: { value: "OPENAI_POST_HOOK_OK" },

225+

});

226+

}, 45_000);

134227

});