Repository navigation
Guard against a null choice or delta in TryGetReasoningContent - #7792
Closed
eersinyildizz wants to merge 1 commit into
Closed
eersinyildizz wants to merge 1 commit into
eersinyildizz wants to merge 1 commit into
Conversation
Collaborator
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1614493&view=codecoverage-tab |
Member
|
@eersinyildizz thanks, I think it would be better to get rid of the workaround now that the underlying library has fixed the issue. #7815. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #7790.
TryGetReasoningContentcallsJsonElement.TryGetPropertyonchoices[0]and onchoices[0].deltawithout checking that either is an object.TryGetPropertyrequiresValueKind == JsonValueKind.Objectand throws otherwise, so a streaming chunk carrying"delta": null(or"choices": [null]) fails the whole stream with:Azure OpenAI emits exactly this shape when content filtering runs in asynchronous mode: an
annotation-only event carrying
content_filter_results/content_filter_offsetswith a nulldelta, interleaved with token chunks and also after
finish_reason: "stop". The same backendbehaviour has had to be guarded against in openai-python (#2313), LiteLLM (#3811) and
Semantic Kernel (#8407).
The method is already written to fail soft - every other step is a
ValueKindcheck or aTryGetProperty- so the fix is to add the two missing kind checks. A null or otherwisenon-object element now means "no reasoning content here" instead of an exception.
Microsoft Reviewers: Open in CodeFlow