semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: Bug: .NET, OpenAI Assistant An item with the same key has already been added. Key: step_

Open JP-droidic opened this issue 2 years ago • 4 comments

After upgrading to the latest version of SK 1.2.8.0 and OpenAi SDK 2.1.0 - beta.2 we start getting the following error message:

System.ArgumentException: An item with the same key has already been added. 
Key: step_nZg6g0H4Z6tF043ZgJNhiR5B 
  at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) 
  at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) 
  at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, 
AssistantClient client, String threadId, IList`1 messages, OpenAIAssistantInvocationOptions 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, OpenAIAssistantInvocationOptions invocationOptions, ILogger logger, 
Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult() 
  at AiEngine.SemanticKernel.SemanticKernelService.GetChatMessageContentStreamingAssistantAsync(RequestModel requestModel, OpenAIAssistantAgent assistant, String threadId, List`1 images) in

This happens from time to time, we can't catch the exact pattern.

JP-droidic avatar Nov 11 '24 13:11 JP-droidic

@JP-droidic - Thanks for reporting this. Can you please confirm on whether you are using any plugins or functions with this agent, or is this entirely message generation? In the meantime, I'll setup a local stress test to see if I can't reproduce this error for additional insight.

crickman avatar Nov 11 '24 16:11 crickman

@crickman Hi Chris

thank you!. Yes, the kernel has 10ish plugins added

JP-droidic avatar Nov 11 '24 17:11 JP-droidic

Ok, I have a hypothesis on what may be occurring here. Moving from stress-test to a targeted scenario.

crickman avatar Nov 11 '24 18:11 crickman

Thank you @crickman !

JP-droidic avatar Nov 12 '24 07:11 JP-droidic