fix: Preserve OpenAI stream errors and model compatibility - #12
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
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.
OpenAI-backed runs can terminate with
openai stream error :, discarding the provider's actionable error details. Two reporters reproduce the failure on the current release, and one confirmed that direct streaming Responses API calls succeed while meat fails across multiple reasoning models.The same report identifies a separate deterministic compatibility problem: meat sends
reasoning.effortto models that do not support reasoning parameters, which reject the field with HTTP 400.This change updates
meat/openai.goso request construction determines whether the resolved model belongs to a reasoning-capable family, retaining the current default effort and encrypted-reasoning include for those models while omitting reasoning-only fields for the rest. That capability decision stays in the production request path rather than adding a test-only seam, and the existing behavior for meat's default model is preserved.It also extends the SSE wire representation and decoder to extract provider details from both the event's direct error fields and an embedded error object used by compatible response envelopes, preferring non-empty code/type/message values and returning a descriptive fallback when the event is malformed, instead of emitting a blank error.
The issue is confined to OpenAI request construction and SSE error decoding; Anthropic and the provider-agnostic agent loop are out of scope.
Testing: a reasoning-capable request still serializes the configured/default reasoning effort and
reasoning.encrypted_content, and a normal completed stream remains unchanged. Requests to models without reasoning support omit reasoning-only fields entirely while retaining the common Responses API fields, preventing the reported unsupported-parameter response.go build ./...andgo test ./meat/...both pass (16 tests).Fixes #1