Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f3db78f
.NET: Add Microsoft.Agents.AI.TypeSafe Jev AIFunction tool (alpha)
rogerbarreto Sep 24, 2026
c4a10b3
.NET: Add JevChatClient to Microsoft.Agents.AI.TypeSafe and align Jev…
rogerbarreto Sep 29, 2026
3e7756e
.NET: Address TypeSafe review feedback on schema checks and the loop …
rogerbarreto Oct 2, 2026
3ac445d
.NET: Link the TypeSafe quickstart instead of the sign-in console in …
rogerbarreto Oct 2, 2026
9894d5b
.NET: Accept integers of any size in TypeSafe tool schema checks
rogerbarreto Oct 2, 2026
d8615d2
Merge main into maf-jev-chatclient and preserve sample credentials
rogerio-barreto Oct 20, 2026
78d2948
.NET: Fix TypeSafe turn boundaries and tool schema compilation
rogerio-barreto Oct 20, 2026
80e78f2
.NET: Add an internal copy of the proposed MEAI decision API
rogerbarreto Nov 11, 2026
0f39b6a
.NET: Add an internal Jev client for the decision API
rogerbarreto Nov 11, 2026
296675e
.NET: Build JevChatClient on a provider-neutral decision chat engine
rogerbarreto Nov 11, 2026
830427a
.NET: Declare two-decimal precision for Jev decision answers
rogerbarreto Nov 12, 2026
0e55dea
Merge remote-tracking branch 'origin/main' into maf-jev-decisions
rogerbarreto Nov 12, 2026
8c32621
.NET: Expose the proposed MEAI decision API publicly from the TypeSaf…
rogerbarreto Nov 12, 2026
7e65635
.NET: Judge the TypeSafe loop sample through the decision API
rogerbarreto Nov 12, 2026
712ceae
.NET: Add agent samples for decision tools and decision routing
rogerbarreto Nov 12, 2026
49b71cb
.NET: Route issues for the TypeSafe package
rogerbarreto Nov 12, 2026
37733a6
.NET: Move the proposed MEAI decision API copy to Microsoft.Agents.AI…
rogerbarreto Nov 12, 2026
b3a1ba8
.NET: Remove JevChatClient and the decision chat engine from the Type…
rogerbarreto Nov 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/issue-routing-owners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ routes:
- { path: dotnet/src/Microsoft.Agents.AI.OpenAI/, owner: rogerbarreto, labels: [agents] }
- { path: dotnet/src/Microsoft.Agents.AI.Purview/, owner: westey-m, labels: [security] }
- { path: dotnet/src/Microsoft.Agents.AI.Tools.Shell/, owner: westey-m, labels: [agents] }
- { path: dotnet/src/Microsoft.Agents.AI.TypeSafe/, owner: rogerbarreto, labels: [agents] }
- { path: dotnet/src/Microsoft.Agents.AI.Valkey/, owner: westey-m, labels: [] }
- { path: dotnet/src/Microsoft.Agents.AI.Workflows/, owner: baywet, labels: [] }
- { path: dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/, owner: baywet, labels: [] }
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dotnet-verify-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ jobs:
FOUNDRY_PROJECT_ENDPOINT: ${{ vars.FOUNDRY_PROJECT_ENDPOINT }}
FOUNDRY_MODEL: ${{ vars.FOUNDRY_MODEL }}
AZURE_AI_BING_CONNECTION_ID: ${{ vars.AZURE_AI_BING_CONNECTION_ID }}
# TypeSafe (Jev)
TYPESAFE_API_KEY: ${{ secrets.TYPESAFE_API_KEY }}

