Maybe you have the same issue or any idea how to fix this?!
I'm using Semantic Kernel (.net) to access an Azure AI Service with GPT-4o model deployed in swedencentral via an APIM. When I start a group Chat with several assistants (OpenAIAssistantAgent) I get a NullReferenceException
chat.AddChatMessage(new ChatMessageContent(AuthorRole.User, input));
chat.IsComplete = false;
await foreach (var response in chat.InvokeStreamingAsync())
Using InvokeAsync()
instead works fine...
I have diagnostic settings configured for all related resources and have not a single error. First the assistants are added, then a thread is started, the user message is added and the last step in the logs is the threads/thread_..../runs .
Doing the same with a similar infrastructure in francecentral works fine (so far - as far as I know swedencentral ist updated earlier).
My "demo" solution is based on this example: https://learn.microsoft.com/en-us/semantic-kernel/frameworks/agent/examples/example-agent-collaboration?pivots=programming-language-csharp
BUT uses OpenAIAssistantAgent
AssistantClient assistantClient = OpenAIAssistantAgent.CreateAzureOpenAIClient(
new ApiKeyCredential(apiKey),
new Uri(endpoint),
httpClient: httpClient).GetAssistantClient();
Assistant agentReviewer = await assistantClient.CreateAssistantAsync(
deploymentName, new AssistantCreationOptions()
{
Name = ReviewerName,
Instructions =
"""
...
""",
Description = "Your responsibility is to review and identify how to improve user provided content.",
});
OpenAIAssistantAgent assistantAgentReviewer = new OpenAIAssistantAgent(
agentReviewer,
assistantClient);
I tried semantic Kernel in version 1.45 and 1.47
Here my error callstack:
System.NullReferenceException: Object reference not set to an instance of an object.
at OpenAI.AsyncSseUpdateCollection`1.AsyncSseUpdateEnumerator`1.System.Collections.Generic.IAsyncEnumerator<U>.MoveNextAsync()
at OpenAI.AsyncSseUpdateCollection`1.GetValuesFromPageAsync(ClientResult page)+MoveNext()
at OpenAI.AsyncSseUpdateCollection`1.GetValuesFromPageAsync(ClientResult page)+MoveNext()
at OpenAI.AsyncSseUpdateCollection`1.GetValuesFromPageAsync(ClientResult page)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at System.ClientModel.AsyncCollectionResult`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
at System.ClientModel.AsyncCollectionResult`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
at System.ClientModel.AsyncCollectionResult`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
at System.ClientModel.AsyncCollectionResult`1.GetAsyncEnumerator(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList`1 messages, RunCreationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList`1 messages, RunCreationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList`1 messages, RunCreationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func`1 getActivity, Func`1 operation, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func`1 getActivity, Func`1 operation, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Diagnostics.ActivityExtensions.RunWithActivityAsync[TResult](Func`1 getActivity, Func`1 operation, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Microsoft.SemanticKernel.Agents.AgentChat.InvokeStreamingAgentAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentChat.InvokeStreamingAgentAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentChat.InvokeStreamingAgentAsync(Agent agent, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(Agent agent, CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(Agent agent, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(CancellationToken cancellationToken)+MoveNext()
at Microsoft.SemanticKernel.Agents.AgentGroupChat.InvokeStreamingAsync(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
closing note: there was a bug in the APIM and Microsoft fixed it