File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
packages/openai-codex-auth/src Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -52,18 +52,21 @@ export const OpenAICodexAuthPlugin: Plugin = async (_ctx) => {
5252
5353 // Required by ChatGPT backend
5454 body . store = false
55+ body . stream = true
5556
5657 // Extract system message from input array for instructions
5758 if ( ! body . instructions && body . input && Array . isArray ( body . input ) ) {
5859 const systemMsg = body . input . find (
5960 ( item : { role ?: string ; type ?: string } ) =>
60- item . role === "system" || item . type === "message" && item . role === "system"
61+ item . role === "system" || ( item . type === "message" && item . role === "system" )
6162 )
6263 if ( systemMsg ?. content ) {
6364 const content = Array . isArray ( systemMsg . content )
6465 ? systemMsg . content . map ( ( c : { text ?: string } ) => c . text || "" ) . join ( "\n" )
6566 : systemMsg . content
6667 body . instructions = content
68+ // Remove the system message from input since it's now in instructions
69+ body . input = body . input . filter ( ( item : { role ?: string } ) => item . role !== "system" )
6770 }
6871 }
6972
@@ -80,6 +83,14 @@ When helping with code:
8083- Ask clarifying questions if the request is ambiguous`
8184 }
8285
86+ // Strip item IDs for stateless operation (required by Codex backend)
87+ if ( body . input && Array . isArray ( body . input ) ) {
88+ body . input = body . input . map ( ( item : Record < string , unknown > ) => {
89+ const { id, ...rest } = item
90+ return rest
91+ } )
92+ }
93+
8394 modifiedInit = {
8495 ...init ,
8596 body : JSON . stringify ( body ) ,
You can’t perform that action at this time.
0 commit comments