Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static async Task Main()
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));
await foreach (WorkflowEvent evt in run.WatchStreamAsync())
{
if (evt is AgentRunUpdateEvent executorComplete)
if (evt is AgentResponseUpdateEvent executorComplete)
{
Console.WriteLine($"{executorComplete.ExecutorId}: {executorComplete.Data}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ await InvokeAgentAsync(

if (autoSend)
{
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
}

return default;
Expand Down Expand Up @@ -113,7 +113,7 @@ await InvokeAgentAsync(

if (autoSend)
{
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
}

await context.QueueStateUpdateAsync(key: "TeacherResponse", value: agentResponse.Messages, scopeName: "Local").ConfigureAwait(false);
Expand Down Expand Up @@ -176,7 +176,7 @@ GOLD STAR!
"""
);
AgentResponse response = new([new ChatMessage(ChatRole.Assistant, activityText)]);
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, response)).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, response)).ConfigureAwait(false);

return default;
}
Expand All @@ -197,7 +197,7 @@ await context.FormatTemplateAsync(
"""
);
AgentResponse response = new([new ChatMessage(ChatRole.Assistant, activityText)]);
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, response)).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, response)).ConfigureAwait(false);

return default;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static async Task Main()
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));
await foreach (WorkflowEvent evt in run.WatchStreamAsync())
{
if (evt is AgentRunUpdateEvent executorComplete)
if (evt is AgentResponseUpdateEvent executorComplete)
{
Console.WriteLine($"{executorComplete.ExecutorId}: {executorComplete.Data}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static async Task<List<ChatMessage>> RunWorkflowAsync(Workflow workflow, List<Ch
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));
await foreach (WorkflowEvent evt in run.WatchStreamAsync())
{
if (evt is AgentRunUpdateEvent e)
if (evt is AgentResponseUpdateEvent e)
{
if (e.ExecutorId != lastExecutorId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ private static async Task ExecuteWorkflowAsync(Workflow workflow, string input)
// Don't print internal executor outputs, let them handle their own printing
break;

case AgentRunUpdateEvent:
case AgentResponseUpdateEvent:
// Show agent thinking in real-time (optional)
if (ShowAgentThinking && !string.IsNullOrEmpty(((AgentRunUpdateEvent)evt).Update.Text))
if (ShowAgentThinking && !string.IsNullOrEmpty(((AgentResponseUpdateEvent)evt).Update.Text))
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write(((AgentRunUpdateEvent)evt).Update.Text);
Console.Write(((AgentResponseUpdateEvent)evt).Update.Text);
Console.ResetColor();
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static async Task ExecuteWorkflowAsync(Workflow workflow, string input)
{
switch (evt)
{
case AgentRunUpdateEvent agentUpdate:
case AgentResponseUpdateEvent agentUpdate:
// Stream agent output in real-time
if (!string.IsNullOrEmpty(agentUpdate.Update.Text))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ await InvokeAgentAsync(

if (autoSend)
{
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
}
");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal sealed class <#= this.Name #>Executor(FormulaSession session, WorkflowA

if (autoSend)
{
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, agentResponse)).ConfigureAwait(false);
}
<#
AssignVariable(this.Messages, "agentResponse.Messages"); #>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override string TransformText()
}

this.Write("\n );\n AgentResponse response = new([new ChatMessage(ChatRole" +
".Assistant, activityText)]);\n await context.AddEventAsync(new AgentRunRes" +
".Assistant, activityText)]);\n await context.AddEventAsync(new AgentRes" +
"ponseEvent(this.Id, response)).ConfigureAwait(false);");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (this.Model.Activity is MessageActivityTemplate messageActivity)
#>
);
AgentResponse response = new([new ChatMessage(ChatRole.Assistant, activityText)]);
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, response)).ConfigureAwait(false);<#
await context.AddEventAsync(new AgentResponseEvent(this.Id, response)).ConfigureAwait(false);<#
} #>

return default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public static async ValueTask<AgentResponse> InvokeAgentAsync(

if (autoSend)
{
await context.AddEventAsync(new AgentRunUpdateEvent(executorId, update), cancellationToken).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseUpdateEvent(executorId, update), cancellationToken).ConfigureAwait(false);
}
}

AgentResponse response = updates.ToAgentResponse();

