mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:48:26 +00:00
fix: always drop orphaned OpenAI reasoning blocks in session history
downgradeOpenAIReasoningBlocks was only called on model change, but orphaned reasoning items (e.g. from an aborted stream) can exist without a model switch and cause a 400 from the OpenAI Responses API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
e33017982c
commit
46bf210e04
@@ -204,7 +204,7 @@ describe("sanitizeSessionHistory", () => {
|
|||||||
expect(result.map((msg) => msg.role)).toEqual(["user"]);
|
expect(result.map((msg) => msg.role)).toEqual(["user"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not downgrade openai reasoning when the model has not changed", async () => {
|
it("downgrades orphaned openai reasoning even when the model has not changed", async () => {
|
||||||
const sessionEntries = [
|
const sessionEntries = [
|
||||||
makeModelSnapshotEntry({
|
makeModelSnapshotEntry({
|
||||||
provider: "openai",
|
provider: "openai",
|
||||||
@@ -222,7 +222,7 @@ describe("sanitizeSessionHistory", () => {
|
|||||||
sessionManager,
|
sessionManager,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result).toEqual(messages);
|
expect(result).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("downgrades openai reasoning only when the model changes", async () => {
|
it("downgrades openai reasoning only when the model changes", async () => {
|
||||||
|
|||||||
@@ -457,10 +457,9 @@ export async function sanitizeSessionHistory(params: {
|
|||||||
modelId: params.modelId,
|
modelId: params.modelId,
|
||||||
})
|
})
|
||||||
: false;
|
: false;
|
||||||
const sanitizedOpenAI =
|
const sanitizedOpenAI = isOpenAIResponsesApi
|
||||||
isOpenAIResponsesApi && modelChanged
|
? downgradeOpenAIReasoningBlocks(sanitizedToolResults)
|
||||||
? downgradeOpenAIReasoningBlocks(sanitizedToolResults)
|
: sanitizedToolResults;
|
||||||
: sanitizedToolResults;
|
|
||||||
|
|
||||||
if (hasSnapshot && (!priorSnapshot || modelChanged)) {
|
if (hasSnapshot && (!priorSnapshot || modelChanged)) {
|
||||||
appendModelSnapshot(params.sessionManager, {
|
appendModelSnapshot(params.sessionManager, {
|
||||||
|
|||||||
Reference in New Issue
Block a user