Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Workflows/Edge.cs
T
Jacob Alber 32e7ff00b5 .NET: Add support for Subworkflows and many threading fixes (#1066)
* feat: Add support for Workflow-as-Executor

* Fixes routing of 'object' compile-typed variables to properly take in type information
* Fixes a concurrency issue in StepTracer

* fix: Make Subworkflow ExternalRequests work properly

* fix: Threading and Concurrency fixes; prep for OffThread Mode

* refactor: Remove dead code around OffStreamRunEventStream

Currently not used, and will be replaced with a rewrite when brought back, so having it in the change is not valuable.

* ci: Work around issues with dotnet-format not properly analyzing the source

* fix: Fix the logic of AsyncCoordinator and AsyncBarrier

* Prevent individual wait cancellations from canceling the entire barrier
* Propagate information about whether the wait was completed or cancelled, and whether any waiters were present when released

* fix: Remove superfluous acces to .Keys in InProcStepTracer

* refactor: Clean up AsyncCoordinator's use of AsyncBarrier
2025-10-03 17:26:30 +00:00

77 lines
2.2 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Diagnostics;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI.Workflows;
/// <summary>
/// Specified the edge type.
/// </summary>
public enum EdgeKind
{
/// <summary>
/// A direct connection from one node to another.
/// </summary>
Direct,
/// <summary>
/// A connection from one node to a set of nodes.
/// </summary>
FanOut,
/// <summary>
/// A connection from a set of nodes to a single node.
/// </summary>
FanIn
}
/// <summary>
/// Represents a connection or relationship between nodes, characterized by its type and associated data.
/// </summary>
/// <remarks>
/// An <see cref="Edge"/> can be of type <see cref="EdgeKind.Direct"/>, <see cref="EdgeKind.FanOut"/>, or <see
/// cref="EdgeKind.FanIn"/>, as specified by the <see cref="Kind"/> property. The <see cref="Data"/> property holds
/// additional information relevant to the edge, and its concrete type depends on the value of <see
/// cref="Kind"/>, functioning as a tagged union.
/// </remarks>
[DebuggerDisplay("[{Data.Id}]: {Kind}Edge({Data.Connection})")]
public sealed class Edge
{
/// <summary>
/// Specifies the type of the edge, which determines how the edge is processed in the workflow.
/// </summary>
public EdgeKind Kind { get; init; }
/// <summary>
/// The <see cref="EdgeKind"/>-dependent edge data.
/// </summary>
/// <seealso cref="DirectEdgeData"/>
/// <seealso cref="FanOutEdgeData"/>
/// <seealso cref="FanInEdgeData"/>
public EdgeData Data { get; init; }
internal Edge(DirectEdgeData data)
{
this.Data = Throw.IfNull(data);
this.Kind = EdgeKind.Direct;
}
internal Edge(FanOutEdgeData data)
{
this.Data = Throw.IfNull(data);
this.Kind = EdgeKind.FanOut;
}
internal Edge(FanInEdgeData data)
{
this.Data = Throw.IfNull(data);
this.Kind = EdgeKind.FanIn;
}
internal DirectEdgeData? DirectEdgeData => this.Data as DirectEdgeData;
internal FanOutEdgeData? FanOutEdgeData => this.Data as FanOutEdgeData;
internal FanInEdgeData? FanInEdgeData => this.Data as FanInEdgeData;
}