fix: strip orphaned OpenAI reasoning blocks before responses API call… · openclaw/openclaw@6682b12
suboss87
·
2026-04-19
·
via Recent Commits to openclaw:main
3 files changed
lines changed
| Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,7 @@ Docs: https://docs.openclaw.ai
|
99### Fixes
|
1010|
1111- Control UI/cron: keep the runtime-only `last` delivery sentinel from being materialized into persisted cron delivery and failure-alert channel configs when jobs are created or edited. (#68829) Thanks @tianhaocui.
|
12+- OpenAI/Responses: strip orphaned reasoning blocks before outbound Responses API calls so compacted or restored histories no longer fail on standalone reasoning items. (#55787) Thanks @suboss87.
|
1213|
1314## 2026.4.19-beta.2
|
1415|
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -207,6 +207,7 @@ export function downgradeOpenAIFunctionCallReasoningPairs(
|
207207 * is incomplete, drop the block to keep history usable.
|
208208 */
|
209209export function downgradeOpenAIReasoningBlocks(messages: AgentMessage[]): AgentMessage[] {
|
210+let anyChanged = false;
|
210211const out: AgentMessage[] = [];
|
211212|
212213for (const msg of messages) {
|
@@ -259,12 +260,13 @@ export function downgradeOpenAIReasoningBlocks(messages: AgentMessage[]): AgentM
|
259260continue;
|
260261}
|
261262|
263+anyChanged = true;
|
262264if (nextContent.length === 0) {
|
263265continue;
|
264266}
|
265267|
266268out.push({ ...assistantMsg, content: nextContent } as AgentMessage);
|
267269}
|
268270|
269-return out;
|
271+return anyChanged ? out : messages;
|
270272}
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -72,6 +72,7 @@ import {
|
7272import type { EmbeddedContextFile } from "../../pi-embedded-helpers.js";
|
7373import {
|
7474downgradeOpenAIFunctionCallReasoningPairs,
|
75+downgradeOpenAIReasoningBlocks,
|
7576isCloudCodeAssistFormatError,
|
7677resolveBootstrapMaxChars,
|
7778resolveBootstrapPromptTruncationWarningMode,
|
@@ -1367,7 +1368,10 @@ export async function runEmbeddedAttempt(
|
13671368if (!Array.isArray(messages)) {
|
13681369return inner(model, context, options);
|
13691370}
|
1370-const sanitized = downgradeOpenAIFunctionCallReasoningPairs(messages as AgentMessage[]);
|
1371+// Strip orphaned reasoning blocks first, then fix function-call
|
1372+// pairing — matches the call order in google.ts.
|
1373+const reasoningSanitized = downgradeOpenAIReasoningBlocks(messages as AgentMessage[]);
|
1374+const sanitized = downgradeOpenAIFunctionCallReasoningPairs(reasoningSanitized);
|
13711375if (sanitized === messages) {
|
13721376return inner(model, context, options);
|
13731377}
|
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。