Skip to content

fix: handle missing fields in OpenAI ResponseErrorEvent stream events - #34

Merged
K-Mistele merged 1 commit into
mainfrom
debug-missing-code-key-in-openai-stream-response
Sep 2, 2026
Merged

fix: handle missing fields in OpenAI ResponseErrorEvent stream events#34
K-Mistele merged 1 commit into
mainfrom
debug-missing-code-key-in-openai-stream-response

Conversation

@K-Mistele

Copy link
Copy Markdown
Contributor

Summary

  • Upgrades @effect/* packages from rc.109 to rc.112, which subsumes the entire prior patch (reasoning "max", XaiErrorBody, HTTP 402 handling, billing_insufficient_balance)
  • Patches ResponseErrorEvent in @effect/ai-openai to make code, param, and sequence_number optional — the Codex backend omits these fields on SSE error events, which crashed the stream decoder because UnknownResponseStreamEvent also rejects known event types like "error"

Context

Users hit OpenAiClient.createResponseStream: Invalid output: Missing key at [0]["data"]["code"] when the Codex backend returned a stream error event without a code key. The schema union dead-ended: ResponseErrorEvent required the key, and UnknownResponseStreamEvent rejected type: "error" as a known type. This prevented Fold from reading the actual error message or retrying.

Example failing session: sess_lkuwspx20w32gb0bbbyqx8vm (model gpt-5.6-sol, provider codex)

Test plan

  • bun run typecheck — 0 errors
  • bun run test — 718 tests pass (0 failures)
  • Verify a Codex session can recover from a provider-side stream error without crashing

🤖 Generated with Claude Code

…formant providers

The Codex backend sends SSE error events without `code`, `param`, or
`sequence_number` keys. The @effect/ai-openai schema required these fields,
and the UnknownResponseStreamEvent catch-all rejected known types like
"error", so the stream decoder crashed instead of surfacing the error.

Also upgrades @effect/* from rc.109 to rc.112, which subsumes the prior
patch (reasoning "max", XaiErrorBody, 402 handling, billing_insufficient_balance).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HumanLayer-Session: https://app.dev.codelayer.gg/sessions/01a05fb1-a6be-71e1-b09c-40c04f49aa7c
@K-Mistele
K-Mistele merged commit 25975a2 into main Sep 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant