.NET Workflows - Re-enable Declarative Integration Tests (#1080)

* Investigate

* Next

* Update initialization

* Should be ok

* Agent definition dx

* Link agent definitions

* Link agent definitions

* Path resolution #2

* Fix path resolution

* Another pass

* Another

* Better

* One more

* Whoopsie

* Update dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Framework/AgentFactory.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Namespace

* Cleanup

* Temp config for pipeline

* Another temp workaround

* Test config: Bing Grounding Tool

* Update template

* Next pass

* Ok now

* Cleanup

* Test note

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Chris
2025-10-01 22:21:45 +00:00
committed by GitHub
co-authored by Copilot
parent 9a59b86fc8
commit 6d0f28eb9b
23 changed files with 83 additions and 54 deletions
@@ -59,14 +59,15 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
"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" +
", newMessage, cancellationToken).ConfigureAwait(false);");
this.Write(", await this.GetContentAsync(context).ConfigureAwait(false)) { AdditionalProperti" +
"es = this.GetMetadata() };\n await agentProvider.CreateMessageAsync(conver" +
"sationId, newMessage, cancellationToken).ConfigureAwait(false);");
AssignVariable(this.Message, "newMessage");
this.Write("\n return default;\n }\n\n private async IAsyncEnumerable<AIContent> Get" +
"ContentAsync(IWorkflowContext context)\n {");
this.Write("\n return default;\n }\n\n private async ValueTask<IList<AIContent>> Get" +
"ContentAsync(IWorkflowContext context)\n {\n List<AIContent> content = [" +
"];\n ");
int index = 0;
foreach (AddConversationMessageContent content in this.Model.Content)
@@ -76,23 +77,28 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
AgentMessageContentType contentType = content.Type.Value;
if (contentType == AgentMessageContentType.ImageUrl)
{
this.Write("\n yield return new UriContent(contentValue, \"image/*\");");
this.Write("\n content.Add(UriContent(contentValue");
this.Write(this.ToStringHelper.ToStringWithCulture(index));
this.Write(", \"image/*\"));");
}
else if (contentType == AgentMessageContentType.ImageFile)
{
this.Write("\n yield return new HostedFileContent(contentValue);");
this.Write("\n content.Add(new HostedFileContent(contentValue");
this.Write(this.ToStringHelper.ToStringWithCulture(index));
this.Write("));");
}
else
{
this.Write("\n yield return new TextContent(contentValue");
this.Write("\n content.Add(new TextContent(contentValue");
this.Write(this.ToStringHelper.ToStringWithCulture(index));
this.Write(");");
this.Write("));");
}
}
this.Write("\n }\n\n private AdditionalPropertiesDictionary? GetMetadata()\n {");
this.Write("\n return content;\n }\n\n private AdditionalPropertiesDictionary? GetMe" +
"tadata()\n {");
EvaluateRecordExpression<object>(this.Model.Metadata, "metadata");
this.Write("\n\n if (metadata is null)\n {\n return null; \n }\n" +
@@ -16,15 +16,17 @@ internal sealed class <#= this.Name #>Executor(FormulaSession session, WorkflowA
{
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() };
ChatMessage newMessage = new(ChatRole.<#= FormatEnum(this.Model.Role, RoleMap) #>, await this.GetContentAsync(context).ConfigureAwait(false)) { AdditionalProperties = this.GetMetadata() };
await agentProvider.CreateMessageAsync(conversationId, newMessage, cancellationToken).ConfigureAwait(false);<#
AssignVariable(this.Message, "newMessage");
#>
return default;
}
private async IAsyncEnumerable<AIContent> GetContentAsync(IWorkflowContext context)
{<#
private async ValueTask<IList<AIContent>> GetContentAsync(IWorkflowContext context)
{
List<AIContent> content = [];
<#
int index = 0;
foreach (AddConversationMessageContent content in this.Model.Content)
{
@@ -33,17 +35,18 @@ internal sealed class <#= this.Name #>Executor(FormulaSession session, WorkflowA
AgentMessageContentType contentType = content.Type.Value;
if (contentType == AgentMessageContentType.ImageUrl)
{#>
yield return new UriContent(contentValue, "image/*");<#
content.Add(UriContent(contentValue<#= index #>, "image/*"));<#
}
else if (contentType == AgentMessageContentType.ImageFile)
{#>
yield return new HostedFileContent(contentValue);<#
content.Add(new HostedFileContent(contentValue<#= index #>));<#
}
else
{#>
yield return new TextContent(contentValue<#= index #>);<#
content.Add(new TextContent(contentValue<#= index #>));<#
}
}#>
return content;
}
private AdditionalPropertiesDictionary? GetMetadata()
@@ -10,4 +10,6 @@ internal sealed class AzureAIConfiguration
public string Endpoint { get; set; }
public string DeploymentName { get; set; }
public string BingConnectionId { get; set; }
}