.NET: Add Foundry Evaluation samples (Safety + Quality)#3697
Merged
rogerbarreto merged 11 commits intomainfrom Feb 18, 2026
Merged
.NET: Add Foundry Evaluation samples (Safety + Quality)#3697rogerbarreto merged 11 commits intomainfrom
rogerbarreto merged 11 commits intomainfrom
Conversation
Copilot
AI
changed the title
[WIP] Add .NET samples for Foundry observability and evaluations
.NET: Add Foundry Evaluation samples for Red Teaming and Self-Reflection
Feb 5, 2026
Copilot
AI
changed the title
.NET: Add Foundry Evaluation samples for Red Teaming and Self-Reflection
Refactor evaluation samples: Replace instructional Console.WriteLine with real implementations
Feb 5, 2026
Copilot
AI
changed the title
Refactor evaluation samples: Replace instructional Console.WriteLine with real implementations
Uncomment evaluation sample function definitions, keep only invocations commented
Feb 5, 2026
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
…nted Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com>
- Rename Evaluation/Evaluation_StepXX to FoundryAgents_Evaluations_StepXX - Add evaluation projects to slnx - Fix var usage, apply dotnet format, use DefaultAzureCredential - Add try/finally for agent cleanup - Fix evaluator deployment name separation in Step02 - Update README references Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
343b0df to
af12ba1
Compare
The .NET RedTeam API currently only supports model deployment targets via AzureOpenAIModelConfiguration. Agent-targeted red teaming with AzureAIAgentTarget is documented in concept docs but not yet available in the SDK's RedTeam constructor. Results appear in classic portal view. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
westey-m
reviewed
Feb 17, 2026
...ples/GettingStarted/FoundryAgents/FoundryAgents_Evaluations_Step02_SelfReflection/Program.cs
Outdated
Show resolved
Hide resolved
westey-m
reviewed
Feb 17, 2026
...ples/GettingStarted/FoundryAgents/FoundryAgents_Evaluations_Step02_SelfReflection/Program.cs
Show resolved
Hide resolved
westey-m
approved these changes
Feb 17, 2026
Clarify that this sample uses the classic Azure AI Foundry red teaming API (/redTeams/runs). The new Foundry portal uses a separate evaluation- based API not yet available in the .NET SDK. AzureAIAgentTarget exists in the SDK but is consumed by the Evaluation Taxonomy API, not RedTeam. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SergeyMenshykh
approved these changes
Feb 17, 2026
- Pass full prompt (with context) to evaluator messages instead of just the question, so evaluator input matches what the agent received - Include previous response text in self-reflection refinement prompt so the LLM can meaningfully improve its answer across iterations - Inline CreateKnowledgeAgent helper (single use, single statement) - Add comment clarifying why RunCombinedQualityAndSafetyEvaluation intentionally passes only the question (no context) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SergeyMenshykh
approved these changes
Feb 18, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 18, 2026
* Initial plan * Add Foundry evaluation samples for Red Teaming and Self-Reflection Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com> * Refactor evaluation samples with real implementations in local functions Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com> * Uncomment function signatures and bodies, keep only invocations commented Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com> * Update Foundry evaluation samples with observability support * Restructure evaluation samples to follow FoundryAgents naming convention - Rename Evaluation/Evaluation_StepXX to FoundryAgents_Evaluations_StepXX - Add evaluation projects to slnx - Fix var usage, apply dotnet format, use DefaultAzureCredential - Add try/finally for agent cleanup - Fix evaluator deployment name separation in Step02 - Update README references Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Rewrite Step01 to use Azure.AI.Projects RedTeam API and address review comments - Replace safety evaluator sample with actual Red Teaming using AIProjectClient.RedTeams - Use AttackStrategy (Easy, Moderate, Jailbreak) and RiskCategory from Azure.AI.Projects - Remove Microsoft.Extensions.AI.Evaluation.Safety dependency from Step01 - Add DefaultAzureCredential warning comments to Step02 - Remove unused bestResponse variable in Step02 - Add session isolation comments in self-reflection loop - Fix stale directory references in READMEs - Fix misleading evaluation overview link in main README Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add note about agent-targeted red teaming limitations in README The .NET RedTeam API currently only supports model deployment targets via AzureOpenAIModelConfiguration. Agent-targeted red teaming with AzureAIAgentTarget is documented in concept docs but not yet available in the SDK's RedTeam constructor. Results appear in classic portal view. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add classic Foundry disclaimer to red teaming sample README Clarify that this sample uses the classic Azure AI Foundry red teaming API (/redTeams/runs). The new Foundry portal uses a separate evaluation- based API not yet available in the .NET SDK. AzureAIAgentTarget exists in the SDK but is consumed by the Evaluation Taxonomy API, not RedTeam. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address PR review comments on Step02 SelfReflection - Pass full prompt (with context) to evaluator messages instead of just the question, so evaluator input matches what the agent received - Include previous response text in self-reflection refinement prompt so the LLM can meaningfully improve its answer across iterations - Inline CreateKnowledgeAgent helper (single use, single statement) - Add comment clarifying why RunCombinedQualityAndSafetyEvaluation intentionally passes only the question (no context) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rogerbarreto <19890735+rogerbarreto@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
westey-m
approved these changes
Feb 18, 2026
This was referenced Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Adds .NET evaluation samples for Foundry Agents, achieving parity with existing Python evaluation samples. Part of #3675 / #3440.
Description
This PR adds two new evaluation samples demonstrating how to assess agent safety and quality using
Microsoft.Extensions.AI.Evaluationpackages with Azure AI Foundry.New Samples
FoundryAgents_Evaluations_Step01_RedTeamingContentHarmEvaluator,ViolenceEvaluator,HateAndUnfairnessEvaluator,ProtectedMaterialEvaluator,IndirectAttackEvaluatorFoundryAgents_Evaluations_Step02_SelfReflectionGroundednessEvaluator,RelevanceEvaluator,CoherenceEvaluatorKey Changes
FoundryAgents_Evaluations_StepXX_*naming convention (same level as other FoundryAgents samples)Directory.Packages.props:Microsoft.Extensions.AI.Evaluation10.3.0Microsoft.Extensions.AI.Evaluation.Quality10.3.0Microsoft.Extensions.AI.Evaluation.Safety10.3.0-previewvar), collection expressions,DefaultAzureCredential,dotnet formatcleantry/finallyblocks ensure agent cleanup even on evaluation failuresAZURE_OPENAI_DEPLOYMENT_NAMEfor evaluator model (may differ from Foundry agent model)Environment Variables
AZURE_FOUNDRY_PROJECT_ENDPOINTAZURE_FOUNDRY_PROJECT_DEPLOYMENT_NAMEAZURE_OPENAI_ENDPOINTAZURE_OPENAI_DEPLOYMENT_NAMERegional Requirements
Contribution Checklist
dotnet formatpasses with no changes