.NET: NET Workflows - Skip conversation initialization when identifier is provided (#1087)

* Fix

* Code-gen case

* Tests

* Autosend logic

* Build fix

* Namespace

* Validation enhancement
This commit is contained in:
Chris
2025-10-02 14:27:46 +00:00
committed by GitHub
parent cb62407fb8
commit 08ea625de0
23 changed files with 102 additions and 31 deletions
@@ -13,7 +13,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.Interpreter;
/// </summary>
internal sealed class DeclarativeWorkflowExecutor<TInput>(
string workflowId,
WorkflowAgentProvider agentProvider,
DeclarativeWorkflowOptions options,
WorkflowFormulaState state,
Func<TInput, ChatMessage> inputTransform) :
Executor<TInput>(workflowId), IModeledAction where TInput : notnull
@@ -26,10 +26,14 @@ internal sealed class DeclarativeWorkflowExecutor<TInput>(
DeclarativeWorkflowContext declarativeContext = new(context, state);
ChatMessage input = inputTransform.Invoke(message);
string conversationId = await agentProvider.CreateConversationAsync(cancellationToken: default).ConfigureAwait(false);
string? conversationId = options.ConversationId;
if (string.IsNullOrWhiteSpace(conversationId))
{
conversationId = await options.AgentProvider.CreateConversationAsync(cancellationToken: default).ConfigureAwait(false);
}
await declarativeContext.QueueConversationUpdateAsync(conversationId).ConfigureAwait(false);
await agentProvider.CreateMessageAsync(conversationId, input, cancellationToken: default).ConfigureAwait(false);
await options.AgentProvider.CreateMessageAsync(conversationId, input, cancellationToken: default).ConfigureAwait(false);
await declarativeContext.SetLastMessageAsync(input).ConfigureAwait(false);
await context.SendResultMessageAsync(this.Id).ConfigureAwait(false);