fix: handle missing fields in OpenAI ResponseErrorEvent stream events - #34
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@effect/*packages fromrc.109torc.112, which subsumes the entire prior patch (reasoning"max",XaiErrorBody, HTTP 402 handling,billing_insufficient_balance)ResponseErrorEventin@effect/ai-openaito makecode,param, andsequence_numberoptional — the Codex backend omits these fields on SSE error events, which crashed the stream decoder becauseUnknownResponseStreamEventalso 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 acodekey. The schema union dead-ended:ResponseErrorEventrequired the key, andUnknownResponseStreamEventrejectedtype: "error"as a known type. This prevented Fold from reading the actual error message or retrying.Example failing session:
sess_lkuwspx20w32gb0bbbyqx8vm(modelgpt-5.6-sol, providercodex)Test plan
bun run typecheck— 0 errorsbun run test— 718 tests pass (0 failures)🤖 Generated with Claude Code