Skip to content

Comments

fix: handle null responses from model providers#37

Open
chtushar wants to merge 2 commits intomainfrom
chtushar/model-final-response-err
Open

fix: handle null responses from model providers#37
chtushar wants to merge 2 commits intomainfrom
chtushar/model-final-response-err

Conversation

@chtushar
Copy link
Contributor

@chtushar chtushar commented Feb 4, 2026

Summary

When upstream providers return null responses, the gateway now properly handles them by returning error responses instead of crashing. This prevents TypeError in the stream generator and allows the OpenAI agents SDK to properly handle the error.

Fixes cases where agent framework gets "ModelBehaviorError: Model did not produce a final response" due to invalid response handling.

Changes

  • Added null response handling in OpenAIModelResponseJSONToStreamGenerator (streaming mode)
  • Added null response handling in OpenAICreateModelResponseTransformer (non-streaming mode)
  • Both now return proper error responses with code null_response when upstream returns null

🤖 Generated with Claude Code

chtushar and others added 2 commits February 5, 2026 22:16
When upstream providers return null responses, the gateway now properly handles them by returning error responses instead of crashing. This prevents TypeError in the stream generator and allows the OpenAI agents SDK to properly handle the error.

Fixes cases where agent framework gets "ModelBehaviorError: Model did not produce a final response" due to invalid response handling.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@chtushar chtushar force-pushed the chtushar/model-final-response-err branch from dca01a7 to d83633a Compare February 5, 2026 16:46
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