- name: Write Job Summary
if: always()
Expand Down
6 changes: 6 additions & 0 deletions dotnet/agent-framework-dotnet.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<Project Path="samples/02-agents/AgentProviders/onnx/Agent_With_ONNX/Agent_With_ONNX.csproj" />
<Project Path="samples/02-agents/AgentProviders/openai/Agent_With_OpenAIChatCompletion/Agent_With_OpenAIChatCompletion.csproj" />
<Project Path="samples/02-agents/AgentProviders/openai/Agent_With_OpenAIResponses/Agent_With_OpenAIResponses.csproj" />
<Project Path="samples/02-agents/AgentProviders/typesafe/Agent_TypeSafe_Step01_LoopJudge/Agent_TypeSafe_Step01_LoopJudge.csproj" />
<Project Path="samples/02-agents/AgentProviders/typesafe/Agent_TypeSafe_Step02_DecisionTool/Agent_TypeSafe_Step02_DecisionTool.csproj" />
<Project Path="samples/02-agents/AgentProviders/typesafe/Agent_TypeSafe_Step03_DecisionRouting/Agent_TypeSafe_Step03_DecisionRouting.csproj" />
</Folder>
<Folder Name="/Samples/05-end-to-end/DevUIAspireIntegration/">
<Project Path="samples/05-end-to-end/DevUIAspireIntegration/DevUIIntegration.AppHost/DevUIIntegration.AppHost.csproj" />
Expand Down Expand Up @@ -70,6 +73,7 @@
<Project Path="samples/02-agents/Agents/Agent_Step22_AgentMode/Agent_Step22_AgentMode.csproj" />
<Project Path="samples/02-agents/Agents/Agent_Step23_TodoList/Agent_Step23_TodoList.csproj" />
<Project Path="samples/02-agents/Agents/Agent_Step24_MultiModelRouting/Agent_Step24_MultiModelRouting.csproj" />
<Project Path="samples/02-agents/Agents/Agent_Step25_ClassificationWithJev/Agent_Step25_ClassificationWithJev.csproj" />
</Folder>
<Folder Name="/Samples/02-agents/DeclarativeAgents/">
<Project Path="samples/02-agents/DeclarativeAgents/ChatClient/DeclarativeChatClientAgents.csproj" />
Expand Down Expand Up @@ -640,6 +644,7 @@
<Project Path="src/Microsoft.Agents.AI.OpenAI/Microsoft.Agents.AI.OpenAI.csproj" />
<Project Path="src/Microsoft.Agents.AI.Purview/Microsoft.Agents.AI.Purview.csproj" />
<Project Path="src/Microsoft.Agents.AI.Tools.Shell/Microsoft.Agents.AI.Tools.Shell.csproj" />
<Project Path="src/Microsoft.Agents.AI.TypeSafe/Microsoft.Agents.AI.TypeSafe.csproj" />
<Project Path="src/Microsoft.Agents.AI.Valkey/Microsoft.Agents.AI.Valkey.csproj" />
<Project Path="src/Microsoft.Agents.AI.Workflows.Declarative.Foundry/Microsoft.Agents.AI.Workflows.Declarative.Foundry.csproj" />
<Project Path="src/Microsoft.Agents.AI.Workflows.Declarative.Mcp/Microsoft.Agents.AI.Workflows.Declarative.Mcp.csproj" />
Expand Down Expand Up @@ -697,6 +702,7 @@
<Project Path="tests/Microsoft.Agents.AI.OpenAI.UnitTests/Microsoft.Agents.AI.OpenAI.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Purview.UnitTests/Microsoft.Agents.AI.Purview.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Tools.Shell.UnitTests/Microsoft.Agents.AI.Tools.Shell.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.TypeSafe.UnitTests/Microsoft.Agents.AI.TypeSafe.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.UnitTests/Microsoft.Agents.AI.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Valkey.UnitTests/Microsoft.Agents.AI.Valkey.UnitTests.csproj" />
<Project Path="tests/Microsoft.Agents.AI.Workflows.Declarative.Mcp.UnitTests/Microsoft.Agents.AI.Workflows.Declarative.Mcp.UnitTests.csproj" />
Expand Down
2 changes: 2 additions & 0 deletions dotnet/agent-framework-src-and-tests.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"src\\Microsoft.Agents.AI.OpenAI\\Microsoft.Agents.AI.OpenAI.csproj",
"src\\Microsoft.Agents.AI.Purview\\Microsoft.Agents.AI.Purview.csproj",
"src\\Microsoft.Agents.AI.Tools.Shell\\Microsoft.Agents.AI.Tools.Shell.csproj",
"src\\Microsoft.Agents.AI.TypeSafe\\Microsoft.Agents.AI.TypeSafe.csproj",
"src\\Microsoft.Agents.AI.Valkey\\Microsoft.Agents.AI.Valkey.csproj",
"src\\Microsoft.Agents.AI.Workflows.Declarative.Foundry\\Microsoft.Agents.AI.Workflows.Declarative.Foundry.csproj",
"src\\Microsoft.Agents.AI.Workflows.Declarative.Mcp\\Microsoft.Agents.AI.Workflows.Declarative.Mcp.csproj",
Expand Down Expand Up @@ -65,6 +66,7 @@
"tests\\Microsoft.Agents.AI.OpenAI.UnitTests\\Microsoft.Agents.AI.OpenAI.UnitTests.csproj",
"tests\\Microsoft.Agents.AI.Purview.UnitTests\\Microsoft.Agents.AI.Purview.UnitTests.csproj",
"tests\\Microsoft.Agents.AI.Tools.Shell.UnitTests\\Microsoft.Agents.AI.Tools.Shell.UnitTests.csproj",
"tests\\Microsoft.Agents.AI.TypeSafe.UnitTests\\Microsoft.Agents.AI.TypeSafe.UnitTests.csproj",
"tests\\Microsoft.Agents.AI.UnitTests\\Microsoft.Agents.AI.UnitTests.csproj",
"tests\\Microsoft.Agents.AI.Valkey.UnitTests\\Microsoft.Agents.AI.Valkey.UnitTests.csproj",
"tests\\Microsoft.Agents.AI.Workflows.Declarative.Mcp.UnitTests\\Microsoft.Agents.AI.Workflows.Declarative.Mcp.UnitTests.csproj",
Expand Down
72 changes: 72 additions & 0 deletions dotnet/eng/verify-samples/AgentsSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,55 @@ internal static class AgentsSamples
],
},

