diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs index 13dfc30066..322c460ee3 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeAzureAgentExecutor.cs @@ -94,11 +94,11 @@ internal sealed class InvokeAzureAgentExecutor(InvokeAzureAgent model, ResponseA { try { - JsonDocument jsonDocument = JsonDocument.Parse(lastMessageText); + using JsonDocument jsonDocument = JsonDocument.Parse(lastMessageText); Dictionary objectProperties = jsonDocument.ParseRecord(VariableType.RecordType); await this.AssignAsync(this.AgentOutput?.ResponseObject?.Path, objectProperties.ToFormula(), context).ConfigureAwait(false); } - catch + catch (JsonException) { // Not valid json, skip assignment. }