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

推荐订阅源

博客园 - Franky
U
Unit 42
MyScale Blog
MyScale Blog
B
Blog
阮一峰的网络日志
阮一峰的网络日志
量子位
IT之家
IT之家
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Recent Announcements
Recent Announcements
V
Visual Studio Blog
G
Google Developers Blog
Last Week in AI
Last Week in AI
雷峰网
雷峰网
博客园 - 聂微东
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
博客园 - 司徒正美
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏

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(mistral): normalize structured completion content · o...
steipete · 2026-05-08 · via Recent Commits to openclaw:main

@@ -1494,12 +1494,21 @@ async function processOpenAICompletionsStream(

14941494

continue;

14951495

}

14961496

if (choice.delta.content) {

1497-

if (currentBlock?.type === "toolCall") {

1498-

queuePostToolCallDelta({ kind: "text", text: choice.delta.content });

1499-

} else {

1500-

appendTextDelta(choice.delta.content);

1497+

// Structured content can contain visible text and thinking blocks in the

1498+

// same delta, so route each extracted block through the normal stream path.

1499+

const contentDeltas = getCompletionsContentDeltas(choice.delta.content);

1500+

for (const contentDelta of contentDeltas) {

1501+

if (currentBlock?.type === "toolCall") {

1502+

queuePostToolCallDelta(contentDelta);

1503+

} else if (contentDelta.kind === "text") {

1504+

appendTextDelta(contentDelta.text);

1505+

} else {

1506+

appendThinkingDelta(contentDelta);

1507+

}

1508+

}

1509+

if (contentDeltas.length > 0) {

1510+

continue;

15011511

}

1502-

continue;

15031512

}

15041513

const reasoningDeltas = getCompletionsReasoningDeltas(

15051514

choice.delta as Record<string, unknown>,

@@ -1599,6 +1608,49 @@ type CompletionsReasoningDelta =

15991608

text: string;

16001609

};

160116101611+

function getCompletionsContentDeltas(content: unknown): CompletionsReasoningDelta[] {

1612+

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

1613+

return content ? [{ kind: "text", text: content }] : [];

1614+

}

1615+

if (Array.isArray(content)) {

1616+

return content.flatMap((item) => getCompletionsContentDeltas(item));

1617+

}

1618+

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

1619+

return [];

1620+

}

1621+

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

1622+

const type = typeof record.type === "string" ? record.type.toLowerCase() : "";

1623+

// Some OpenAI-compatible providers, notably Mistral thinking models, stream

1624+

// `delta.content` as typed objects. Never coerce those objects directly or

1625+

// they become persisted visible text like "[object Object]".

1626+

const extractText = (value: unknown): string => {

1627+

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

1628+

return value;

1629+

}

1630+

if (Array.isArray(value)) {

1631+

return value.map((item) => extractText(item)).join("");

1632+

}

1633+

if (value && typeof value === "object") {

1634+

const nested = value as Record<string, unknown>;

1635+

return extractText(nested.text ?? nested.content ?? nested.thinking);

1636+

}

1637+

return "";

1638+

};

1639+

const text = extractText(record.text ?? record.content ?? record.thinking);

1640+

if (!text) {

1641+

return [];

1642+

}

1643+

// Preserve provider reasoning as OpenClaw thinking blocks so channel/UI

1644+

// surfaces can decide whether to show it instead of leaking it as answer text.

1645+

if (type.includes("thinking") || type.includes("reasoning")) {

1646+

return [{ kind: "thinking", signature: "content", text }];

1647+

}

1648+

if (type === "text" || type === "output_text" || type.endsWith(".output_text")) {

1649+

return [{ kind: "text", text }];

1650+

}

1651+

return [];

1652+

}

1653+16021654

function getCompletionsReasoningDeltas(

16031655

delta: Record<string, unknown>,

16041656

visibleReasoningDetailTypes: readonly string[],