Skip to content

[BUG] Serialization error with AI Agents: Unable to cast object of type 'd__2' to type #52671

@karthiksimplist

Description

@karthiksimplist

Library name and version

Azure.AI.Agents.Persistent 1.2.0-beta.4

Describe the bug

Message: Unable to cast object of type 'd__2' to type 'System.Collections.Generic.List`1[System.Text.Json.JsonElement]'.

Stack:
   at System.Text.Json.JsonSerializer.UnboxOnWrite[T](Object value)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.SerializeAsObject(Utf8JsonWriter writer, Object rootValue)
   at System.Text.Json.JsonSerializer.WriteStringAsObject(Object value, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Serialize(Object value, JsonTypeInfo jsonTypeInfo)
   at Azure.AI.Agents.Persistent.ThreadMessages.CreateMessageAsync(String threadId, MessageRole role, IEnumerable`1 contentBlocks, IEnumerable`1 attachments, IReadOnlyDictionary`2 metadata, CancellationToken cancellationToken)
   at Microsoft.SemanticKernel.Agents.AzureAI.Internal.AgentThreadActions.CreateMessageAsync(PersistentAgentsClient client, String threadId, ChatMessageContent message, CancellationToken cancellationToken)
   at Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgentThread.OnNewMessageInternalAsync(ChatMessageContent newMessage, CancellationToken cancellationToken)
   at Microsoft.SemanticKernel.Agents.AgentThread.OnNewMessageAsync(ChatMessageContent newMessage, CancellationToken cancellationToken)
   at Microsoft.SemanticKernel.Agents.Agent.EnsureThreadExistsWithMessagesAsync[TThreadType](ICollection`1 messages, AgentThread thread, Func`1 constructThread, CancellationToken cancellationToken)
   at Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.InvokeStreamingAsync(ICollection`1 messages, AgentThread thread, AzureAIAgentInvokeOptions options, CancellationToken cancellationToken)+MoveNext()
   at Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.InvokeStreamingAsync(ICollection`1 messages, AgentThread thread, AzureAIAgentInvokeOptions options, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()

Expected behavior

Throws this exception all the time when using Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.InvokeStreamingAsync
which used to work on the same codebase of ours.

Actual behavior

Throws the above mentioned exception.

Reproduction Steps

Invoke
Microsoft.SemanticKernel.Agents.AzureAI.AzureAIAgent.InvokeStreamingAsync method with the following packages.

<PackageReference Include="Azure.AI.Agents.Persistent" Version="1.2.0-beta.4" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.3.0-beta.1" />
<PackageReference Include="Azure.AI.Projects" Version="1.0.0-beta.11" />
<PackageReference Include="System.ClientModel" Version="1.6.1" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
<PackageReference Include="Simplist.Framework.Services.Core" Version="1.0.0" />
<PackageReference Include="Simplist.Framework.Bootstrap" Version="1.0.0" />
<PackageReference Include="Microsoft.SemanticKernel" Version="1.64.0" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.64.0" />
<PackageReference Include="Microsoft.SemanticKernel.Agents.Core" Version="1.64.0" />
<PackageReference Include="Microsoft.SemanticKernel.Agents.OpenAI" Version="1.64.0-preview" />
<PackageReference Include="Microsoft.SemanticKernel.Agents.AzureAI" Version="1.64.0-preview" />
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Web" Version="1.64.0-alpha" />

Environment

.NET

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI AgentsClientThis issue is related to a non-management packageService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions