fix: handle empty response with reasoning in Requesty provider #10205
+136
−0
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.
Related GitHub Issue
Closes: #10106
Description
This PR attempts to address Issue #10106. Feedback and guidance are welcome.
The fix adds a safeguard to the Requesty provider to handle scenarios where models return only reasoning/thinking content without actual text or tool calls. This can occur when:
<tool_call><function=...>syntax)Implementation:
hasContentandhasReasoningflags during streamingThis fix is part of a broader effort to address empty response errors across multiple providers (see related PR #10136 for OpenRouter).
Test Procedure
Unit tests added for:
Run tests:
All 14 tests pass.
Pre-Submission Checklist
Screenshots / Videos
N/A - Backend change only, no UI changes.
Documentation Updates
Additional Notes
This is one potential fix for the "Unknown API Error" issue. The root cause appears to be related to how certain models format tool calls when using reasoning/thinking mode, particularly with the newer native tool protocol. The model may output something like
<tool_call><function=get_weather>in its reasoning content, which is not a valid tool call format.Related PRs:
Get in Touch
@roomote