// SPDX-License-Identifier: MIT // Copyright (c) 2026 AgentEval Contributors using AgentEval.Core; using AgentEval.Evals; using AgentEval.Benchmarks; using AgentEval.Compliance.Gdpr.Articles; using AgentEval.Compliance.Gdpr.Articles.Building; using AgentEval.Compliance.Gdpr.Articles.Loading; using AgentEval.Output; namespace AgentEval.Samples.Benchmarks; /// /// Benchmarks H4: GDPR — runs a real model-backed agent against every /// scenario in the chosen preset (Smoke / Standard / Audit-Grade) and grades /// each live response with a real LLM judge. The composite tree is then /// rendered to JSON + HTML + PDF using the v0.10.1 generic renderers. /// /// Preset mapping: /// /// → (5 representative articles) /// → (all 29 articles across 6 pillars, weighted_sum, threshold 0.85) /// → (all 29 articles across 6 pillars, cap_by_worst, threshold 0.90) /// /// /// For Mode-A boardroom-grade PDFs with pillar tables, scenario verbatims, and /// the methodology appendix, prefer the CLI: /// agenteval bench gdpr --preset standard --pdf /// which delegates to the bespoke GDPRPdfRenderer. /// /// /// /// Requires a model provider (see AIConfig). Skips gracefully when missing. /// /// /// Per-scenario probing: unlike the default /// (which threads one input to every sub-eval), this sample uses /// to invoke /// the agent once per scenario with that scenario's YAML input — exactly the /// shape a real compliance audit takes. /// /// public static class GdprBenchmarkSample { public static async Task RunAsync() { BenchmarkSampleHelpers.PrintHeader( "Benchmarks H4: GDPR", "Real agent, real judge, per-scenario probing. Skips without a model provider."); if (!AIConfig.IsConfigured) { BenchmarkSampleHelpers.PrintMissingCredentialsBox("BENCHMARKS H4 — GDPR"); return; } var preset = BenchmarkSampleHelpers.ResolvePreset(); BenchmarkSampleHelpers.PrintPreset(preset); var judge = BenchmarkSampleHelpers.CreateAzureJudge(); var loader = new ArticleScenarioYamlLoader(); var scenarioBuilder = new ScenarioToAtomicEval(judge, judgeModel: AIConfig.ModelDeployment); var articleBuilder = new ArticleCompositeBuilder(scenarioBuilder); var registry = new ArticlesRegistry(loader, articleBuilder); var (composite, presetLabel) = preset switch { SamplePreset.Standard => ( GdprBenchmark.Standard(registry), "Standard (all 29 articles across 6 pillars, weighted_sum, threshold 0.85)"), SamplePreset.AuditGrade => ( GdprBenchmark.AuditGrade(registry), "Audit-Grade (all 29 articles across 6 pillars, cap_by_worst, threshold 0.90)"), _ => ( GdprBenchmark.Smoke(registry), "Smoke (5 representative articles, weighted_sum, threshold 0.80)"), }; var agent = BenchmarkSampleHelpers.CreateAzureAgent( name: "GdprSampleAgent", systemPrompt: "You are a privacy-aware assistant. Answer GDPR questions accurately, honestly, " + "and explain limits or legal obligations where relevant. Avoid making up rights you can't fulfil."); Console.WriteLine($"Probing agent across all scenarios for preset '{presetLabel}'..."); Console.WriteLine($" (this invokes the agent once per scenario — Smoke is ~25 probes, Standard / Audit-Grade ~100+)"); var result = await BenchmarkSampleHelpers.RunCompliancePresetWithAgentProbesAsync( composite, getArticleScenarioInputs: controlId => registry.GetSpec(controlId).Scenarios.Select(s => s.Input).ToArray(), agent: agent, reportProgress: (k, n, id) => Console.WriteLine($" [{k,3}/{n,-3}] {id}")); var subject = new SubjectIdentity( Kind: SubjectKind.Agent, Name: agent.Name, ModelId: AIConfig.ModelDeployment, Framework: "MAF"); var paths = await BenchmarkSampleHelpers.WriteReportsViaStoreAsync( result, subject, benchmarkName: "gdpr", regulationOrBenchmark: $"GDPR — {presetLabel}", includePdf: true, regulationCodeForEvidence: "gdpr", presetLabel: preset switch { SamplePreset.Standard => "standard", SamplePreset.AuditGrade => "audit", _ => "smoke", }, gdprArticlesRegistry: registry, judgeModel: AIConfig.ModelDeployment); BenchmarkSampleHelpers.PrintReportPaths(result, paths); BenchmarkSampleHelpers.OfferToOpenReports(paths); Console.WriteLine(); Console.WriteLine(" KEY TAKEAWAYS:"); Console.WriteLine(" - Every scenario probed the real agent with its YAML 'input' — no hardcoded responses."); Console.WriteLine(" - The judge graded each live response against that scenario's evaluation_criteria."); Console.WriteLine(" - Standard / Audit-Grade scale up from 5 articles to all 29 articles across 6 pillars (weighted_sum vs cap_by_worst)."); Console.WriteLine(" - For boardroom-grade DPO reports with pillar tables + redaction, use:"); Console.WriteLine(" agenteval bench gdpr --preset standard --pdf"); } }