From 8bdea8c8b3c99232538b3213412c480ecb0514c7 Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Tue, 30 Sep 2025 10:04:22 -0700 Subject: [PATCH 1/2] Test that the tread can be continued with extra params --- sdk/typescript/tests/responsesProxy.ts | 1 + sdk/typescript/tests/run.test.ts | 49 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/sdk/typescript/tests/responsesProxy.ts b/sdk/typescript/tests/responsesProxy.ts index 5c7815b538..7fcdc9c715 100644 --- a/sdk/typescript/tests/responsesProxy.ts +++ b/sdk/typescript/tests/responsesProxy.ts @@ -25,6 +25,7 @@ export type ResponsesProxy = { }; export type ResponsesApiRequest = { + model?: string; input: Array<{ role: string; content?: Array<{ type: string; text: string }>; diff --git a/sdk/typescript/tests/run.test.ts b/sdk/typescript/tests/run.test.ts index 093adee40e..ccb468a2df 100644 --- a/sdk/typescript/tests/run.test.ts +++ b/sdk/typescript/tests/run.test.ts @@ -85,6 +85,54 @@ describe("Codex", () => { } }); + + + it("continues the thread when run is called twice with options", async () => { + const { url, close, requests } = await startResponsesTestProxy({ + statusCode: 200, + responseBodies: [ + sse( + responseStarted("response_1"), + assistantMessage("First response", "item_1"), + responseCompleted("response_1"), + ), + sse( + responseStarted("response_2"), + assistantMessage("Second response", "item_2"), + responseCompleted("response_2"), + ), + ], + }); + + try { + const client = new Codex({ executablePath: codexExecPath, baseUrl: url, apiKey: "test" }); + + const thread = client.startThread(); + await thread.run("first input"); + await thread.run("second input", { + model: "gpt-test-1", + }); + + // Check second request continues the same thread + expect(requests.length).toBeGreaterThanOrEqual(2); + const secondRequest = requests[1]; + expect(secondRequest).toBeDefined(); + const payload = secondRequest!.json; + + expect(payload.model).toBe("gpt-test-1"); + const assistantEntry = payload.input.find( + (entry: { role: string }) => entry.role === "assistant", + ); + expect(assistantEntry).toBeDefined(); + const assistantText = assistantEntry?.content?.find( + (item: { type: string; text: string }) => item.type === "output_text", + )?.text; + expect(assistantText).toBe("First response"); + } finally { + await close(); + } + }); + it("resumes thread by id", async () => { const { url, close, requests } = await startResponsesTestProxy({ statusCode: 200, @@ -132,6 +180,7 @@ describe("Codex", () => { } }); + it("passes turn options to exec", async () => { const { url, close, requests } = await startResponsesTestProxy({ statusCode: 200, From 7268927ba47f004f3a1c9dcabba664c0b92f598e Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Tue, 30 Sep 2025 10:09:50 -0700 Subject: [PATCH 2/2] Update run.test.ts --- sdk/typescript/tests/run.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/sdk/typescript/tests/run.test.ts b/sdk/typescript/tests/run.test.ts index ccb468a2df..67b1f3d2cf 100644 --- a/sdk/typescript/tests/run.test.ts +++ b/sdk/typescript/tests/run.test.ts @@ -85,8 +85,6 @@ describe("Codex", () => { } }); - - it("continues the thread when run is called twice with options", async () => { const { url, close, requests } = await startResponsesTestProxy({ statusCode: 200, @@ -180,7 +178,6 @@ describe("Codex", () => { } }); - it("passes turn options to exec", async () => { const { url, close, requests } = await startResponsesTestProxy({ statusCode: 200,