From d0dd8430f7fe5750dc486662b29a1d135c090f37 Mon Sep 17 00:00:00 2001 From: can1357 Date: Sun, 26 Apr 2026 02:54:40 +0200 Subject: [PATCH] fix: major codex regression, wth?? --- .../src/providers/openai-codex-responses.ts | 26 ++----------------- packages/coding-agent/src/tools/image-gen.ts | 8 ++++-- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/packages/ai/src/providers/openai-codex-responses.ts b/packages/ai/src/providers/openai-codex-responses.ts index a0bedb6d5..30331b8f3 100644 --- a/packages/ai/src/providers/openai-codex-responses.ts +++ b/packages/ai/src/providers/openai-codex-responses.ts @@ -75,27 +75,6 @@ export interface OpenAICodexResponsesOptions extends StreamOptions { serviceTier?: ServiceTier; } -export const CODEX_INSTRUCTIONS = `You are an expert coding assistant operating inside pi, a coding agent harness.`; - -export interface CodexSystemPrompt { - instructions: string; - developerMessages: string[]; -} - -export function buildCodexSystemPrompt(args: { userSystemPrompt?: string }): CodexSystemPrompt { - const { userSystemPrompt } = args; - const developerMessages: string[] = []; - - if (userSystemPrompt && userSystemPrompt.trim().length > 0) { - developerMessages.push(userSystemPrompt.trim()); - } - - return { - instructions: CODEX_INSTRUCTIONS, - developerMessages, - }; -} - const CODEX_DEBUG = $flag("PI_CODEX_DEBUG"); const CODEX_MAX_RETRIES = 5; const CODEX_RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504]); @@ -537,8 +516,7 @@ async function buildTransformedCodexRequestBody( } } - const systemPrompt = buildCodexSystemPrompt({ userSystemPrompt: context.systemPrompt }); - params.instructions = systemPrompt.instructions; + params.instructions = context.systemPrompt; const codexOptions: CodexRequestOptions = { reasoningEffort: options?.reasoning, @@ -547,7 +525,7 @@ async function buildTransformedCodexRequestBody( include: options?.include, }; - return transformRequestBody(params, model, codexOptions, systemPrompt); + return transformRequestBody(params, model, codexOptions); } async function openInitialCodexEventStream( diff --git a/packages/coding-agent/src/tools/image-gen.ts b/packages/coding-agent/src/tools/image-gen.ts index c31f22d29..32651f6dd 100644 --- a/packages/coding-agent/src/tools/image-gen.ts +++ b/packages/coding-agent/src/tools/image-gen.ts @@ -8,7 +8,6 @@ import { OPENAI_HEADERS, URL_PATHS, } from "@oh-my-pi/pi-ai/providers/openai-codex/constants"; -import { CODEX_INSTRUCTIONS } from "@oh-my-pi/pi-ai/providers/openai-codex-responses"; import { $env, isEnoent, @@ -692,7 +691,12 @@ function buildOpenAIHostedImageRequest( tools: [tool], tool_choice: { type: "image_generation" }, store: false, - ...(stream ? { instructions: CODEX_INSTRUCTIONS } : {}), + ...(stream + ? { + instructions: + "You are an AI image generator. Generate images based on user descriptions. Focus on creating high-quality, visually appealing images that match the user's request.", + } + : {}), ...(stream ? { stream: true } : {}), }; }