fix(agents): unblock gpt-5.3-codex API-key routing and replay (#31083)

* fix(agents): unblock gpt-5.3-codex API-key replay path

* fix(agents): scope OpenAI replay ID rewrites per turn

* test: fix nodes-tool mock typing and reformat telegram accounts
This commit is contained in:
Charles Dusek
2026-03-01 21:45:12 -06:00
committed by GitHub
parent e1bf9591c3
commit 92199ac129
9 changed files with 347 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import {
downgradeOpenAIFunctionCallReasoningPairs,
downgradeOpenAIReasoningBlocks,
isMessagingToolDuplicate,
normalizeTextForComparison,
@@ -318,6 +319,125 @@ describe("downgradeOpenAIReasoningBlocks", () => {
});
});
describe("downgradeOpenAIFunctionCallReasoningPairs", () => {
it("strips fc ids when reasoning cannot be replayed", () => {
const input = [
{
role: "assistant",
content: [{ type: "toolCall", id: "call_123|fc_123", name: "read", arguments: {} }],
},
{
role: "toolResult",
toolCallId: "call_123|fc_123",
toolName: "read",
content: [{ type: "text", text: "ok" }],
},
];
// oxlint-disable-next-line typescript/no-explicit-any
expect(downgradeOpenAIFunctionCallReasoningPairs(input as any)).toEqual([
{
role: "assistant",
content: [{ type: "toolCall", id: "call_123", name: "read", arguments: {} }],
},
{
role: "toolResult",
toolCallId: "call_123",
toolName: "read",
content: [{ type: "text", text: "ok" }],
},
]);
});
it("keeps fc ids when replayable reasoning is present", () => {
const input = [
{
role: "assistant",
content: [
{
type: "thinking",
thinking: "internal",
thinkingSignature: JSON.stringify({ id: "rs_123", type: "reasoning" }),
},
{ type: "toolCall", id: "call_123|fc_123", name: "read", arguments: {} },
],
},
{
role: "toolResult",
toolCallId: "call_123|fc_123",
toolName: "read",
content: [{ type: "text", text: "ok" }],
},
];
// oxlint-disable-next-line typescript/no-explicit-any
expect(downgradeOpenAIFunctionCallReasoningPairs(input as any)).toEqual(input);
});
it("only rewrites tool results paired to the downgraded assistant turn", () => {
const input = [
{
role: "assistant",
content: [{ type: "toolCall", id: "call_123|fc_123", name: "read", arguments: {} }],
},
{
role: "toolResult",
toolCallId: "call_123|fc_123",
toolName: "read",
content: [{ type: "text", text: "turn1" }],
},
{
role: "assistant",
content: [
{
type: "thinking",
thinking: "internal",
thinkingSignature: JSON.stringify({ id: "rs_123", type: "reasoning" }),
},
{ type: "toolCall", id: "call_123|fc_123", name: "read", arguments: {} },
],
},
{
role: "toolResult",
toolCallId: "call_123|fc_123",
toolName: "read",
content: [{ type: "text", text: "turn2" }],
},
];
// oxlint-disable-next-line typescript/no-explicit-any
expect(downgradeOpenAIFunctionCallReasoningPairs(input as any)).toEqual([
{
role: "assistant",
content: [{ type: "toolCall", id: "call_123", name: "read", arguments: {} }],
},
{
role: "toolResult",
toolCallId: "call_123",
toolName: "read",
content: [{ type: "text", text: "turn1" }],
},
{
role: "assistant",
content: [
{
type: "thinking",
thinking: "internal",
thinkingSignature: JSON.stringify({ id: "rs_123", type: "reasoning" }),
},
{ type: "toolCall", id: "call_123|fc_123", name: "read", arguments: {} },
],
},
{
role: "toolResult",
toolCallId: "call_123|fc_123",
toolName: "read",
content: [{ type: "text", text: "turn2" }],
},
]);
});
});
describe("normalizeTextForComparison", () => {
it.each([
{ input: "Hello World", expected: "hello world" },