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

推荐订阅源

U
Unit 42
罗磊的独立博客
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
A
About on SuperTechFans
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
IT之家
IT之家
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
月光博客
月光博客
T
Tailwind CSS Blog
The Cloudflare Blog
Hugging Face - Blog
Hugging Face - 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: normalize malformed assistant replay content (#82748...
steipete · 2026-05-17 · via Recent Commits to openclaw:main

File tree

  • src/agents/pi-embedded-runner

Original file line numberDiff line numberDiff line change

@@ -33,6 +33,7 @@ Docs: https://docs.openclaw.ai

3333

- System prompts: clarify MEMORY guidance over generic TTS hints in the embedded speech-core/system-prompt scaffolding so agents prefer memory-store usage over speech defaults. Fixes #81930. Thanks @giodl73-repo.

3434

- Agents/auth: include the checked credential source in missing API key errors, so users can see which env var, profile, or config path to fix. Fixes #82785. Thanks @loeclos.

3535

- Providers/GitHub Copilot: hash Responses replay item ids with sha256 instead of a weak 32-bit hash and build same-provider Copilot tool-call ids distinctly, so concurrent tool-call replays no longer collide and reject follow-up turns.

36+

- Agents/replay: normalize malformed assistant replay content before transport conversion while preserving empty-stop replay repair, so bad provider history no longer crashes with non-iterable content. Fixes #43795. (#82748) Thanks @IWhatsskill.

3637

- Providers/Anthropic-messages: extract `reasoning_content` from `thinking` blocks during assistant replay so proxy providers that route through the Anthropic-messages transport preserve reasoning context across tool-call follow-up turns. Thanks @Sunnyone2three.

3738

- Agents/GitHub Copilot: normalize replayed Responses tool-call IDs before dispatch so resumed sessions with historical overlong tool IDs continue instead of failing Copilot schema validation. (#82750) Thanks @galiniliev.

3839

- CLI/web: resolve provider-scoped web search/fetch SecretRefs for `infer web ... --provider ...` while leaving unrelated plugin secrets untouched. Fixes #82621. Thanks @leno23.

Original file line numberDiff line numberDiff line change

@@ -126,6 +126,15 @@ describe("normalizeAssistantReplayContent", () => {

126126

expect(repaired.content).toEqual([{ type: "text", text: FALLBACK_TEXT }]);

127127

});

128128
129+

it("converts mid-turn zero-usage null stop turns to a replay sentinel", () => {

130+

const falseSuccessStop = bedrockAssistant(null, "stop");

131+

const messages = [userMessage("hello"), falseSuccessStop, userMessage("retry")];

132+

const out = normalizeAssistantReplayContent(messages);

133+

expect(out).not.toBe(messages);

134+

const repaired = out[1] as AgentMessage & { content: { type: string; text: string }[] };

135+

expect(repaired.content).toEqual([{ type: "text", text: FALLBACK_TEXT }]);

136+

});

137+
129138

it("preserves empty content with non-error stopReasons (toolUse, length) untouched", () => {

130139

// Boundary lock: only `stopReason:"error"` should trip the sentinel

131140

// substitution. `toolUse` and `length` are reachable in practice when a

Original file line numberDiff line numberDiff line change

@@ -59,6 +59,7 @@ type ModelSnapshotEntry = {

5959

modelApi?: string | null;

6060

modelId?: string;

6161

};

62+

type AssistantReplayMessage = Extract<AgentMessage, { role: "assistant" }>;

6263
6364

type ProviderReplayHookParams = {

6465

config?: OpenClawConfig;

@@ -355,7 +356,7 @@ export function normalizeAssistantReplayContent(messages: AgentMessage[]): Agent

355356

touched = true;

356357

continue;

357358

}

358-

let assistantMessage = message;

359+

let assistantMessage: AssistantReplayMessage = message;

359360

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

360361

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

361362

const normalized = normalizeAssistantReplayTextContent(message, replayContent);

@@ -368,7 +369,7 @@ export function normalizeAssistantReplayContent(messages: AgentMessage[]): Agent

368369

if (!Array.isArray(replayContent)) {

369370

replayContent =

370371

replayContent != null && typeof replayContent === "object" ? [replayContent] : [];

371-

assistantMessage = { ...message, content: replayContent } as AgentMessage;

372+

assistantMessage = { ...message, content: replayContent } as AssistantReplayMessage;

372373

touched = true;

373374

}

374375

if (Array.isArray(replayContent)) {

@@ -398,10 +399,10 @@ export function normalizeAssistantReplayContent(messages: AgentMessage[]): Agent

398399

// or completion and no content. Leaving other non-error empty-content

399400

// turns untouched preserves silent-reply semantics on every other code

400401

// path.

401-

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

402-

if (stopReason === "error" || isZeroUsageEmptyStopAssistantTurn(message)) {

402+

const stopReason = (assistantMessage as { stopReason?: unknown }).stopReason;

403+

if (stopReason === "error" || isZeroUsageEmptyStopAssistantTurn(assistantMessage)) {

403404

out.push({

404-

...message,

405+

...assistantMessage,

405406

content: [{ type: "text", text: STREAM_ERROR_FALLBACK_TEXT }],

406407

});

407408

touched = true;