Skip to content

Commit 818ae65

Browse files
he-yufenglokitoth
andauthored
fix: declare Magentic protocol messages (microsoft#5778)
Co-authored-by: Jacob Alber <jaalber@microsoft.com>
1 parent d8619b9 commit 818ae65

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticOrchestrator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ internal class MagenticOrchestrator(AIAgent managerAgent, List<AIAgent> team, Ta
9898

9999
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder protocolBuilder)
100100
{
101-
return base.ConfigureProtocol(protocolBuilder).ConfigureRoutes(ConfigureRoutes);
101+
return base.ConfigureProtocol(protocolBuilder)
102+
.SendsMessage<ChatMessage>()
103+
.SendsMessage<ResetChatSignal>()
104+
.ConfigureRoutes(ConfigureRoutes);
102105

103106
void ConfigureRoutes(RouteBuilder routeBuilder) => routeBuilder.AddPortHandler<MagenticPlanReviewRequest, MagenticPlanReviewResponse>(
104107
"RequestPlanReview",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
3+
using System.Collections.Generic;
4+
using FluentAssertions;
5+
using Microsoft.Agents.AI.Workflows.Specialized.Magentic;
6+
using Microsoft.Extensions.AI;
7+
8+
namespace Microsoft.Agents.AI.Workflows.UnitTests;
9+
10+
public class MagenticOrchestratorTests
11+
{
12+
[Fact]
13+
public void Test_MagenticOrchestrator_Protocol_Declares_SentMessages()
14+
{
15+
TestReplayAgent manager = new(name: nameof(MagenticOrchestrator));
16+
TestEchoAgent participant = new(name: "Echo");
17+
MagenticOrchestrator orchestrator = new(manager, [participant], new(), requirePlanSignoff: false);
18+
19+
ProtocolDescriptor protocol = orchestrator.DescribeProtocol();
20+
21+
protocol.Sends.Should().Contain(typeof(List<ChatMessage>));
22+
protocol.Sends.Should().Contain(typeof(ChatMessage));
23+
protocol.Sends.Should().Contain(typeof(TurnToken));
24+
protocol.Sends.Should().Contain(typeof(ResetChatSignal));
25+
}
26+
}

0 commit comments

Comments
 (0)