Skip to content

Codex subscription provider fails with Cannot read properties of undefined (reading 'map') #226

@yodaliu

Description

@yodaliu

When selecting the AI provider as OpenAI Codex (Subscription), OpenAlice returns:

[Codex API error: Cannot read properties of undefined (reading 'map')]

Observed stack/log points to the SDK stream finalizer:

OpenAIError: Cannot read properties of undefined (reading 'map')
caused by: TypeError: Cannot read properties of undefined (reading 'map')
at maybeParseResponse (.../openai/src/lib/ResponsesParser.ts:37:31)
at finalizeResponse (.../openai/src/lib/responses/ResponseStream.ts:367:10)

Likely cause: the ChatGPT Codex subscription endpoint sometimes completes the stream with a response.completed payload that does not include the response.output shape expected by client.responses.stream(). The text deltas have already streamed correctly, but the SDK helper crashes during final response parsing.

Expected behavior:

  • Codex subscription streaming should not fail after completion if text deltas were received.
  • Real API errors should still be surfaced clearly.

Suggested fix:

  • Avoid client.responses.stream() for the Codex subscription path.
  • Use raw streaming via:

await client.responses.create({
model,
instructions,
input,
tools,
store: false,
stream: true,
})

  • Iterate raw stream events directly.
  • Explicitly handle error, response.failed, and response.incomplete events.

Environment:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions