.NET: Add missing workflow properties to the workflow.definition tag (#1261)

* add workflow edge data properties to the workflow.definition tag.

* use workflow info classes for workflow.definition tag value

* add unit test

* fix test

* fix formatting issue

* remove flaky unit test

* remove unused package dependency
This commit is contained in:
SergeyMenshykh
2025-10-08 22:51:59 +01:00
committed by GitHub
Unverified
parent 988623e7b8
commit 15afc966ce
2 changed files with 4 additions and 33 deletions
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Agents.AI.Workflows.Checkpointing;
using Microsoft.Agents.AI.Workflows.Observability;
using Microsoft.Shared.Diagnostics;
@@ -414,23 +415,13 @@ public class WorkflowBuilder
{
activity?.SetTag(Tags.WorkflowDescription, workflow.Description);
}
if (activity is not null)
{
var workflowJsonDefinitionData = new WorkflowJsonDefinitionData
{
StartExecutorId = this._startExecutorId,
Edges = this._edges.Values.SelectMany(e => e),
Ports = this._inputPorts.Values,
OutputExecutors = this._outputExecutors
};
activity.SetTag(
activity?.SetTag(
Tags.WorkflowDefinition,
JsonSerializer.Serialize(
workflowJsonDefinitionData,
WorkflowJsonDefinitionJsonContext.Default.WorkflowJsonDefinitionData
workflow.ToWorkflowInfo(),
WorkflowsJsonUtilities.JsonContext.Default.WorkflowInfo
)
);
}
return workflow;
}
@@ -1,20 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Microsoft.Agents.AI.Workflows;
[JsonSourceGenerationOptions(UseStringEnumConverter = true)]
[JsonSerializable(typeof(WorkflowJsonDefinitionData))]
internal partial class WorkflowJsonDefinitionJsonContext : JsonSerializerContext
{
}
internal class WorkflowJsonDefinitionData
{
public string StartExecutorId { get; set; } = string.Empty;
public IEnumerable<Edge> Edges { get; set; } = [];
public IEnumerable<RequestPort> Ports { get; set; } = [];
public IEnumerable<string> OutputExecutors { get; set; } = [];
}