-
Notifications
You must be signed in to change notification settings - Fork 2.3k
.NET: Forward agent response details in workflows #7975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d674662
5779b70
6b2cb85
e005213
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System.Collections.Generic; | ||
| using Microsoft.Extensions.AI; | ||
| using Microsoft.Shared.Diagnostics; | ||
|
|
||
| namespace Microsoft.Agents.AI.Workflows; | ||
|
|
||
|
|
@@ -44,4 +46,65 @@ public sealed class AIAgentHostOptions | |
| /// by the agent during its turn. | ||
| /// </summary> | ||
| public bool ForwardIncomingMessages { get; set; } = true; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether the complete agent response should be forwarded as a workflow message. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// When enabled, downstream executors that handle <see cref="AIAgentHostResponse"/> can inspect response-level | ||
| /// metadata such as <see cref="AgentResponse.FinishReason"/>, <see cref="AgentResponse.Usage"/>, and | ||
| /// <see cref="AgentResponse.ResponseId"/>. Existing chat-message forwarding is unchanged. | ||
| /// </remarks> | ||
| public bool ForwardAgentResponse { get; set; } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Represents the complete response produced by an <see cref="AIAgent"/> hosted in a workflow. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <see cref="AIAgentHostResponse"/> is sent as a workflow message when | ||
| /// <see cref="AIAgentHostOptions.ForwardAgentResponse"/> is enabled. It allows custom downstream executors to inspect | ||
| /// response-level metadata while the existing chat-message path continues to carry portable conversation messages to | ||
| /// chat-protocol executors. | ||
| /// </remarks> | ||
| public sealed class AIAgentHostResponse | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="AIAgentHostResponse"/> class. | ||
| /// </summary> | ||
| /// <param name="executorId">The ID of the executor that produced the response.</param> | ||
| /// <param name="agentResponse">The complete response returned by the hosted agent.</param> | ||
| /// <param name="currentTurnMessages">The portable messages for the current host turn, including input messages and forwarded response messages.</param> | ||
| /// <param name="forwardableMessages">The sanitized response messages forwarded on the chat-message path.</param> | ||
| public AIAgentHostResponse( | ||
| string executorId, | ||
| AgentResponse agentResponse, | ||
| IReadOnlyList<ChatMessage> currentTurnMessages, | ||
| IReadOnlyList<ChatMessage> forwardableMessages) | ||
| { | ||
| this.ExecutorId = Throw.IfNull(executorId); | ||
| this.AgentResponse = Throw.IfNull(agentResponse); | ||
| this.CurrentTurnMessages = new List<ChatMessage>(Throw.IfNull(currentTurnMessages)); | ||
| this.ForwardableMessages = new List<ChatMessage>(Throw.IfNull(forwardableMessages)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the ID of the executor that produced the response. | ||
| /// </summary> | ||
| public string ExecutorId { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the complete response returned by the hosted agent. | ||
| /// </summary> | ||
| public AgentResponse AgentResponse { get; } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This response is persisted through the new checkpoint contract, but |
||
|
|
||
| /// <summary> | ||
| /// Gets the portable messages for the current host turn, including the input messages and forwarded response messages. | ||
| /// </summary> | ||
| public IReadOnlyList<ChatMessage> CurrentTurnMessages { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the sanitized response messages forwarded on the chat-message path. | ||
| /// </summary> | ||
| public IReadOnlyList<ChatMessage> ForwardableMessages { get; } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| #nullable enable | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.get -> bool | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.set -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AgentResponse.get -> Microsoft.Agents.AI.AgentResponse! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AIAgentHostResponse(string! executorId, Microsoft.Agents.AI.AgentResponse! agentResponse, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! currentTurnMessages, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! forwardableMessages) -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ExecutorId.get -> string! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ForwardableMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.CurrentTurnMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| #nullable enable | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.get -> bool | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.set -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AgentResponse.get -> Microsoft.Agents.AI.AgentResponse! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AIAgentHostResponse(string! executorId, Microsoft.Agents.AI.AgentResponse! agentResponse, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! currentTurnMessages, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! forwardableMessages) -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ExecutorId.get -> string! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ForwardableMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.CurrentTurnMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| #nullable enable | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.get -> bool | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.set -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AgentResponse.get -> Microsoft.Agents.AI.AgentResponse! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AIAgentHostResponse(string! executorId, Microsoft.Agents.AI.AgentResponse! agentResponse, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! currentTurnMessages, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! forwardableMessages) -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ExecutorId.get -> string! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ForwardableMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.CurrentTurnMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| #nullable enable | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.get -> bool | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.set -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AgentResponse.get -> Microsoft.Agents.AI.AgentResponse! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AIAgentHostResponse(string! executorId, Microsoft.Agents.AI.AgentResponse! agentResponse, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! currentTurnMessages, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! forwardableMessages) -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ExecutorId.get -> string! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ForwardableMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.CurrentTurnMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| #nullable enable | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.get -> bool | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostOptions.ForwardAgentResponse.set -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AgentResponse.get -> Microsoft.Agents.AI.AgentResponse! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.AIAgentHostResponse(string! executorId, Microsoft.Agents.AI.AgentResponse! agentResponse, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! currentTurnMessages, System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! forwardableMessages) -> void | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ExecutorId.get -> string! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.ForwardableMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! | ||
| Microsoft.Agents.AI.Workflows.AIAgentHostResponse.CurrentTurnMessages.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.ChatMessage!>! |
Uh oh!
There was an error while loading. Please reload this page.