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

推荐订阅源

博客园_首页
爱范儿
爱范儿
罗磊的独立博客
V
V2EX
量子位
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
Jina AI
Jina AI
博客园 - 叶小钗
小众软件
小众软件
博客园 - 【当耐特】
Y
Y Combinator Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
博客园 - 聂微东
Microsoft Security Blog
Microsoft Security Blog
美团技术团队
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
有赞技术团队
有赞技术团队
MongoDB | Blog
MongoDB | Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell

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(agents): strip stale anthropic assistant prefill · op...
steipete · 2026-04-27 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

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

1818

- Agents/sessions: acquire the session write lock only after cold bootstrap, plugin, and tool setup so fallback runs are not blocked by stalled pre-model startup work. Thanks @codex.

1919

- Gateway/models: skip external OpenRouter and LiteLLM pricing refreshes for local/self-hosted model endpoints so startup does not wait on remote pricing catalogs for local-only Ollama, vLLM, and compatible providers. Thanks @codex.

2020

- CLI/plugins: stop security-blocked plugin installs from retrying as hook packs, so normal plugin packages report the scanner failure without a misleading "not a valid hook pack" follow-up. Fixes #61175; supersedes #64102. Thanks @KonsultDigital and @ziyincody.

21+

- Agents/Anthropic: strip stale trailing assistant prefill turns from outbound replay so context-engine short circuits cannot send unsupported assistant-prefill payloads to provider APIs. Fixes #72556. Thanks @Veda-openclaw.

2122

- Control UI/Dreaming: require explicit confirmation before applying restart-impacting Dreaming mode changes, with restart warning copy and loading feedback. Fixes #63804. (#63807) Thanks @bbddbb1.

2223

- CLI/update: keep the automatic post-update completion refresh on the core-command tree so it no longer stages bundled plugin runtime deps before the Gateway restart path, avoiding `.24` update hangs and 1006 disconnect cascades. Fixes #72665. Thanks @sakalaboator and @He-Pin.

2324

- Agents/Bedrock: stop heartbeat runs from persisting blank user transcript turns and repair existing blank user text messages before replay, preventing AWS Bedrock `ContentBlock` blank-text validation failures. Fixes #72640 and #72622. Thanks @goldzulu.

Original file line numberDiff line numberDiff line change

@@ -1633,6 +1633,44 @@ describe("wrapStreamFnSanitizeMalformedToolCalls", () => {

16331633

expect(seenContext.messages).toBe(messages);

16341634

});

16351635
1636+

it("strips trailing assistant prefill turns for Anthropic outbound replay", async () => {

1637+

const messages = [

1638+

{

1639+

role: "user",

1640+

content: [{ type: "text", text: "earlier question" }],

1641+

},

1642+

{

1643+

role: "assistant",

1644+

content: [{ type: "text", text: "stale assistant answer" }],

1645+

},

1646+

];

1647+

const baseFn = vi.fn((_model, _context) =>

1648+

createFakeStream({ events: [], resultMessage: { role: "assistant", content: [] } }),

1649+

);

1650+
1651+

const wrapped = wrapStreamFnSanitizeMalformedToolCalls(baseFn as never, new Set(["read"]), {

1652+

validateAnthropicTurns: true,

1653+

preserveSignatures: true,

1654+

dropThinkingBlocks: false,

1655+

} as never);

1656+

const stream = wrapped(

1657+

{ api: "anthropic-messages" } as never,

1658+

{ messages } as never,

1659+

{} as never,

1660+

) as FakeWrappedStream | Promise<FakeWrappedStream>;

1661+

await Promise.resolve(stream);

1662+
1663+

expect(baseFn).toHaveBeenCalledTimes(1);

1664+

const seenContext = baseFn.mock.calls[0]?.[1] as { messages: unknown[] };

1665+

expect(seenContext.messages).toEqual([

1666+

{

1667+

role: "user",

1668+

content: [{ type: "text", text: "earlier question" }],

1669+

},

1670+

]);

1671+

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

1672+

});

1673+
16361674

it("drops signed thinking turns when sibling replay tool calls are not allowlisted", async () => {

16371675

const messages = [

16381676

{

Original file line numberDiff line numberDiff line change

@@ -525,6 +525,32 @@ function sanitizeAnthropicReplayToolResults(

525525

return changed ? out : messages;

526526

}

527527
528+

function assistantTurnHasReplayToolCall(message: AgentMessage): boolean {

529+

if (!message || typeof message !== "object" || message.role !== "assistant") {

530+

return false;

531+

}

532+

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

533+

if (!Array.isArray(content)) {

534+

return false;

535+

}

536+

return content.some((block) => isReplayToolCallBlock(block));

537+

}

538+
539+

function stripTrailingAssistantPrefillTurns(messages: AgentMessage[]): AgentMessage[] {

540+

let end = messages.length;

541+

while (end > 0) {

542+

const message = messages[end - 1];

543+

if (!message || typeof message !== "object" || message.role !== "assistant") {

544+

break;

545+

}

546+

if (assistantTurnHasReplayToolCall(message)) {

547+

break;

548+

}

549+

end -= 1;

550+

}

551+

return end === messages.length ? messages : messages.slice(0, end);

552+

}

553+
528554

function normalizeToolCallIdsInMessage(message: unknown): void {

529555

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

530556

return;

@@ -873,6 +899,7 @@ export function wrapStreamFnSanitizeMalformedToolCalls(

873899

nextMessages = sanitizeAnthropicReplayToolResults(nextMessages, {

874900

disallowEmbeddedUserToolResultsForSignedThinkingReplay: allowProviderOwnedThinkingReplay,

875901

});

902+

nextMessages = stripTrailingAssistantPrefillTurns(nextMessages);

876903

}

877904

if (nextMessages === messages) {

878905

return baseFn(model, context, options);