mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.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:
+7
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user