mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* feat: Implement Polymorphic Routing * feat: Add support for Send/Yield annotations with basic Executor * Adds annotations to Declarative workflow executors * fix: Address PR Comments * Implicit filter in collection loops * Remove debug / usused / superfluous code * Fix ProtocolBuilder implicit output registrations * Fix logic error in ExecuteRouteGeneratorTests.ClassWithManualConfigureProtocol_DoesNotGenerate * fix: Solidify type checks and send/yield type registrations * fix: Suppress generation of TurnTokens out of AggregateTurnMessagesExecutor * Fixes an issue where ConcurrentEndExecutor is not expecting TurnTokens. * fix: Add ProtocolBuilder support for chained-delegation * Updates Declarative pacakge to rely on chained-delegation Send/Yield registration * Renames DeclarativeActionExectuor's new ExecuteAsync to ExecuteActionAsync to avoid colliding with Executor.ExecutoeAsync * fix: Address PR Comments * Fixes type mapping in FanInEdgeRunner * Fixes and expalins send/yield type registration in FunctionExecutor * fixup: build-break * fix: Add missing SendsMesage declaration to InvokeAzureAgentExecutor
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text.Json.Serialization;
|
|
using System.Threading;
|
|
using Microsoft.Agents.AI.Workflows.Checkpointing;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Execution;
|
|
|
|
internal sealed class FanInEdgeState
|
|
{
|
|
private List<PortableMessageEnvelope> _pendingMessages;
|
|
public FanInEdgeState(FanInEdgeData fanInEdge)
|
|
{
|
|
this.SourceIds = fanInEdge.SourceIds.ToArray();
|
|
this.Unseen = [.. this.SourceIds];
|
|
|
|
this._pendingMessages = [];
|
|
}
|
|
|
|
public string[] SourceIds { get; }
|
|
public HashSet<string> Unseen { get; private set; }
|
|
public List<PortableMessageEnvelope> PendingMessages => this._pendingMessages;
|
|
|
|
[JsonConstructor]
|
|
public FanInEdgeState(string[] sourceIds, HashSet<string> unseen, List<PortableMessageEnvelope> pendingMessages)
|
|
{
|
|
this.SourceIds = sourceIds;
|
|
this.Unseen = unseen;
|
|
|
|
this._pendingMessages = pendingMessages;
|
|
}
|
|
|
|
public IEnumerable<IGrouping<ExecutorIdentity, MessageEnvelope>>? ProcessMessage(string sourceId, MessageEnvelope envelope)
|
|
{
|
|
this.PendingMessages.Add(new(envelope));
|
|
this.Unseen.Remove(sourceId);
|
|
|
|
if (this.Unseen.Count == 0)
|
|
{
|
|
List<PortableMessageEnvelope> takenMessages = Interlocked.Exchange(ref this._pendingMessages, []);
|
|
this.Unseen = [.. this.SourceIds];
|
|
|
|
if (takenMessages.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return takenMessages.Select(portable => portable.ToMessageEnvelope())
|
|
.GroupBy(keySelector: messageEnvelope => messageEnvelope.Source);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|