new SampleDefinition
{
Name = "Agent_TypeSafe_Step01_LoopJudge",
ProjectPath = "samples/02-agents/AgentProviders/typesafe/Agent_TypeSafe_Step01_LoopJudge",
RequiredEnvironmentVariables = ["FOUNDRY_PROJECT_ENDPOINT", "TYPESAFE_API_KEY"],
OptionalEnvironmentVariables = ["FOUNDRY_MODEL"],
MustContain = ["Answer 1:", "Judge:", "red_sunsets:", "Final answer:"],
ExpectedOutputDescription =
[
"The first answer should explain only why the sky is blue, and the judge should mark red_sunsets as missing with a low probability.",
"A later answer should also explain why sunsets are red, and the judge should mark red_sunsets as met for it.",
"Every numbered answer (Answer 1, Answer 2, and so on) should be followed by a Judge block with probabilities. The Final answer section repeats the last judged answer and has no Judge block of its own.",
"The final answer should explain both why the sky is blue and why sunsets are red.",
"The output should not contain error messages or stack traces.",
],
},

new SampleDefinition
{
Name = "Agent_TypeSafe_Step02_DecisionTool",
ProjectPath = "samples/02-agents/AgentProviders/typesafe/Agent_TypeSafe_Step02_DecisionTool",
RequiredEnvironmentVariables = ["FOUNDRY_PROJECT_ENDPOINT", "TYPESAFE_API_KEY"],
OptionalEnvironmentVariables = ["FOUNDRY_MODEL"],
MustContain = ["Ticket:", "Tool result:", "department", "The same tool, answered by a local keyword decision client:"],
ExpectedOutputDescription =
[
"Each ticket should show a tool result with department, urgentProbability, and frustration values, followed by a one-line agent reply.",
"The failing Stripe integration ticket should be routed to Technical with a high urgent probability, and the invoice request should be routed to Billing with a low urgent probability.",
"The last part should show a tool result from the local keyword decision client for the invoice ticket, routed to Billing, followed by an agent reply.",
"The output should not contain error messages or stack traces.",
],
},

new SampleDefinition
{
Name = "Agent_TypeSafe_Step03_DecisionRouting",
ProjectPath = "samples/02-agents/AgentProviders/typesafe/Agent_TypeSafe_Step03_DecisionRouting",
RequiredEnvironmentVariables = ["FOUNDRY_PROJECT_ENDPOINT", "TYPESAFE_API_KEY"],
OptionalEnvironmentVariables = ["FOUNDRY_MODEL", "FOUNDRY_REASONING_MODEL"],
MustContain = ["User:", "Route: Fast", "Route: Reasoning", "Agent:"],
ExpectedOutputDescription =
[
"The question about the capital of France should be routed to Fast and answered with Paris.",
"The demand forecasting request should be routed to Reasoning and answered with a comparison of three methods and a recommendation.",
"Each route line should show the probabilities of both routes and the model that answered.",
"The output should not contain error messages or stack traces.",
],
},

// ── Agents ──────────────────────────────────────────────────────────

new SampleDefinition
Expand Down Expand Up @@ -416,6 +465,29 @@ internal static class AgentsSamples
],
},

