mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.NET Workflows -Fix Declarative Workflow Tests (#1065)
* Fixed * Restore generated workflow * Project * Fine tune * Update baseline * Adjust test-case
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
+5
-4
@@ -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" +
|
||||
|
||||
+4
-1
@@ -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");
|
||||
|
||||
+5
-4
@@ -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");
|
||||
|
||||
|
||||
+4
-1
@@ -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)
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
}
|
||||
},
|
||||
"validation": {
|
||||
"min_action_count": 28,
|
||||
"min_action_count": 25,
|
||||
"max_action_count": 56,
|
||||
"actions": {
|
||||
"start": [
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user