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

推荐订阅源

J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
雷峰网
雷峰网
T
Tailwind CSS Blog
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
博客园 - 司徒正美
I
InfoQ
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
小众软件
小众软件
U
Unit 42
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net

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(gateway): preserve mixed assistant history text · ope...
BunsDev · 2026-05-06 · via Recent Commits to openclaw:main

@@ -163,6 +163,39 @@ function sanitizeAssistantPhasedContentBlocks(content: unknown[]): {

163163

};

164164

}

165165166+

function projectAssistantTextFromMixedToolContent(

167+

content: unknown[],

168+

maxChars: number,

169+

): { content: unknown[]; changed: boolean } | null {

170+

const hasToolHistoryBlock = content.some((block) => {

171+

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

172+

return false;

173+

}

174+

return isToolHistoryBlockType((block as { type?: unknown }).type);

175+

});

176+

if (!hasToolHistoryBlock) {

177+

return null;

178+

}

179+180+

const textBlocks: unknown[] = [];

181+

for (const block of content) {

182+

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

183+

continue;

184+

}

185+

const entry = block as { type?: unknown; text?: unknown };

186+

if (entry.type !== "text" || typeof entry.text !== "string" || !entry.text.trim()) {

187+

continue;

188+

}

189+

const stripped = stripInlineDirectiveTagsForDisplay(entry.text);

190+

const truncated = truncateChatHistoryText(stripped.text, maxChars);

191+

if (truncated.text.trim()) {

192+

textBlocks.push({ type: "text", text: truncated.text });

193+

}

194+

}

195+196+

return textBlocks.length > 0 ? { content: textBlocks, changed: true } : null;

197+

}

198+166199

function toFiniteNumber(x: unknown): number | undefined {

167200

return typeof x === "number" && Number.isFinite(x) ? x : undefined;

168201

}

@@ -285,10 +318,19 @@ function sanitizeChatHistoryMessage(

285318

changed = true;

286319

}

287320

if (entry.role === "assistant" && Array.isArray(entry.content)) {

288-

const sanitizedPhases = sanitizeAssistantPhasedContentBlocks(entry.content);

289-

if (sanitizedPhases.changed) {

290-

entry.content = sanitizedPhases.content;

321+

const mixedToolText = projectAssistantTextFromMixedToolContent(entry.content, maxChars);

322+

if (mixedToolText) {

323+

entry.content = mixedToolText.content;

324+

if (entry.phase === "commentary") {

325+

delete entry.phase;

326+

}

291327

changed = true;

328+

} else {

329+

const sanitizedPhases = sanitizeAssistantPhasedContentBlocks(entry.content);

330+

if (sanitizedPhases.changed) {

331+

entry.content = sanitizedPhases.content;

332+

changed = true;

333+

}

292334

}

293335

}

294336

}

@@ -353,6 +395,31 @@ function hasAssistantNonTextContent(message: unknown): boolean {

353395

);

354396

}

355397398+

function hasAssistantMixedToolVisibleText(message: unknown): boolean {

399+

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

400+

return false;

401+

}

402+

const content = (message as { content?: unknown }).content;

403+

if (!Array.isArray(content)) {

404+

return false;

405+

}

406+

let hasToolHistoryBlock = false;

407+

let hasText = false;

408+

for (const block of content) {

409+

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

410+

continue;

411+

}

412+

const entry = block as { type?: unknown; text?: unknown };

413+

if (isToolHistoryBlockType(entry.type)) {

414+

hasToolHistoryBlock = true;

415+

}

416+

if (entry.type === "text" && typeof entry.text === "string" && entry.text.trim()) {

417+

hasText = true;

418+

}

419+

}

420+

return hasToolHistoryBlock && hasText;

421+

}

422+356423

function shouldDropAssistantHistoryMessage(message: unknown): boolean {

357424

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

358425

return false;

@@ -362,7 +429,7 @@ function shouldDropAssistantHistoryMessage(message: unknown): boolean {

362429

return false;

363430

}

364431

if (resolveAssistantMessagePhase(message) === "commentary") {

365-

return true;

432+

return !hasAssistantMixedToolVisibleText(message);

366433

}

367434

const text = extractAssistantTextForSilentCheck(message);

368435

if (text === undefined || !isSuppressedControlReplyText(text)) {