From 47402ddaf78d4ea95fbfcb5ac020e6254cc61efe Mon Sep 17 00:00:00 2001 From: Ahmed Kamal Date: Tue, 6 Jan 2026 01:50:58 +0200 Subject: [PATCH] fix(ai): always include reasoning.encrypted_content for codex (#484) --- .../openai-codex/request-transformer.ts | 4 ++- packages/ai/test/openai-codex-include.test.ts | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 packages/ai/test/openai-codex-include.test.ts diff --git a/packages/ai/src/providers/openai-codex/request-transformer.ts b/packages/ai/src/providers/openai-codex/request-transformer.ts index 1decd3e6..d0f48510 100644 --- a/packages/ai/src/providers/openai-codex/request-transformer.ts +++ b/packages/ai/src/providers/openai-codex/request-transformer.ts @@ -323,7 +323,9 @@ export async function transformRequestBody( verbosity: options.textVerbosity || "medium", }; - body.include = options.include || ["reasoning.encrypted_content"]; + const include = Array.isArray(options.include) ? [...options.include] : []; + include.push("reasoning.encrypted_content"); + body.include = Array.from(new Set(include)); delete body.max_output_tokens; delete body.max_completion_tokens; diff --git a/packages/ai/test/openai-codex-include.test.ts b/packages/ai/test/openai-codex-include.test.ts new file mode 100644 index 00000000..2fab66c1 --- /dev/null +++ b/packages/ai/test/openai-codex-include.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, it } from "vitest"; +import { type RequestBody, transformRequestBody } from "../src/providers/openai-codex/request-transformer.js"; + +describe("openai-codex include handling", () => { + it("always includes reasoning.encrypted_content when caller include is custom", async () => { + const body: RequestBody = { + model: "gpt-5.1-codex", + }; + + const transformed = await transformRequestBody(body, "CODEX_INSTRUCTIONS", { include: ["foo"] }, true); + expect(transformed.include).toEqual(["foo", "reasoning.encrypted_content"]); + }); + + it("does not duplicate reasoning.encrypted_content", async () => { + const body: RequestBody = { + model: "gpt-5.1-codex", + }; + + const transformed = await transformRequestBody( + body, + "CODEX_INSTRUCTIONS", + { include: ["foo", "reasoning.encrypted_content"] }, + true, + ); + expect(transformed.include).toEqual(["foo", "reasoning.encrypted_content"]); + }); +});