Skip to content

Commit 3f824b1

Browse files
committed
Clarify workflow and remote agent sample roles
Show each server constructing a Workflow before adapting it with AsAIAgent, use Producer and Reviewer in the sequential scenario, and distinguish remote client agents and sessions by name. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 681114d3-3e0d-47f8-8b87-4e5873ecdd6d
1 parent e7cb2e2 commit 3f824b1

15 files changed

Lines changed: 57 additions & 44 deletions

File tree

‎dotnet/samples/02-agents/AGUI/Step06_WorkflowSequential/Client/Program.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
string serverUrl = Environment.GetEnvironmentVariable("AGUI_SERVER_URL") ?? "http://localhost:8888";
99
using HttpClient httpClient = new() { Timeout = TimeSpan.FromSeconds(60) };
1010
AGUIChatClient chatClient = new(new(httpClient, serverUrl));
11-
AIAgent agent = chatClient.AsAIAgent(name: "workflow-client");
12-
AgentSession session = await agent.CreateSessionAsync();
11+
AIAgent remoteAgent = chatClient.AsAIAgent(name: "workflow-client");
12+
AgentSession remoteSession = await remoteAgent.CreateSessionAsync();
1313

1414
Console.Write("Request: ");
1515
string request = Console.ReadLine() ?? "Write a short welcome message for a developer conference.";
1616

