From a3cd7c82bc060d0da5761e1770ac0b557af047aa Mon Sep 17 00:00:00 2001 From: deranalabs <113621505+deranalabs@users.noreply.github.com> Date: Tue, 7 Jul 2026 11:48:55 +0700 Subject: [PATCH] fix(translator): preserve developer instructions in openai-responses conversion (#2434) Map role="developer" messages to top-level instructions alongside role="system" in openaiToOpenAIResponsesRequest. Previously developer messages matched no branch and were silently dropped from the Responses request, losing GPT-5/Codex system-level prompts. Co-authored-by: Cursor --- open-sse/translator/request/openai-responses.js | 7 ++++--- tests/translator/bugs-codexCli-responses.test.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/open-sse/translator/request/openai-responses.js b/open-sse/translator/request/openai-responses.js index 98c516cd..23603a71 100644 --- a/open-sse/translator/request/openai-responses.js +++ b/open-sse/translator/request/openai-responses.js @@ -221,13 +221,14 @@ export function openaiToOpenAIResponsesRequest(model, body, stream, credentials) const messages = body.messages || []; for (const msg of messages) { - if (msg.role === ROLE.SYSTEM) { - // Use first system message as instructions + if (msg.role === ROLE.SYSTEM || msg.role === ROLE.DEVELOPER) { + // Use the first instruction-bearing message as instructions. + // OpenAI recommends role="developer" for GPT-5/Codex as the system-level prompt. if (!hasSystemMessage) { result.instructions = typeof msg.content === "string" ? msg.content : ""; hasSystemMessage = true; } - continue; // Skip system messages in input + continue; // Skip instruction messages in input } // Convert user/assistant messages to input items diff --git a/tests/translator/bugs-codexCli-responses.test.js b/tests/translator/bugs-codexCli-responses.test.js index 6f947833..c3401341 100644 --- a/tests/translator/bugs-codexCli-responses.test.js +++ b/tests/translator/bugs-codexCli-responses.test.js @@ -46,6 +46,20 @@ describe("Codex CLI Responses → OpenAI", () => { }); describe("OpenAI → Codex Responses (reverse)", () => { + it("maps developer messages to Responses API instructions", () => { + const out = O2R({ + messages: [ + { role: "developer", content: "Follow the project rules." }, + { role: "user", content: "Hello" }, + ], + }); + + expect(out.instructions).toBe("Follow the project rules."); + expect(out.input).toEqual([ + { type: "message", role: "user", content: [{ type: "input_text", text: "Hello" }] }, + ]); + }); + // openai-responses.js:13 — clampCallId NOT applied on Responses→Chat; but here Chat→Responses must clamp it("call_id longer than 64 chars is clamped", () => { const longId = "call_" + "x".repeat(80);