new SampleDefinition
{
Name = "Agent_Step25_ClassificationWithJev",
ProjectPath = "samples/02-agents/Agents/Agent_Step25_ClassificationWithJev",
RequiredEnvironmentVariables = ["FOUNDRY_PROJECT_ENDPOINT", "TYPESAFE_API_KEY"],
OptionalEnvironmentVariables = ["FOUNDRY_MODEL"],
MustContain =
[
"Ticket:",
"Tool result:",
"The same tool, answered by a local keyword classifier:",
"local-keyword-classifier",
],
ExpectedOutputDescription =
[
"Each of the three tickets should show a tool result with department, urgent, and frustration answers from a jev model, followed by a one-line agent reply.",
"The failing Stripe integration ticket should be routed to technical and marked urgent, and the invoice request should be routed to billing and not urgent.",
"The vague account ticket may be sent to human review when the department confidence is low.",
"The last part should show a tool result from the local-keyword-classifier model for the invoice ticket, followed by an agent reply.",
"The output should not contain error messages or stack traces.",
],
},

// ── AgentSkills ─────────────────────────────────────────────────────

new SampleDefinition
Expand Down
8 changes: 8 additions & 0 deletions dotnet/samples/02-agents/AgentProviders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ covering basics, function tools, structured output, middleware, MCP, code interp
| [Conversation](./openai/Agent_OpenAI_Step05_Conversation/) | Multi-turn conversations with OpenAI |
| [Code Interpreter](./openai/Agent_OpenAI_Step06_CodeInterpreterFileDownload/) | Code interpreter with file downloads |

### [TypeSafe](./typesafe/)

| Sample | Description |
| --- | --- |
| [Loop judge](./typesafe/Agent_TypeSafe_Step01_LoopJudge/) | Use Jev as the judge of a LoopAgent, through an IDecisionClient and a typed decision definition |
| [Decision tool](./typesafe/Agent_TypeSafe_Step02_DecisionTool/) | Give an agent a decision as a tool with `DecisionDefinition.AsAIFunction`, and answer it with Jev or a local decision client |
| [Decision routing](./typesafe/Agent_TypeSafe_Step03_DecisionRouting/) | Route each request of an agent to a fast or a reasoning model, with Jev choosing the route through `RoutingChatClient` |

## Running the samples

Navigate to a sample directory and run:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net10.0</TargetFrameworks>

<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.Foundry\Microsoft.Agents.AI.Foundry.csproj" />
<ProjectReference Include="..\..\..\..\..\src\Microsoft.Agents.AI.TypeSafe\Microsoft.Agents.AI.TypeSafe.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// Copyright (c) Microsoft. All rights reserved.

// This sample uses Jev, the TypeSafe System One model, as the judge of a LoopAgent. A Foundry agent writes the
// answer. After each answer, Jev checks every criterion with its own yes or no question, and the loop sends the agent
// the criteria that are still missing, until the answer meets all of them. The judge uses the decision API proposed
// for Microsoft.Extensions.AI: an IDecisionClient and a typed DecisionDefinition.

#pragma warning disable MAAI001 // LoopAgent and DelegateLoopEvaluator are experimental.
#pragma warning disable MEAI001 // The decision API is experimental.

using System.ClientModel;
using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.TypeSafe;
using Microsoft.Extensions.AI;

var endpoint = Environment.GetEnvironmentVariable("FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("FOUNDRY_PROJECT_ENDPOINT is not set.");
var deploymentName = Environment.GetEnvironmentVariable("FOUNDRY_MODEL") ?? "gpt-5.4-mini";
var typeSafeApiKey = Environment.GetEnvironmentVariable("TYPESAFE_API_KEY") ?? throw new InvalidOperationException("TYPESAFE_API_KEY is not set.");

// 1. The criteria, as a typed verdict. Each property is a Binary question, whose answer is the probability that the
// answer meets the criterion, so the judge reports exactly which criteria are missing instead of a single verdict. The
// questions describe what a good answer contains; wording that steers the judge, such as "only say yes if", tends to
// push every answer one way.
DecisionDefinition<Verdict> criteria = DecisionDefinition<Verdict>.Create(builder =>
{
builder.BinaryProbability(verdict => verdict.BlueSky, "Does `answer` explain why the daytime sky appears blue?");
builder.BinaryProbability(verdict => verdict.RedSunsets, "Does `answer` explain why sunsets appear red or orange?");
builder.BinaryProbability(verdict => verdict.PlainLanguage, "Does `answer` use clear language suitable for a general audience?");
});

// A criterion is met when its probability is above this threshold. 0.5 is not calibrated for any task: a higher value
// accepts fewer answers that still miss a criterion, at the cost of more loop runs. Choose it on labeled examples of
// your own answers.
const double CriterionThreshold = 0.5;

// 2. The agent that writes the answers. Its instructions hold back part of the first answer, so the judge has a gap
// to find and the loop runs more than once.
// 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.
AIAgent answerer = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential()).AsAIAgent(
model: deploymentName,
name: "Answerer",
instructions: """
You answer science questions for a general audience in one short paragraph.
Your first answer is a single sentence about why the daytime sky is blue. It does not mention sunsets, even
if the user asks about them.
When feedback lists missing points, rewrite the whole answer so that it covers them too.
""");

