diff --git a/internal/translator/codex/openai/chat-completions/codex_openai_request.go b/internal/translator/codex/openai/chat-completions/codex_openai_request.go index 6e790ee5..29d9a8a6 100644 --- a/internal/translator/codex/openai/chat-completions/codex_openai_request.go +++ b/internal/translator/codex/openai/chat-completions/codex_openai_request.go @@ -137,6 +137,11 @@ func ConvertOpenAIRequestToCodex(modelName string, inputRawJSON []byte, stream b out, _ = sjson.Set(out, "instructions", systemInstructions) } else { _, instructions := misc.CodexInstructionsForModel(modelName, "") + // Keep this short: upstream validators can reject large instruction blocks. + const maxInstructionsChars = 1024 + if len(instructions) > maxInstructionsChars { + instructions = instructions[:maxInstructionsChars] + "\n...[truncated]..." + } out, _ = sjson.Set(out, "instructions", instructions) } diff --git a/internal/translator/codex/openai/responses/codex_openai-responses_request.go b/internal/translator/codex/openai/responses/codex_openai-responses_request.go index 0532d28f..dea6d945 100644 --- a/internal/translator/codex/openai/responses/codex_openai-responses_request.go +++ b/internal/translator/codex/openai/responses/codex_openai-responses_request.go @@ -94,6 +94,11 @@ func ConvertOpenAIResponsesRequestToCodex(modelName string, inputRawJSON []byte, } // Otherwise, inject standard Codex instructions. + // Keep this short: upstream validators can reject large instruction blocks. + const maxInstructionsChars = 1024 + if len(instructions) > maxInstructionsChars { + instructions = instructions[:maxInstructionsChars] + "\n...[truncated]..." + } rawJSON, _ = sjson.SetBytes(rawJSON, "instructions", instructions) return rawJSON }