-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net: Bug: 1.23.0 throws an exception when streaming a chat completion with auto-invoked tool call #9313
Comments
More info, this has something to do with System.Memory.Data which provides the
Both of those depend on Azure.Core, which in turn depends on System.Memory.Data. And recently, Azure.Core changed its dependency requirements:
So updating those packages simultaneously resulted in a much newer version of System.Memory.Data being brought into my project, and with this newer version of System.Memory.Data, the error occurs. If I downgrade those 2 packages (Azure.Identity and Azure.Storage.Blobs to 1.21.1 and 12.22.1 respectively) and keep SK version 1.23.0, the exception does not occur. |
I've confirmed that the exception is thrown in SK 1.22.0 also when my project updates to Azure.Identity 1.21.1 and Azure.Storage.Blobs 12.22.1. |
Further investigation: if I don't upgrade any packages then I've got a working codebase using SK 1.22.0. It has no direct dependency on System.Memory.Data and so through transitive dependencies it installs System.Memory.Data 1.0.2. Again, this works. If I take a direct dependency on System.Memory.Data:
Next I'll try updating the Azure packages and SK to 1.23, and with a direct dependency on System.Memory.Data 8.0.1 I expect things will work. |
That workaround works as expected. So restating the bug report (I will add this to the body as well). Using Semantic Kernel to do streaming chat completion, with auto tool invocation, when a function is called, results in an uncaught exception thrown by a specific version of transitive dependency, System.Memory.Data 6.0.0. This issue is realized now because the latest versions of other common Microsoft dependencies (Azure.Identity 1.13.0 and Azure.Storage.Blobs 12.22.2) have raised one of their minimum dependency versions such that System.Memory.Data is transitively updated from 1.0.2 to 6.0.0. Workaround: in my project add a direct reference to System.Memory.Data >= 7.00 (I'm going with 8.0.1). |
@jphorv-bdo Thank you very much for the valuable context and investigation, in our repository our dependencies with
Will try your approach with the |
This dependency combination reproduces the bug (with auto-invoked tool call)
I have added
and the exception is gone. What a Friday! This thread saved my weekend and deployment next Monday ❤️ |
What change was made to SK to fix this? I couldn't find any commits that appear related. |
@RogerBarreto you mentioned attempting to catch/avoid triggering the exception that occurs with System.Memory.Data v6.0.0, but @evchaki closed this and I don't see any relevant commits. It seems like something should be done, shouldn't it? |
@jphorv-bdo Im happy the problem can be avoided with your resolution I will reopen the issue and investigate a bug catch for this misusage, but keep in mind that this is not the related to SK when using a non-supported |
@RogerBarreto I see, I didn't know it was unsupported. Never even thought about it until this bug appeared. But if it isn't supported then shouldn't one of the SK NuGet packages have a version requirement of System.Memory.Data >= 7.0 to prevent this from happening? |
Actually our requirement for |
…es (#9454) ### Motivation and Context This add a small fix when using SK with `System.Memory.Data 6.0.0`. This bug happens when updating the `Azure.Core` to [1.44.0](https://www.nuget.org/packages/Azure.Core/1.44.0) which requires `System.Memory.Data` of 6 or above that introduce an error when attempting to `.ToString()` on an empty `BinaryData` object. - Fix #9313
Thanks for the fix @RogerBarreto ! |
Describe the bug
An exception is thrown when streaming a response with toolcall auto invocation, though only when the prompt causes the function to be invoked.
Possibly related to PR 9273?
Stack trace:
To Reproduce
Steps to reproduce the behavior:
Microsoft.SemanticKernel.Connectors.OpenAI.ClientCore.GetStreamingChatMessageContentsAsync()
, withOpenAIPromptExecutionSettings
havingToolCallBehavior
set toToolCallBehavior.AutoInvokeKernelFunctions
, with a prompt that will trigger the function invocation.Expected behavior
I expect the chat completion completes successfully.
Platform
Additional context
Using Azure OpenAI services, model gpt-4o.
UPDATE
After some testing I found the issue exists with SK 1.22.0 also, and my conclusion on the specific cause:
Using Semantic Kernel to do streaming chat completion, with auto tool invocation, when a function is called, results in an uncaught exception thrown by a specific version of a transitive dependency, System.Memory.Data 6.0.0.
This issue is realized now because the latest versions of other common Microsoft dependencies (Azure.Identity 1.13.0 and Azure.Storage.Blobs 12.22.2) have raised one of their minimum dependency versions such that System.Memory.Data is transitively updated from 1.0.2 to 6.0.0.
Workaround: in my project add a direct reference to System.Memory.Data >= 7.00 (I'm going with 8.0.1).
The text was updated successfully, but these errors were encountered: