.NET Workflows -Fix Declarative Workflow Tests (#1065)

* Fixed

* Restore generated workflow

* Project

* Fine tune

* Update baseline

* Adjust test-case
This commit is contained in:
Chris
2025-10-01 09:15:46 -07:00
committed by GitHub
Unverified
parent dc9d1a6280
commit f5ca4f42c0
10 changed files with 49 additions and 41 deletions
@@ -48,9 +48,9 @@ public static class TestWorkflowProvider
context,
"FOUNDRY_AGENT_RESEARCHWEB",
"FOUNDRY_AGENT_RESEARCHANALYST",
"FOUNDRY_AGENT_RESEARCHCODER",
"FOUNDRY_AGENT_RESEARCHMANAGER",
"FOUNDRY_AGENT_RESEARCHWEATHER",
"FOUNDRY_AGENT_RESEARCHCODER").ConfigureAwait(false);
"FOUNDRY_AGENT_RESEARCHWEATHER").ConfigureAwait(false);
// Initialize variables
await context.QueueStateUpdateAsync("AgentResponse", UnassignedValue.Instance, "Local").ConfigureAwait(false);
@@ -476,27 +476,27 @@ public static class TestWorkflowProvider
protected override async ValueTask<object?> ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken)
{
VariableType targetType =
VariableType.Record(
("instruction_or_question",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(string)))),
("next_speaker",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(string)))),
("is_request_satisfied",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(bool)))),
("is_progress_being_made",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(bool)))),
("is_in_loop",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(bool)))));
VariableType.Record(
("is_progress_being_made",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(bool)))),
("is_request_satisfied",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(bool)))),
("is_in_loop",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(bool)))),
("next_speaker",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(string)))),
("instruction_or_question",
VariableType.Record(
("reason", typeof(string)),
("answer", typeof(string)))));
object? parsedValue = await context.ConvertValueAsync(targetType, "Last(Local.ProgressLedgerUpdate).Text", cancellationToken).ConfigureAwait(false);
await context.QueueStateUpdateAsync(key: "TypedProgressLedger", value: parsedValue, scopeName: "Local").ConfigureAwait(false);
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version: 18.0.0.0
// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -19,7 +19,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
/// <summary>
/// Class to produce the template output
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "18.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
internal partial class AddConversationMessageTemplate : ActionTemplate
{
/// <summary>
@@ -55,8 +55,9 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
" {");
EvaluateStringExpression(this.Model.ConversationId, "conversationId", isNullable: true);
this.Write("\n ArgumentNullException.ThrowIfNull(conversationId, nameof(conversationId)" +
");\n ChatMessage newMessage = new(ChatRole.");
this.Write("\n if (string.IsNullOrWhiteSpace(conversationId))\n {\n thr" +
"ow new DeclarativeActionException($\"Conversation identifier must be defined: {th" +
"is.Id}\");\n }\n ChatMessage newMessage = new(ChatRole.");
this.Write(this.ToStringHelper.ToStringWithCulture(FormatEnum(this.Model.Role, RoleMap)));
this.Write(", [.. this.GetContentAsync(context).ToEnumerable()]) { AdditionalProperties = thi" +
"s.GetMetadata() };\n await agentProvider.CreateMessageAsync(conversationId" +
@@ -12,7 +12,10 @@ internal sealed class <#= this.Name #>Executor(FormulaSession session, WorkflowA
protected override async ValueTask<object?> ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken)
{<#
EvaluateStringExpression(this.Model.ConversationId, "conversationId", isNullable: true); #>
ArgumentNullException.ThrowIfNull(conversationId, nameof(conversationId));
if (string.IsNullOrWhiteSpace(conversationId))
{
throw new DeclarativeActionException($"Conversation identifier must be defined: {this.Id}");
}
ChatMessage newMessage = new(ChatRole.<#= FormatEnum(this.Model.Role, RoleMap) #>, [.. this.GetContentAsync(context).ToEnumerable()]) { AdditionalProperties = this.GetMetadata() };
await agentProvider.CreateMessageAsync(conversationId, newMessage, cancellationToken).ConfigureAwait(false);<#
AssignVariable(this.Message, "newMessage");
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version: 18.0.0.0
// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -19,7 +19,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
/// <summary>
/// Class to produce the template output
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "18.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
internal partial class CopyConversationMessagesTemplate : ActionTemplate
{
/// <summary>
@@ -55,8 +55,9 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
" {");
EvaluateStringExpression(this.Model.ConversationId, "conversationId", isNullable: true);
this.Write("\n ArgumentNullException.ThrowIfNull(conversationId, nameof(conversationId)" +
");");
this.Write("\n if (string.IsNullOrWhiteSpace(conversationId))\n {\n thr" +
"ow new DeclarativeActionException($\"Conversation identifier must be defined: {th" +
"is.Id}\");\n }");
EvaluateValueExpression<ChatMessage[]>(this.Model.Messages, "messages");
@@ -11,7 +11,10 @@ internal sealed class <#= this.Name #>Executor(FormulaSession session, WorkflowA
protected override async ValueTask<object?> ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken)
{<#
EvaluateStringExpression(this.Model.ConversationId, "conversationId", isNullable: true); #>
ArgumentNullException.ThrowIfNull(conversationId, nameof(conversationId));<#
if (string.IsNullOrWhiteSpace(conversationId))
{
throw new DeclarativeActionException($"Conversation identifier must be defined: {this.Id}");
}<#
EvaluateValueExpression<ChatMessage[]>(this.Model.Messages, "messages");
#>
if (messages is not null)
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version: 18.0.0.0
// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -19,7 +19,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
/// <summary>
/// Class to produce the template output
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "18.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
internal partial class InvokeAzureAgentTemplate : ActionTemplate
{
/// <summary>
@@ -56,8 +56,8 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
EvaluateStringExpression(this.Model.Agent.Name, "agentName", isNullable: true);
this.Write("\n\n if (string.IsNullOrWhiteSpace(agentName))\n {\n throw n" +
"ew InvalidOperationException($\"Agent name must be defined: {this.Id}\");\n " +
"}\n ");
"ew DeclarativeActionException($\"Agent name must be defined: {this.Id}\");\n " +
" }\n ");
EvaluateStringExpression(this.Model.ConversationId, "conversationId", isNullable: true);
EvaluateBoolExpression(this.Model.Output?.AutoSend, "autoSend", defaultValue: true);
@@ -14,7 +14,7 @@ internal sealed class <#= this.Name #>Executor(FormulaSession session, WorkflowA
if (string.IsNullOrWhiteSpace(agentName))
{
throw new InvalidOperationException($"Agent name must be defined: {this.Id}");
throw new DeclarativeActionException($"Agent name must be defined: {this.Id}");
}
<#
EvaluateStringExpression(this.Model.ConversationId, "conversationId", isNullable: true);
@@ -7,7 +7,7 @@
}
},
"validation": {
"min_action_count": 28,
"min_action_count": 25,
"max_action_count": 56,
"actions": {
"start": [
@@ -63,7 +63,7 @@ public static class WorkflowProvider
if (string.IsNullOrWhiteSpace(agentName))
{
throw new InvalidOperationException($"Agent name must be defined: {this.Id}");
throw new DeclarativeActionException($"Agent name must be defined: {this.Id}");
}
string? conversationId = await context.ReadStateAsync<string>(key: "ConversationId", scopeName: "System").ConfigureAwait(false);
+1 -1
View File
@@ -314,7 +314,7 @@ trigger:
conditions:
- id: conditionItem_fpaNL9
condition: =.TypedProgressLedger.is_in_loop.answer
condition: =Local.TypedProgressLedger.is_in_loop.answer
displayName: Is Loop
actions:
- kind: SendActivity