Fix ChatResponseUpdate.Clone dropping ContinuationToken - #7699
Open
dfedoryshchev wants to merge 1 commit into
Open
Fix ChatResponseUpdate.Clone dropping ContinuationToken#7699dfedoryshchev wants to merge 1 commit into
dfedoryshchev wants to merge 1 commit into
Conversation
Clone() copied every settable property except ContinuationToken, so a cloned update lost the token needed to resume a background streaming response. Extended Clone_CreatesShallowCopy to cover the property.
Author
|
@dotnet-policy-service agree |
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.
ChatResponseUpdate.Clone()assigns every settable property on the type exceptContinuationToken, so the token is silently dropped from the clone. The doc comment says the result is "a new ChatResponseUpdate object with the same property values as the current instance", andContinuationTokenpredatesClone(), so this reads as an omission rather than a deliberate exclusion.It is reachable in the box.
ImageGeneratingChatClient.GetStreamingResponseAsyncclones an update whenever it rewrites that update's contents, and yields the clone in place of the original, so for those updates the consumer seesContinuationToken == null. The remarks onChatResponseUpdate.ContinuationTokentell callers to pass the token from the latest received update toChatOptions.ContinuationTokenin order to resume an interrupted background stream, which a clone cannot support.Fix: copy
ContinuationTokeninClone().Validation: extended the existing
Clone_CreatesShallowCopytest to set and assertContinuationToken. Against unmodified sources it fails withand passes with the change.
Microsoft.Extensions.AI.Abstractions.Tests: 1642 passed, 0 failed, 1 skipped.Microsoft.Extensions.AI.Tests: 761 passed, 0 failed.Microsoft Reviewers: Open in CodeFlow