// 3. The judge. AIJudgeLoopEvaluator asks a chat client for JSON structured output, which a decision model does not
// write, so a DelegateLoopEvaluator asks the decision client the criteria questions instead. The state is the request
// and the latest answer.
using IDecisionClient judge = new JevDecisionClient(new ApiKeyCredential(typeSafeApiKey));
bool accepted = false;
var evaluator = new DelegateLoopEvaluator(async (context, cancellationToken) =>
{
Console.WriteLine($"\nAnswer {context.Iteration}:\n{context.LastResponse.Text}");
string request = string.Join("\n", context.InitialMessages.Select(message => message.Text));
List<string> missing = await JudgeAsync(request, context.LastResponse.Text, cancellationToken);
accepted = missing.Count == 0;

// The feedback names the missing criteria, which is the gap analysis that a generative judge would write.
return accepted
? LoopEvaluation.Stop()
: LoopEvaluation.Continue($"Your answer does not yet: {string.Join("; ", missing)}. Rewrite the whole answer so that it does.");
});

// 4. The loop re-runs the agent until the judge stops it. MaxIterations bounds the cost if the answer never passes.
const int MaxIterations = 3;
const string Request = "Explain why the sky is blue and why sunsets are red.";
AIAgent loop = new LoopAgent(answerer, evaluator, new LoopAgentOptions { MaxIterations = MaxIterations, NonStreamingReturnsLastResponseOnly = true });
AgentResponse response = await loop.RunAsync(Request);

// LoopAgent stops at MaxIterations before it calls the evaluator, so an answer from the last allowed run has not been
// judged yet. Judging it here keeps the final answer from being presented as accepted when it may miss a criterion.
if (!accepted)
{
Console.WriteLine($"\nAnswer {MaxIterations} (the last run the loop allows):\n{response.Text}");
accepted = (await JudgeAsync(Request, response.Text, CancellationToken.None)).Count == 0;
}

Console.WriteLine(accepted ? "\nFinal answer:" : "\nFinal answer (some criteria are still missing):");
Console.WriteLine(response.Text);

// Asks the judge whether the answer meets each criterion, prints the probabilities, and returns the missing criteria.
async Task<List<string>> JudgeAsync(string request, string answer, CancellationToken cancellationToken)
{
DecisionResponse<Verdict> decision = await judge.GetResponseAsync(new JudgedAnswer(request, answer), criteria, cancellationToken: cancellationToken);
Verdict verdict = decision.Result;

Console.WriteLine("Judge:");
List<string> missing = [];
foreach ((string name, string description, double probability) in new[]
{
("blue_sky", "explain why the daytime sky appears blue", verdict.BlueSky),
("red_sunsets", "explain why sunsets appear red or orange", verdict.RedSunsets),
("plain_language", "use clear language suitable for a general audience", verdict.PlainLanguage),
})
{
bool met = probability > CriterionThreshold;
Console.WriteLine($" {name}: {(met ? "met" : "missing")} (probability {probability:F2})");
if (!met)
{
missing.Add(description);
}
}

return missing;
}

/// <summary>The state the judge reads: the user's request and the answer to judge.</summary>
internal sealed record JudgedAnswer(string Request, string Answer);

/// <summary>The probability that the answer meets each criterion.</summary>
#pragma warning disable CA1812 // Instantiated by the decision definition, which creates the result from the answers.
internal sealed record Verdict(double BlueSky, double RedSunsets, double PlainLanguage);
#pragma warning restore CA1812
Loading
Loading