chore: import upstream snapshot with attribution
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:39:25 +08:00
commit db620d33df
5151 changed files with 925932 additions and 0 deletions
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net10.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Microsoft.Agents.AI.Foundry\Microsoft.Agents.AI.Foundry.csproj" />
<ProjectReference Include="..\..\..\..\src\Microsoft.Agents.AI.Workflows\Microsoft.Agents.AI.Workflows.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,74 @@
// Copyright (c) Microsoft. All rights reserved.
// This sample demonstrates evaluating a multi-agent workflow with per-agent breakdown.
using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
string endpoint = Environment.GetEnvironmentVariable("FOUNDRY_PROJECT_ENDPOINT")
?? throw new InvalidOperationException("FOUNDRY_PROJECT_ENDPOINT is not set.");
string deploymentName = Environment.GetEnvironmentVariable("FOUNDRY_MODEL") ?? "gpt-4o-mini";
// WARNING: DefaultAzureCredential is convenient for development but requires careful consideration in production.
// In production, consider using a specific credential (e.g., ManagedIdentityCredential) to avoid
// latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
AIProjectClient aiProjectClient = new(new Uri(endpoint), new DefaultAzureCredential());
// Create two agents: a planner and an executor.
AIAgent planner = aiProjectClient.AsAIAgent(
model: deploymentName,
instructions: "You plan trips. Output a concise bullet-point plan.",
name: "planner");
AIAgent executor = aiProjectClient.AsAIAgent(
model: deploymentName,
instructions: "You execute travel plans. Confirm the bookings listed in the plan.",
name: "executor");
// Build a simple planner -> executor workflow.
Workflow workflow = new WorkflowBuilder(planner)
.AddEdge(planner, executor)
.Build();
// Run the workflow to completion (RunAsync returns Run which supports EvaluateAsync).
await using Run run = await InProcessExecution.RunAsync(
workflow,
new ChatMessage(ChatRole.User, "Plan a weekend trip to Paris"));
// Print the events from the run.
foreach (WorkflowEvent evt in run.OutgoingEvents)
{
if (evt is AgentResponseEvent response)
{
Console.WriteLine($" {response.ExecutorId}: {response.Response.Text[..Math.Min(80, response.Response.Text.Length)]}...");
}
}
// Evaluate with per-agent breakdown.
EvalCheck isNonempty = FunctionEvaluator.Create("is_nonempty", (string response) => response.Trim().Length > 5);
EvalCheck hasKeywords = EvalChecks.KeywordCheck("plan", "trip");
LocalEvaluator local = new(isNonempty, hasKeywords);
AgentEvaluationResults results = await run.EvaluateAsync(local);
Console.WriteLine();
Console.WriteLine($"Overall: {results.Passed}/{results.Total} passed");
if (results.SubResults is not null)
{
foreach (var (agentName, sub) in results.SubResults)
{
Console.WriteLine($" {agentName}: {sub.Passed}/{sub.Total} passed");
for (int i = 0; i < sub.Items.Count; i++)
{
foreach (var metric in sub.Items[i].Metrics)
{
string status = metric.Value.Interpretation?.Failed == true ? "FAIL" : "PASS";
Console.WriteLine($" [{status}] {metric.Key}");
}
}
}
}
@@ -0,0 +1,30 @@
# Evaluation - Workflow Eval
This sample demonstrates evaluating a multi-agent workflow with per-agent breakdown.
## What this sample demonstrates
- Building a two-agent workflow (planner → executor)
- Running the workflow and collecting events
- Using `run.EvaluateAsync()` to evaluate the completed run
- Per-agent sub-results via `results.SubResults`
- Combining `FunctionEvaluator.Create` with `EvalChecks.KeywordCheck`
## Prerequisites
- .NET 10 SDK or later
- Azure authentication available to `DefaultAzureCredential` (for local development, run `az login`)
Set the following environment variables:
```powershell
$env:FOUNDRY_PROJECT_ENDPOINT="https://your-foundry-service.services.ai.azure.com/api/projects/your-foundry-project"
$env:FOUNDRY_MODEL="gpt-4o-mini"
```
## Run the sample
```powershell
cd dotnet/samples/03-workflows/Evaluation
dotnet run --project .\Evaluation_WorkflowEval
```