17-
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(
17+
await foreach (AgentResponseUpdate update in remoteAgent.RunStreamingAsync(
1818
new ChatMessage(ChatRole.User, request),
19-
session))
19+
remoteSession))
2020
{
2121
switch (update.AsChatResponseUpdate().RawRepresentation)
2222
{

‎dotnet/samples/02-agents/AGUI/Step06_WorkflowSequential/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sequential Workflow over AG-UI
22

3-
This sample hosts a two-agent sequential workflow over AG-UI. The `Writer` drafts a response and the
3+
This sample hosts a two-agent sequential workflow over AG-UI. The `Producer` drafts a response and the
44
`Reviewer` produces the final answer. The client prints AG-UI step lifecycle events alongside streamed text.
55

66
## Run
@@ -12,4 +12,4 @@ dotnet run --project Server --urls http://localhost:8888
1212
dotnet run --project Client
1313
```
1414

15-
Expected step events include `STEP_STARTED` and `STEP_FINISHED` for `Writer` followed by `Reviewer`.
15+
Expected step events include `STEP_STARTED` and `STEP_FINISHED` for `Producer` followed by `Reviewer`.

‎dotnet/samples/02-agents/AGUI/Step06_WorkflowSequential/Server/Program.cs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
new DefaultAzureCredential())
2323
.GetChatClient(deploymentName);
2424

25-
AIAgent writer = chatClient.AsAIAgent(
26-
name: "Writer",
25+
AIAgent producer = chatClient.AsAIAgent(
26+
name: "Producer",
2727
instructions: "Draft a concise answer to the user's request.");
2828
AIAgent reviewer = chatClient.AsAIAgent(
2929
name: "Reviewer",
3030
instructions: "Review the draft and return an improved final answer.");
3131

32-
AIAgent workflowAgent = SequentialWorkflow.Create(writer, reviewer).AsAIAgent(name: "SequentialWorkflow");
32+
Workflow workflow = SequentialWorkflow.Create(producer, reviewer);
33+
AIAgent workflowAgent = workflow.AsAIAgent(name: "SequentialWorkflow");
3334

3435
WebApplication app = builder.Build();
3536
app.MapAGUIServer("/", workflowAgent);

‎dotnet/samples/02-agents/AGUI/Step06_WorkflowSequential/Server/SequentialWorkflow.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public static class SequentialWorkflow
1313
/// <summary>
1414
/// Creates a workflow that asks one agent to draft content and another to review it.
1515
/// </summary>
16-
/// <param name="writer">The writer agent.</param>
16+
/// <param name="producer">The producer agent.</param>
1717
/// <param name="reviewer">The reviewer agent.</param>
1818
/// <returns>The sequential workflow.</returns>
19-
public static Workflow Create(AIAgent writer, AIAgent reviewer)
20-
=> new SequentialWorkflowBuilder(writer, reviewer).Build();
19+
public static Workflow Create(AIAgent producer, AIAgent reviewer)
20+
=> new SequentialWorkflowBuilder(producer, reviewer).Build();
2121
}

‎dotnet/samples/02-agents/AGUI/Step07_WorkflowConcurrent/Client/Program.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
string serverUrl = Environment.GetEnvironmentVariable("AGUI_SERVER_URL") ?? "http://localhost:8888";
99
using HttpClient httpClient = new() { Timeout = TimeSpan.FromSeconds(60) };
1010
AGUIChatClient chatClient = new(new(httpClient, serverUrl));
11-
AIAgent agent = chatClient.AsAIAgent(name: "workflow-client");
12-
AgentSession session = await agent.CreateSessionAsync();
11+
AIAgent remoteAgent = chatClient.AsAIAgent(name: "workflow-client");
12+
AgentSession remoteSession = await remoteAgent.CreateSessionAsync();
1313

1414
Console.Write("Request: ");
1515
string request = Console.ReadLine() ?? "Assess the tradeoffs of adopting a new framework.";
1616

17-
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(
17+
await foreach (AgentResponseUpdate update in remoteAgent.RunStreamingAsync(
1818
new ChatMessage(ChatRole.User, request),
19-
session))
19+
remoteSession))
2020
{
2121
switch (update.AsChatResponseUpdate().RawRepresentation)
2222
{

‎dotnet/samples/02-agents/AGUI/Step07_WorkflowConcurrent/Server/Program.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
name: "Critic",
3030
instructions: "Identify risks and missing considerations in the user's request.");
3131

32-
AIAgent workflowAgent = ConcurrentWorkflow.Create(researcher, critic).AsAIAgent(name: "ConcurrentWorkflow");
32+
Workflow workflow = ConcurrentWorkflow.Create(researcher, critic);
33+
AIAgent workflowAgent = workflow.AsAIAgent(name: "ConcurrentWorkflow");
3334

3435
WebApplication app = builder.Build();
3536
app.MapAGUIServer("/", workflowAgent);

‎dotnet/samples/02-agents/AGUI/Step08_WorkflowFailure/Client/Program.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
string serverUrl = Environment.GetEnvironmentVariable("AGUI_SERVER_URL") ?? "http://localhost:8888";
99
using HttpClient httpClient = new() { Timeout = TimeSpan.FromSeconds(60) };
1010
AGUIChatClient chatClient = new(new(httpClient, serverUrl));
11-
AIAgent agent = chatClient.AsAIAgent(name: "workflow-client");
12-
AgentSession session = await agent.CreateSessionAsync();
11+
AIAgent remoteAgent = chatClient.AsAIAgent(name: "workflow-client");
12+
AgentSession remoteSession = await remoteAgent.CreateSessionAsync();
1313

14-
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(
14+
await foreach (AgentResponseUpdate update in remoteAgent.RunStreamingAsync(
1515
new ChatMessage(ChatRole.User, "Run the failing workflow."),
16-
session))
16+
remoteSession))
1717
{
1818
switch (update.AsChatResponseUpdate().RawRepresentation)
1919
{

‎dotnet/samples/02-agents/AGUI/Step08_WorkflowFailure/Server/Program.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
builder.Services.AddHttpClient().AddLogging();
1010
builder.Services.AddAGUIServer();
1111

12-
AIAgent workflowAgent = FailingWorkflow.Create(new FailingAgent()).AsAIAgent(name: "FailingWorkflow");
12+
Workflow workflow = FailingWorkflow.Create(new FailingAgent());
13+
AIAgent workflowAgent = workflow.AsAIAgent(name: "FailingWorkflow");
1314

1415
WebApplication app = builder.Build();
1516
app.MapAGUIServer("/", workflowAgent);

‎dotnet/samples/02-agents/AGUI/Step09_WorkflowTools/Client/Program.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
string serverUrl = Environment.GetEnvironmentVariable("AGUI_SERVER_URL") ?? "http://localhost:8888";
99
using HttpClient httpClient = new() { Timeout = TimeSpan.FromSeconds(60) };
1010
AGUIChatClient chatClient = new(new(httpClient, serverUrl));
11-
AIAgent agent = chatClient.AsAIAgent(name: "workflow-client");
12-
AgentSession session = await agent.CreateSessionAsync();
11+
AIAgent remoteAgent = chatClient.AsAIAgent(name: "workflow-client");
12+
AgentSession remoteSession = await remoteAgent.CreateSessionAsync();
1313

14-
await foreach (AgentResponseUpdate update in agent.RunStreamingAsync(
14+
await foreach (AgentResponseUpdate update in remoteAgent.RunStreamingAsync(
1515
new ChatMessage(ChatRole.User, "What is the weather in Seattle?"),
16-
session))
16+
remoteSession))
1717
{
1818
switch (update.AsChatResponseUpdate().RawRepresentation)
1919
{

‎dotnet/samples/02-agents/AGUI/Step09_WorkflowTools/Server/Program.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ static string GetWeather([Description("The city to inspect.")] string city)
3232
name: "WeatherAgent",
3333
instructions: "Use the weather tool and answer with the returned forecast.",
3434
tools: [AIFunctionFactory.Create(GetWeather)]);
35-
AIAgent workflowAgent = ToolWorkflow.Create(weatherAgent).AsAIAgent(name: "ToolWorkflow");
35+
Workflow workflow = ToolWorkflow.Create(weatherAgent);
36+
AIAgent workflowAgent = workflow.AsAIAgent(name: "ToolWorkflow");
3637

3738
WebApplication app = builder.Build();
3839
app.MapAGUIServer("/", workflowAgent);

0 commit comments

Comments
 (0)