if (autoSend)
{
await context.AddEventAsync(new AgentRunResponseEvent(executorId, response), cancellationToken).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(executorId, response), cancellationToken).ConfigureAwait(false);
}

// If autoSend is enabled and this is not the workflow conversation, copy messages to the workflow conversation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal sealed class AddConversationMessageExecutor(AddConversationMessage mode

if (isWorkflowConversation)
{
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, new AgentResponse(newMessage)), cancellationToken).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, new AgentResponse(newMessage)), cancellationToken).ConfigureAwait(false);
}

return default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal sealed class CopyConversationMessagesExecutor(CopyConversationMessages

if (isWorkflowConversation)
{
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, new AgentResponse([.. inputMessages])), cancellationToken).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, new AgentResponse([.. inputMessages])), cancellationToken).ConfigureAwait(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
namespace Microsoft.Agents.AI.Workflows;

/// <summary>
/// Represents an event triggered when an agent run produces an update.
/// Represents an event triggered when an agent produces a response.
/// </summary>
public class AgentRunResponseEvent : ExecutorEvent
public class AgentResponseEvent : ExecutorEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="AgentRunUpdateEvent"/> class.
/// Initializes a new instance of the <see cref="AgentResponseEvent"/> class.
/// </summary>
/// <param name="executorId">The identifier of the executor that generated this event.</param>
/// <param name="response">The agent run response.</param>
public AgentRunResponseEvent(string executorId, AgentResponse response) : base(executorId, data: response)
/// <param name="response">The agent response.</param>
public AgentResponseEvent(string executorId, AgentResponse response) : base(executorId, data: response)
{
this.Response = Throw.IfNull(response);
}

/// <summary>
/// Gets the agent run response.
/// Gets the agent response.
/// </summary>
public AgentResponse Response { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ namespace Microsoft.Agents.AI.Workflows;
/// <summary>
/// Represents an event triggered when an agent run produces an update.
/// </summary>
public class AgentRunUpdateEvent : ExecutorEvent
public class AgentResponseUpdateEvent : ExecutorEvent
{
/// <summary>
/// Initializes a new instance of the <see cref="AgentRunUpdateEvent"/> class.
/// Initializes a new instance of the <see cref="AgentResponseUpdateEvent"/> class.
/// </summary>
/// <param name="executorId">The identifier of the executor that generated this event.</param>
/// <param name="update">The agent run response update.</param>
public AgentRunUpdateEvent(string executorId, AgentResponseUpdate update) : base(executorId, data: update)
public AgentResponseUpdateEvent(string executorId, AgentResponseUpdate update) : base(executorId, data: update)
{
this.Update = Throw.IfNull(update);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ await this.EnsureThreadAsync(context, cancellationToken).ConfigureAwait(false),

await foreach (AgentResponseUpdate update in agentStream.ConfigureAwait(false))
{
await context.AddEventAsync(new AgentRunUpdateEvent(this.Id, update), cancellationToken).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseUpdateEvent(this.Id, update), cancellationToken).ConfigureAwait(false);

// TODO: FunctionCall request handling, and user info request handling.
// In some sense: We should just let it be handled as a ChatMessage, though we should consider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override async ValueTask TakeTurnAsync(List<ChatMessage> messages, IWo
updates.Add(update);
if (emitEvents is true)
{
await context.AddEventAsync(new AgentRunUpdateEvent(this.Id, update), cancellationToken).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseUpdateEvent(this.Id, update), cancellationToken).ConfigureAwait(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async Task AddUpdateAsync(AgentResponseUpdate update, CancellationToken cancella
updates.Add(update);
if (handoffState.TurnToken.EmitEvents is true)
{
await context.AddEventAsync(new AgentRunUpdateEvent(this.Id, update), cancellationToken).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseUpdateEvent(this.Id, update), cancellationToken).ConfigureAwait(false);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ IAsyncEnumerable<AgentResponseUpdate> InvokeStageAsync(
{
switch (evt)
{
case AgentRunUpdateEvent agentUpdate:
case AgentResponseUpdateEvent agentUpdate:
yield return agentUpdate.Update;
break;

Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/Shared/Workflows/Execution/WorkflowRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public async Task ExecuteAsync(Func<Workflow> workflowProvider, string input)
Console.ResetColor();
break;

case AgentRunUpdateEvent streamEvent:
case AgentResponseUpdateEvent streamEvent:
if (!string.Equals(messageId, streamEvent.Update.MessageId, StringComparison.Ordinal))
{
hasStreamed = false;
Expand Down Expand Up @@ -230,7 +230,7 @@ public async Task ExecuteAsync(Func<Workflow> workflowProvider, string input)
}
break;

case AgentRunResponseEvent messageEvent:
case AgentResponseEvent messageEvent:
try
{
if (hasStreamed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public WorkflowEvents(IReadOnlyList<WorkflowEvent> workflowEvents)
this.ExecutorInvokeEvents = workflowEvents.OfType<ExecutorInvokedEvent>().ToList();
this.ExecutorCompleteEvents = workflowEvents.OfType<ExecutorCompletedEvent>().ToList();
this.InputEvents = workflowEvents.OfType<RequestInfoEvent>().ToList();
this.AgentResponseEvents = workflowEvents.OfType<AgentRunResponseEvent>().ToList();
this.AgentResponseEvents = workflowEvents.OfType<AgentResponseEvent>().ToList();
}

public IReadOnlyList<WorkflowEvent> Events { get; }
Expand All @@ -29,5 +29,5 @@ public WorkflowEvents(IReadOnlyList<WorkflowEvent> workflowEvents)
public IReadOnlyList<ExecutorInvokedEvent> ExecutorInvokeEvents { get; }
public IReadOnlyList<ExecutorCompletedEvent> ExecutorCompleteEvents { get; }
public IReadOnlyList<RequestInfoEvent> InputEvents { get; }
public IReadOnlyList<AgentRunResponseEvent> AgentResponseEvents { get; }
public IReadOnlyList<AgentResponseEvent> AgentResponseEvents { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private static async IAsyncEnumerable<WorkflowEvent> MonitorAndDisposeWorkflowRu
Console.WriteLine($"ACTION: {actionInvokeEvent.ActionId} [{actionInvokeEvent.ActionType}]");
break;

case AgentRunResponseEvent responseEvent:
case AgentResponseEvent responseEvent:
if (!string.IsNullOrEmpty(responseEvent.Response.Text))
{
Console.WriteLine($"AGENT: {responseEvent.Response.AgentId}: {responseEvent.Response.Text}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static void EventCounts(int actualCount, Testcase testcase, bool isComple
}
}

public static void Responses(IReadOnlyList<AgentRunResponseEvent> responseEvents, Testcase testcase)
public static void Responses(IReadOnlyList<AgentResponseEvent> responseEvents, Testcase testcase)
{
Assert.True(responseEvents.Count >= testcase.Validation.MinResponseCount, $"Response count less than expected: {testcase.Validation.MinResponseCount} (Actual: {responseEvents.Count})");
if (testcase.Validation.MaxResponseCount != -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private async Task ValidateFileAsync(AIContent fileContent)
WorkflowEvents workflowEvents = await harness.RunWorkflowAsync(inputMessage).ConfigureAwait(false);
ConversationUpdateEvent conversationEvent = Assert.Single(workflowEvents.ConversationEvents);
this.Output.WriteLine("CONVERSATION: " + conversationEvent.ConversationId);
AgentRunResponseEvent agentResponseEvent = Assert.Single(workflowEvents.AgentResponseEvents);
AgentResponseEvent agentResponseEvent = Assert.Single(workflowEvents.AgentResponseEvents);
this.Output.WriteLine("RESPONSE: " + agentResponseEvent.Response.Text);
Assert.NotEmpty(agentResponseEvent.Response.Text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private async Task RunWorkflowAsync<TInput>(string workflowPath, TInput workflow
this.Output.WriteLine($"ACTIVITY: {activityEvent.Message}");
break;

case AgentRunResponseEvent messageEvent:
case AgentResponseEvent messageEvent:
this.Output.WriteLine($"MESSAGE: {messageEvent.Response.Messages[0].Text.Trim()}");
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ NEVER 1!
"""
);
AgentResponse response = new([new ChatMessage(ChatRole.Assistant, activityText)]);
await context.AddEventAsync(new AgentRunResponseEvent(this.Id, response)).ConfigureAwait(false);
await context.AddEventAsync(new AgentResponseEvent(this.Id, response)).ConfigureAwait(false);

return default;
}
Expand Down
Loading
Loading