e-naxosMAF COURSE / COURS
Français

MICROSOFT AGENT FRAMEWORK · 0.16.0-rc.1

Demo280 — Validated Planning

JSON extraction, host schema and at most one retry precede deserialization. After two failures, the loop continues without simulated execution of that plan. No creation effect, even for a valid plan.

Objectives

Prepare the program

Live chat through common configuration, granite4:3b by default; no embeddings required. An optional API is selected explicitly with no automatic fallback. Start at the root of the complete distribution. Preserve shared projects and configuration files. Some historical prompts and labels in Demo260–290 remain French in public code; commands and identifiers match this revision.

dotnet build BaseTechnique.slnx -m:1 -c Release
Required projects
ProjectRole
demos/Demo280_ValidatedPlanning/Demo280.App.csprojApp
shared/Maf.DemoConnection/Maf.DemoConnection.csprojShared implementation

Commands from the root

dotnet run --project demos/Demo280_ValidatedPlanning/Demo280.App.csproj -c Release --no-build

Procedures and variants

Compare Demo270’s two requests, then follow the chapter’s invalid-plan injection in a separate copy.

    // 3) Validation JSON Schema (+ retry unique si invalide)
    if (!ValidatePlanJson(jsonText, out var err))
    {
        Console.WriteLine("⚠️ Plan JSON invalide. Retry unique...");
        Console.WriteLine(err);

        var repairPrompt = $"""
Tu as renvoyé un JSON invalide ou non conforme.
Corrige-le et renvoie UNIQUEMENT un JSON valide, sans texte autour, conforme à ce schéma :

{PlanJsonSchema}

Demande utilisateur :
{input}
""";

        var rawResp2 = await planner.RunAsync(message: repairPrompt, session: session);
        var rawText2 = GetResponseText(rawResp2);
        jsonText = ExtractJsonObject(rawText2);

        if (!ValidatePlanJson(jsonText, out err))
        {
            Console.WriteLine("⛔ JSON toujours invalide après retry. Arrêt.");
            Console.WriteLine(err);
            Console.WriteLine();
            continue;
        }
    }

    // 4) Désérialisation une fois validé

demos/Demo280_ValidatedPlanning/Program.cs · L92–L121 · 9a895c94534c

Source code · Demo280 · Folder

What must be observable

JSON extraction, host schema and at most one retry precede deserialization. After two failures, the loop continues without simulated execution of that plan. No creation effect, even for a valid plan.

These results are expected from the linked code. Checks actually rerun for this lot are distinguished in exercises and reception; no unmeasured live output is presented as observed.

Limits and retained state

Demo230–250 build a fresh graph per input and write no business effect. Demo260 retains its two sessions only in-process. Demo270–290 interpret a plan through simulated printing without a workflow engine. Live calls depend on the profile; scripted tests qualify no model.

Contracts and prerequisites

Prerequisites

Continue reading

Complete demo folder · README

lot009-workflows-1 · 2026-10-24 · 9a895c94534cd5fc6f3da883e37e5f7856e588c1