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

推荐订阅源

罗磊的独立博客
G
Google Developers Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
有赞技术团队
有赞技术团队
Vercel News
Vercel News
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
The Cloudflare Blog
B
Blog
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
U
Unit 42
D
Docker
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
博客园 - Franky
A
About on SuperTechFans

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: preserve OpenAI encrypted reasoning replay · opencla...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -28,6 +28,9 @@ type ReplayableReasoningItem = Extract<InputItem, { type: "reasoning" }>;

2828

type ReplayableReasoningSignature = {

2929

type: "reasoning" | `reasoning.${string}`;

3030

id?: string;

31+

content?: unknown;

32+

encrypted_content?: string;

33+

summary?: unknown;

3134

};

3235

type ToolCallReplayId = { callId: string; itemId?: string };

3336

export type PlannedTurnInput = {

@@ -166,18 +169,35 @@ function toReplayableReasoningId(value: unknown): string | null {

166169

return id && id.startsWith("rs_") ? id : null;

167170

}

168171169-

function toReasoningSignature(value: unknown): ReplayableReasoningSignature | null {

172+

function toReasoningSignature(

173+

value: unknown,

174+

options?: { requireReplayableId?: boolean },

175+

): ReplayableReasoningSignature | null {

170176

if (!value || typeof value !== "object") {

171177

return null;

172178

}

173-

const record = value as { type?: unknown; id?: unknown };

179+

const record = value as {

180+

type?: unknown;

181+

id?: unknown;

182+

content?: unknown;

183+

encrypted_content?: unknown;

184+

summary?: unknown;

185+

};

174186

if (!isReplayableReasoningType(record.type)) {

175187

return null;

176188

}

177189

const reasoningId = toReplayableReasoningId(record.id);

190+

if (options?.requireReplayableId && !reasoningId) {

191+

return null;

192+

}

178193

return {

179194

type: record.type,

180195

...(reasoningId ? { id: reasoningId } : {}),

196+

...(record.content !== undefined ? { content: record.content } : {}),

197+

...(typeof record.encrypted_content === "string"

198+

? { encrypted_content: record.encrypted_content }

199+

: {}),

200+

...(record.summary !== undefined ? { summary: record.summary } : {}),

181201

};

182202

}

183203

@@ -186,28 +206,18 @@ function encodeThinkingSignature(signature: ReplayableReasoningSignature): strin

186206

}

187207188208

function parseReasoningItem(value: unknown): ReplayableReasoningItem | null {

189-

if (!value || typeof value !== "object") {

190-

return null;

191-

}

192-

const record = value as {

193-

type?: unknown;

194-

id?: unknown;

195-

content?: unknown;

196-

encrypted_content?: unknown;

197-

summary?: unknown;

198-

};

199-

if (!isReplayableReasoningType(record.type)) {

209+

const signature = toReasoningSignature(value);

210+

if (!signature) {

200211

return null;

201212

}

202-

const reasoningId = toReplayableReasoningId(record.id);

203213

return {

204214

type: "reasoning",

205-

...(reasoningId ? { id: reasoningId } : {}),

206-

...(typeof record.content === "string" ? { content: record.content } : {}),

207-

...(typeof record.encrypted_content === "string"

208-

? { encrypted_content: record.encrypted_content }

215+

...(signature.id ? { id: signature.id } : {}),

216+

...(signature.content !== undefined ? { content: signature.content } : {}),

217+

...(signature.encrypted_content !== undefined

218+

? { encrypted_content: signature.encrypted_content }

209219

: {}),

210-

...(typeof record.summary === "string" ? { summary: record.summary } : {}),

220+

...(signature.summary !== undefined ? { summary: signature.summary } : {}),

211221

};

212222

}

213223

@@ -216,8 +226,7 @@ function parseThinkingSignature(value: unknown): ReplayableReasoningItem | null

216226

return null;

217227

}

218228

try {

219-

const signature = toReasoningSignature(JSON.parse(value));

220-

return signature ? parseReasoningItem(signature) : null;

229+

return parseReasoningItem(JSON.parse(value));

221230

} catch {

222231

return null;

223232

}

@@ -271,7 +280,25 @@ function extractResponseReasoningText(item: unknown): string {

271280

if (summaryText) {

272281

return summaryText;

273282

}

274-

return normalizeOptionalString(record.content) ?? "";

283+

if (typeof record.content === "string") {

284+

return normalizeOptionalString(record.content) ?? "";

285+

}

286+

if (Array.isArray(record.content)) {

287+

return record.content

288+

.map((part) => {

289+

if (typeof part === "string") {

290+

return part.trim();

291+

}

292+

if (!part || typeof part !== "object") {

293+

return "";

294+

}

295+

return normalizeOptionalString((part as { text?: unknown }).text) ?? "";

296+

})

297+

.filter(Boolean)

298+

.join("\n")

299+

.trim();

300+

}

301+

return "";

275302

}

276303277304

export function convertTools(

@@ -573,21 +600,16 @@ export function buildAssistantMessageFromResponse(

573600

if (!isReplayableReasoningType(item.type)) {

574601

continue;

575602

}

603+

const reasoningSignature = toReasoningSignature(item, { requireReplayableId: true });

576604

const reasoning = extractResponseReasoningText(item);

577-

if (!reasoning) {

605+

if (!reasoning && !reasoningSignature) {

578606

continue;

579607

}

580-

const reasoningId = toReplayableReasoningId(item.id);

581608

content.push({

582609

type: "thinking",

583610

thinking: reasoning,

584-

...(reasoningId

585-

? {

586-

thinkingSignature: encodeThinkingSignature({

587-

id: reasoningId,

588-

type: item.type,

589-

}),

590-

}

611+

...(reasoningSignature

612+

? { thinkingSignature: encodeThinkingSignature(reasoningSignature) }

591613

: {}),

592614

} as AssistantMessage["content"][number]);

593615

}