fix: preserve the stream property for chat/completions calls#164
Merged
fix: preserve the stream property for chat/completions calls#164
Conversation
dannykopping
reviewed
Feb 4, 2026
5e2f98c to
d43b583
Compare
ssncferreira
reviewed
Feb 4, 2026
ssncferreira
approved these changes
Feb 5, 2026
Contributor
ssncferreira
left a comment
There was a problem hiding this comment.
LGTM ![]()
Can you add a simple description to the PR and link it to the slack thread for future reference?
Comment on lines
+2193
to
+2204
| var reqBody map[string]any | ||
| if err := json.Unmarshal(body, &reqBody); err != nil { | ||
| return fmt.Errorf("request should be valid JSON: %w", err) | ||
| } | ||
|
|
||
| // Verify required fields for OpenAI responses | ||
| // Note: Using map here since there's no specific SDK type for responses endpoint | ||
| model, ok := reqBody["model"] | ||
| if !ok || model == "" { | ||
| return fmt.Errorf("model field is required but missing or empty") | ||
| } | ||
| return nil |
Contributor
There was a problem hiding this comment.
We can actually use responses.ResponseNewParams:
Suggested change
| var reqBody map[string]any | |
| if err := json.Unmarshal(body, &reqBody); err != nil { | |
| return fmt.Errorf("request should be valid JSON: %w", err) | |
| } | |
| // Verify required fields for OpenAI responses | |
| // Note: Using map here since there's no specific SDK type for responses endpoint | |
| model, ok := reqBody["model"] | |
| if !ok || model == "" { | |
| return fmt.Errorf("model field is required but missing or empty") | |
| } | |
| return nil | |
| var req responses.ResponseNewParams | |
| if err := json.Unmarshal(body, &req); err != nil { | |
| return fmt.Errorf("request should unmarshal into ResponseNewParams: %w", err) | |
| } | |
| // Collect all validation errors | |
| var errs []string | |
| if req.Model == "" { | |
| errs = append(errs, "model field is required but empty") | |
| } | |
| if len(errs) > 0 { | |
| return fmt.Errorf("validation failed: %s", strings.Join(errs, "; ")) | |
| } | |
| return nil |
Contributor
There was a problem hiding this comment.
I can add this as a follow-up 👍
SasSwart
added a commit
to coder/coder
that referenced
this pull request
Feb 5, 2026
…s' calls (#21926) Update AI Bridge to apply this fix: coder/aibridge#164
SasSwart
added a commit
to coder/coder
that referenced
this pull request
Feb 5, 2026
…s' calls (#21926) Update AI Bridge to apply this fix: coder/aibridge#164
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.
In the
openai-goSDK, a conflict between a recent optimization and the way in which options are set resulted in an issue whereby request bodies forchat/completionscalls were being discarded.This PR fixes the issue by taking full control of the request body handling. We now use the
WithRequestBodyandWithJSONSetoptions ourselves to ensure that the request payload is sent exactly as we need it.Integration tests have been added to guard against future regression.
Related to internal Slack thread.