Skip to content

Commit 0570d26

Browse files
brettheapclaude
andcommitted
fix(openai-codex-auth): add more required Codex fields
- Add stream=true (required by Codex backend) - Strip item IDs from input array (stateless operation) - Remove system message from input after extracting to instructions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 4cc46dc commit 0570d26

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

packages/openai-codex-auth/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff 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),

0 commit comments

Comments
 (0)