<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cédric Mendelin on Medium]]></title>
        <description><![CDATA[Stories by Cédric Mendelin on Medium]]></description>
        <link>https://medium.com/@cedric.mendelin?source=rss-5cda01cbd49e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gtIoa9dj7LrCltJ4i_3X0w.png</url>
            <title>Stories by Cédric Mendelin on Medium</title>
            <link>https://medium.com/@cedric.mendelin?source=rss-5cda01cbd49e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 20:33:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cedric.mendelin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond LLMs: Building with Decision Models in .NET]]></title>
            <link>https://medium.com/data-science-collective/beyond-llms-building-with-decision-models-in-net-44763ab8276c?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/44763ab8276c</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[decision-model]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 21:19:04 GMT</pubDate>
            <atom:updated>2026-11-12T21:19:04.454Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Bounded judgments, explicit policy, and generation only where it helps.</blockquote><p>Many AI features I have built over the last two years don’t actually need text. They need a decision. Is this ticket for billing or engineering? Is this answer good enough to show the user? Did the LLM extract the right data?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-vD7UrKMyuhPG0YOEtEIg.jpeg" /><figcaption>Unsplash</figcaption></figure><p>Yet we often give all of these jobs to the same generative model: read the input, reason about it, and produce JSON that our application parses back into a label or a number. The application never needed the prose in the first place.</p><p>Amazon’s <a href="https://strandsagents.com/blog/amazon-saves-millions-replacing-sonnet-with-strands-decider/">ticket-classification story</a> makes the distinction concrete: the team replaced a Sonnet labeling path with a smaller decision model for choosing among 20 categories. They report lower latency and estimated costs on their workload, and describe shadowing the new model before switching over. Those are workload-specific results, not a promise for every application.</p><p>This is the gap that <strong>decision models</strong> fill. Based on a certain state, they can decide on a bounded questions and return probabilities (distribution). And the best thing — faster and cheaper then an LLM. We’ll unpack it first, then implement it in .NET.</p><h3>Table of Contents</h3><p>· <a href="#e2e3">Decision Models in a Nutshell</a><br>· <a href="#4b62">System One: Thinking, Fast and Slow for Software</a><br>· <a href="#bba7">Three Modes, Three Classification Problems</a><br>· <a href="#23c9">Noul / Predicate: Binary Classification</a><br>· <a href="#bc5a">Choice: Multi-Class Classification</a><br>· <a href="#d54a">Score: Ordinal Classification</a><br>· <a href="#8621">When to Use Decision Models (and When Not)</a><br>· <a href="#6475">Step-by-Step Implementation</a><br>· <a href="#2d9a">Step 1: Deploy Microsoft-Decision-1</a><br>· <a href="#aef0">Step 2: Assess, Choose and Score with ElBruno.AI.Decisions</a><br>· <a href="#0c2d">Final Thoughts</a><br>· <a href="#bc7d">References</a></p><h3>Decision Models in a Nutshell</h3><p>An LLM takes context and generates content. A decision model takes a <strong>state</strong> and a <strong>bounded question</strong>, and returns a typed answer. There a three types of questions:</p><ul><li>noul returns a probability</li><li>choice returns a selected value from the supplied options and associated probabilities</li><li>score returns a value on an ordered scale.</li></ul><blockquote><strong><em>Generative models create. Decision models judge. Code acts.</em></strong></blockquote><h3>System One: Thinking, Fast and Slow for Software</h3><p>TypeSafe AI calls its Jev model the first “System One model”. The name borrows from Daniel Kahneman’s <em>Thinking, Fast and Slow</em> (one of my favorite books I read in the last years): <strong>System 1</strong> is fast, automatic and intuitive; <strong>System 2</strong> is slow, deliberate and effortful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKy3uEi-e1XhjWmiqWm5lA.png" /><figcaption>LLMs generate and reason; decision models return bounded judgments for application code to act on.</figcaption></figure><p>The analogy works surprisingly well for AI architecture:</p><ul><li><strong>System 2 = LLMs and reasoning models.</strong> They can plan, write, and reason step by step. Powerful, but often slower and more expensive for bounded classification tasks.</li><li><strong>System 1 = decision models.</strong> A focused decision call with a bounded answer space, rather than generated prose.</li></ul><h3>Three Modes, Three Classification Problems</h3><p>If you have a machine learning background, the three modes will look familiar. They map to classic classification problems and can be used out-of-the-box with a generic model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7PEvL-_LsivZ1TPy1_0Uag.png" /></figure><h3>Noul / Predicate: Binary Classification</h3><p><em>“Does this request concern a billing problem?”</em> → 0.07</p><p>Microsoft-Decision-1 and Jev call it <strong>noul</strong>, the OpenAI Decisions API calls it <strong>predicate</strong>.</p><p>The result is the model’s estimated probability that the proposition is true. It is <strong>not</strong> a generic confidence score or a guarantee of calibration for your task.</p><h3>Choice: Multi-Class Classification</h3><p><em>“Which team should handle this ticket?”</em> with billing, support and engineering. A choice question selects one supplied label and returns probabilities for the options.</p><pre>{ &quot;billing&quot;: 0.03, &quot;support&quot;: 0.09, &quot;engineering&quot;: 0.88 }</pre><h3>Score: Ordinal Classification</h3><p><em>“How completely does this answer satisfy the requirement?”</em> with the levels Not fulfilled, Partially, Mostly, Fully (0–3).</p><p>Now the classes are <strong>ordered</strong>. <a href="https://learn.microsoft.com/en-us/azure/foundry/foundry-models/how-to/use-foundry-models-microsoft-decision">Microsoft-Decision-1</a> and the <a href="https://developers.openai.com/api/docs/guides/decisions">OpenAI Decisions API</a> document score as the probability-weighted average of the level indices, so the result can fall between levels (for example, 2.63).</p><h3>When to Use Decision Models (and When Not)</h3><p>This is the part I care about most. A new model category is no reason to rebuild everything.</p><p><strong>Good fits:</strong></p><ul><li><strong>Routing and triage:</strong> tickets, emails, alerts or documents into a known set of queues.</li><li><strong>Gates in agent loops:</strong> “Does this tool call touch production data?”, “Should the agent continue, retry or hand off?”</li><li><strong>LLM judges and verification:</strong> checking extracted data, grading answers against a rubric, RAG relevance before an expensive generation step.</li><li><strong>Model, tool and agent selection:</strong> “Which model should handle this?” is simply a choice question.</li><li><strong>Labelling at scale:</strong> sorting thousands of feedback items into themes a human defined.</li></ul><p><strong>Bad fits:</strong></p><ul><li><strong>Open answer spaces.</strong> Extracting, summarising, rewriting or explaining is LLM work.</li><li><strong>When you need a rationale.</strong> Decision models return numbers, not reasons. If an auditor wants to know <em>why</em>, you need an LLM or a human in the loop.</li><li><strong>Multi-step or dependent reasoning.</strong> When question B depends on the answer to question A, you need separate calls or a reasoning model.</li><li><strong>Things code can do.</strong> Arithmetic, counting, date comparison, schema validation and known business rules belong in C#. TypeSafe even lists maths and dates among Jev’s weak spots.</li><li><strong>The sole decision-maker about people.</strong> Do not use a model score as the sole basis for consequential decisions about people. Meaningful human oversight, applicable law, and your organization’s responsible-AI policies still matter; human review alone does not make an otherwise inappropriate use acceptable. See <a href="https://www.microsoft.com/ai/responsible-ai">Microsoft’s Responsible AI principles</a>.</li><li><strong>A security boundary.</strong> A noul “Is this a prompt injection?” is a useful signal, not a guarantee.</li></ul><p>My rule of thumb comes down to three questions:</p><ol><li><strong>Can code decide it deterministically?</strong> → Use code.</li><li><strong>Can I list the valid answers upfront, and would a probability or bounded score help?</strong> → Consider a decision model, then validate it for the task.</li><li><strong>Otherwise</strong> → Use an LLM.</li></ol><h3>Step-by-Step Implementation</h3><p>We’ll use <a href="https://github.com/elbruno/ElBruno.AI.Decisions">ElBruno.AI.Decisions</a>, a community SDK from a Microsoft employee — they are currently working on bringing this to MEAI (Microsoft.Extensions.AI).</p><p>Create a .NET 10 console project and pin the package version used by this sample:</p><pre>dotnet new console -f net10.0 -n DecisionSample<br>cd DecisionSample<br>dotnet add package ElBruno.AI.Decisions.Foundry --version 0.7.0<br>dotnet add package Azure.Identity</pre><h3>Step 1: Deploy Microsoft-Decision-1</h3><p>For our demo, I deployed the Decision-1 as well as gpt-6-luna into my Foundry project.</p><h3>Step 2: Assess, Choose and Score with ElBruno.AI.Decisions</h3><p>First we need to initialize a client — then we can us this for the three type of qestions. The three operations map to the Microsoft-Decision-1 modes: AssessAsync (noul), ChooseAsync (choice), and ScoreAsync (score).</p><pre>using ElBruno.AI.Decisions.Foundry;</pre><pre>using var client = new FoundryDecisionClient(new FoundryDecisionOptions<br>{<br>    // Resource root; 0.7.0 appends the Microsoft System One route.<br>    Endpoint = new Uri(&quot;https://&lt;resource&gt;.services.ai.azure.com&quot;),<br>    Model = &quot;&lt;deployment-name&gt;&quot;<br>});</pre><pre>const string ticket = &quot;The API returns 500 on every call.&quot;;</pre><pre>var billing = await client.AssessAsync(ticket, &quot;This request concerns a billing problem.&quot;);</pre><pre>var route = await client.ChooseAsync(ticket, &quot;Which team should handle this ticket?&quot;,<br>    new Dictionary&lt;string, string?&gt;<br>    {<br>        [&quot;billing&quot;] = &quot;Charges, invoices and refunds&quot;,<br>        [&quot;engineering&quot;] = &quot;Bugs, errors and outages&quot;,<br>        [&quot;support&quot;] = &quot;How-to and account questions&quot;<br>    });</pre><pre>var severity = await client.ScoreAsync(ticket, &quot;How severe is this incident?&quot;,<br>    new[] { &quot;Cosmetic&quot;, &quot;Minor&quot;, &quot;Major&quot;, &quot;Critical&quot; });</pre><pre>Console.WriteLine($&quot;Billing: {billing.Probability:P1} | Team: {route.Choice} | Severity: {severity.Score:F2}&quot;);</pre><p>The same domain-level methods do <strong>not</strong> make provider APIs interchangeable. For Azure OpenAI Decisions with gpt-6-luna, select its adapter explicitly and use the Azure OpenAI resource endpoint and deployment name:</p><pre>var openAiDecisions = new FoundryDecisionClient(new FoundryDecisionOptions<br>{<br>    Api = FoundryDecisionApi.OpenAIDecisions,<br>    Endpoint = new Uri(&quot;https://&lt;resource&gt;.openai.azure.com&quot;),<br>    Model = &quot;&lt;gpt-6-luna-deployment&gt;&quot;<br>});</pre><p>This adapter uses /openai/v1/decisions, not the Microsoft System One route. The convenience methods shown above send one text question per request; use the SDK&#39;s DecideAsync API for its richer multi-question or image-input capabilities.</p><h3>Final Thoughts</h3><p>For the last few years, AI architecture has focused around one primitive: generation. Decision models add another: bounded judgments. Kahneman might recognise the analogy: use a focused decision call for routine questions, a generative model or a person for open-ended or uncertain cases, and explicit rules for escalation.</p><p>Maybe our applications should simply chat less and decide more.</p><p>Explore the code in <a href="https://github.com/cedricmendelin/Agentic-Design-Patterns-MAF/tree/main/dotnet/src/DecisionModels">Agentic-Design-Patterns-MAF: Decision Models</a>.</p><h3>References</h3><ul><li><a href="https://docs.typesafe.ai/concepts/system-one">TypeSafe docs: System One</a></li><li><a href="https://github.com/cedricmendelin/Agentic-Design-Patterns-MAF/tree/main/dotnet/src/DecisionModels">Agentic-Design-Patterns-MAF: Decision Models examples</a></li><li><a href="https://learn.microsoft.com/en-us/azure/foundry/foundry-models/how-to/use-foundry-models-microsoft-decision">Microsoft Learn: Deploy and use Microsoft-Decision-1 in Microsoft Foundry</a></li><li><a href="https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/introducing-microsoft-decision-1-in-microsoft-foundry-for-decision-and-classific/4562742">Microsoft Foundry Blog: Introducing Microsoft-Decision-1 in Microsoft Foundry</a></li><li><a href="https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/decisions">Microsoft Learn: Use the Azure OpenAI Decisions API</a></li><li><a href="https://www.microsoft.com/ai/responsible-ai">Microsoft: Responsible AI principles</a></li><li><a href="https://github.com/elbruno/ElBruno.AI.Decisions">GitHub: elbruno/ElBruno.AI.Decisions</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44763ab8276c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/beyond-llms-building-with-decision-models-in-net-44763ab8276c">Beyond LLMs: Building with Decision Models in .NET</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microsoft Foundry: From Agents to Automation with Routines]]></title>
            <link>https://medium.com/data-science-collective/microsoft-foundry-from-agents-to-automation-with-routines-341536b92646?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/341536b92646</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[microsoft-foundry]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 11:00:25 GMT</pubDate>
            <atom:updated>2026-10-16T11:00:25.703Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Your agent shouldn’t wait for someone to type. Let’s run it on a schedule, at a fixed time, or when an assigned GitHub issue lands.</em></p><p>Most agents I see in projects have one thing in common: they sit in a chat window and wait. Somebody has to open the app, type a question, and only then does the agent start working. But a lot of real work doesn’t start with a question. It starts with a time (“every Monday morning”) or an event (“a new github issue was opened”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G51WroN5k8LuhXuPlPa6Eg.png" /><figcaption><em>Image generated with AI</em></figcaption></figure><p>Until now, making an agent run on its own meant building everything around it yourself: a scheduler, a webhook receiver, a queue, credentials, retry logic and a table for run history. Sounds like a lot of plumbing for “run my agent every morning”, right? Well… it was.</p><p>With <strong>Routines in Foundry Agent Service</strong>, generally available since September 24, 2026, Microsoft moves that plumbing into the Foundry project. In this article, we’ll configure a weekly routine and a GitHub issue routine in C#, with portal alternatives for manual setup and testing. We’ll also make the identity decision deliberately: whose permissions should an unattended agent use?</p><p>And yes, a bit of a personal angle: my own weekly blog idea research is now an automated agent too. This is the enterprise version of it.</p><h3>Table of Contents</h3><p>· <a href="#e964">Routines in a Nutshell</a><br>· <a href="#0500">Why Routines and Not Azure Functions?</a><br>· <a href="#4c64">Step-by-Step Implementation</a><br>· <a href="#74f6">Step 1: Install the Packages</a><br>· <a href="#c511">Step 2: Create a Weekly Routine</a><br>· <a href="#18db">Step 3: Test It Without Waiting a Week</a><br>· <a href="#3df3">Step 4: Triage New GitHub Issues</a><br>· <a href="#7cb5">Agent Identity or Creator Identity?</a><br>· <a href="#012a">Limits Worth Knowing</a><br>· <a href="#111c">Recap</a><br>· <a href="#3189">References</a></p><h3>Routines in a Nutshell</h3><p>A routine is a named automation rule in your Foundry project. Here are the key concepts:</p><ul><li><strong>Trigger:</strong> When the routine fires. Exactly one per routine: a recurring <strong>schedule</strong> (cron, minimum five minutes), a one-time <strong>timer</strong>, a <strong>github </strong>event (issue opened or closed), or a custom <strong>Teams </strong>trigger for new channel messages.</li><li><strong>Action:</strong> Which agent to invoke</li><li><strong>Input:</strong> The text or JSON the agent receives. Event triggers deliver the event payload; keep the intended behavior in the agent’s instructions.</li></ul><p><strong>How a Foundry routine runs:</strong> a trigger starts a project-scoped routine, which invokes the agent using agent identity by default or creator identity when explicitly selected. The agent uses its configured tools, and Foundry records the delivery outcome in run history. <strong>Event triggers authenticate through a connector connection, separately from the dispatch identity.</strong></p><h3>Why Routines and Not Azure Functions?</h3><p>To be honest, my first reaction was: “I can do that with a timer-triggered Azure Function in ten minutes.” And you can. But then you also need to handle authentication to the agent, the GitHub event integration, secrets, retries, and somewhere to look when a run failed at 3 AM.</p><p>The biggest advantage, in my opinion, is that routines don’t introduce a new runtime for agent logic. A routine uses the <strong>same invocation path</strong> as your app or the playground. The agent keeps its configured tools and tracing, and the routine inherits the project’s network setup, including private networking. You still need to check the permissions of the identity used for unattended execution.</p><p>Routines are deliberately small: one trigger, one action. Use them to decide when an existing agent should run.</p><h3>Step-by-Step Implementation</h3><p>We assume you already have a Foundry project with a deployed prompt or hosted agent and the <strong>Foundry User</strong> role on the project. Creating connector connections has a separate prerequisite: the connector guide lists <strong>Foundry Project Manager</strong>. The agent’s identity also needs whatever permissions its tools require. Don’t grant broader roles just to bypass an unexplained failure.</p><p><strong>You can also do this in the Foundry portal.</strong> Open your project, select <strong>Routines</strong>, then <strong>+ New routine</strong>. Choose the agent, identity, prompt and trigger, and select <strong>Create &amp; start</strong>. The portal alternatives below correspond to the C# steps; package installation is only needed for the code path. Use a dedicated test environment and safe, preferably read-only agent tools because creating and starting a routine enables unattended execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6x4dIWfc8wvjr1jFXUXYw.png" /><figcaption>Portal support</figcaption></figure><h3>Step 1: Install the Packages</h3><p>Routines are not in the stable Azure.AI.Projects 2.0.1 package. Microsoft Learn points to this preview package set:</p><pre>dotnet add package Azure.AI.Projects --version 2.1.0-beta.4<br>dotnet add package Azure.AI.Projects.Agents --version 2.1.0-beta.4<br>dotnet add package Azure.AI.Extensions.OpenAI --version 2.1.0-beta.4<br>dotnet add package Azure.Identity</pre><p>The service is GA, but the .NET routines API is still experimental (as of October 2026). The connector experience is also preview. Configure FOUNDRY_PROJECT_ENDPOINT and AGENT_NAME locally and sign in with an identity that can access the project. Keep credentials out of source control, prompts and logs. Use .NET User Secrets for local secrets rather than committing them.</p><h3>Step 2: Create a Weekly Routine</h3><p>Let’s create a routine that runs a summary agent every Monday at 06:30, Swiss time. We create it disabled first and use a unique name to avoid replacing an existing routine:</p><pre>using Azure.AI.Projects;<br>using Azure.Identity;<br><br>#pragma warning disable AAIP001<br>var projectEndpoint = Environment.GetEnvironmentVariable(&quot;FOUNDRY_PROJECT_ENDPOINT&quot;);<br>var agentName = Environment.GetEnvironmentVariable(&quot;AGENT_NAME&quot;);<br><br>var projectClient = new AIProjectClient(<br>    new Uri(projectEndpoint),<br>    new DefaultAzureCredential());<br><br>var weeklyRoutineName = $&quot;weekly-summary-test-{Guid.NewGuid():N}&quot;;<br><br>var action = new AgentResponsesApiRoutineAction<br>{<br>    AgentName = agentName,<br>    Input = BinaryData.FromObjectAsJson(&quot;Summarize last week&#39;s activity and list open risks.&quot;),<br>};<br><br>var options = new ProjectsRoutineOptions(<br>    action: action,<br>    description: &quot;Weekly summary every Monday morning.&quot;,<br>    enabled: false);<br><br>options.Triggers.Add(&quot;monday-morning&quot;, new ScheduleRoutineTrigger(<br>    cronExpression: &quot;30 6 * * 1&quot;,<br>    timeZone: &quot;Europe/Zurich&quot;));<br><br>ProjectsRoutine routine = await projectClient.Routines.CreateOrUpdateAsync(<br>    name: weeklyRoutineName,<br>    options: options);<br><br>Console.WriteLine($&quot;Routine created: {routine.Name}, enabled={routine.IsEnabled}&quot;);</pre><p>No scheduler, no Function App, no storage account for run history. Keep the generated name for follow-up commands and cleanup. CreateOrUpdateAsync replaces the definition if you reuse an existing name, so don&#39;t use a production routine&#39;s name for a test.</p><p>After inspecting the saved definition and approving unattended execution, enable this specific test routine:</p><pre>await projectClient.Routines.EnableAsync(weeklyRoutineName);</pre><p><strong>Portal alternative:</strong> select <strong>Recurring schedule</strong>, choose weekly execution on Monday at 06:30, and select <strong>Create &amp; start</strong>. The portal interprets the time in your browser’s local time zone; confirm it is the intended Swiss time. To pin Europe/Zurich independently of the browser, use the code path above. Unlike the disabled-first example, <strong>Create &amp; start</strong> immediately enables the routine.</p><h3>Step 3: Test It Without Waiting a Week</h3><p>Nobody wants to wait until Monday to see if it works. Dispatch the routine manually, then wait for the matching dispatch in run history. A dispatch acknowledgment only means the request was queued.</p><pre>DispatchRoutineResult dispatch = await projectClient.Routines.DispatchAsync(<br>    name: &quot;weekly-summary&quot;,<br>    payload: new AgentResponsesApiDispatchPayload(<br>        BinaryData.FromObjectAsJson(&quot;Test run: summarize the last 24 hours.&quot;)));<br><br>Console.WriteLine($&quot;Dispatched: {dispatch.DispatchId}&quot;);<br><br>await foreach (RoutineRun run in projectClient.Routines.GetRoutineRunsAsync(&quot;weekly-summary&quot;))<br>{<br>    Console.WriteLine($&quot;{run.Id}: {run.Status} ({run.TriggerType}), response {run.ResponseId}&quot;);<br>}</pre><p>A run ends as finished, failed or killed. For failed runs, ErrorType and ErrorMessage tell you why - and the response ID takes you to the trace. When you&#39;re done testing, DeleteAsync(&quot;weekly-summary&quot;) cleans up.</p><p><strong>Portal alternative:</strong> open the routine and select <strong>Test run</strong>, then inspect its past-runs table. Select the response ID and check the actual response status, output and trace. For a summary agent, verify that the required data was available and that the summary satisfies your output criteria. Don’t call a queued request or an accepted background response an end-to-end pass.</p><h3>Step 4: Triage New GitHub Issues</h3><p>Now the more interesting one: an agent that reacts to events. First, create a GitHub <strong>connector connection</strong> in your project through the portal, REST or azd, and complete OAuth consent. Confirm the connection is connected and that the authenticated GitHub account can access the repository. The C# SDK creates the routine, not the connection.</p><p><strong>Important: the issue needs to be assigned to the connection user.</strong> The underlying GitHub connector documents IssueOpened as &quot;When a new issue is opened and assigned to me&quot; and IssueClosed as &quot;When an issue assigned to me is closed.&quot; Here, <strong>me means the GitHub account used to authorize the connector</strong>, not the agent identity or the person who happens to be viewing Foundry. The connector reference also excludes organization repositories for these issue triggers. Use a personally owned test repository for this walkthrough. Works with public but also private repositories.</p><p>Use an existing triage agent whose instructions define how to handle issue payloads, treat issue text as untrusted data, and return validated triage suggestions. The following code only configures its trigger; it doesn’t implement the agent:</p><pre>var githubRoutineName = $&quot;on-issue-opened-test-{Guid.NewGuid():N}&quot;;<br><br>var triageAction = new AgentResponsesApiRoutineAction<br>{<br>    AgentName = &quot;issue-triage-agent&quot;,<br>    Input = BinaryData.FromObjectAsJson(&quot;Triage this GitHub issue.&quot;),<br>};<br><br>var triageOptions = new ProjectsRoutineOptions(<br>    action: triageAction,<br>    description: &quot;Triages assigned new issues in our sample repo.&quot;,<br>    enabled: false);<br><br>triageOptions.Triggers.Add(&quot;on-issue&quot;, new GitHubIssueRoutineTrigger(<br>    connectionId: &quot;github-conn&quot;,<br>    owner: &quot;your-github-user&quot;,<br>    repository: &quot;your-repo&quot;,<br>    issueEvent: GitHubIssueEvent.Opened));<br><br>await projectClient.Routines.CreateOrUpdateAsync(githubRoutineName, triageOptions);</pre><p>Replace the connection, owner, repository and agent names with your test configuration. Inspect the saved definition, then deliberately enable it:</p><pre>await projectClient.Routines.EnableAsync(githubRoutineName);</pre><p><strong>Portal alternative:</strong> open <strong>Routines &gt; + New routine</strong>, select your agent and identity, fill in the required Prompt, select the GitHub connection, choose <strong>When a new issue is opened</strong>, and enter the repository owner and name. Select <strong>Create &amp; start</strong> when you’re ready to activate it. You can also easily setup the github connection from within the Portal (under Trigger select <strong>new GitHub Connection</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*TmVs8QJj1DkMuhh7XIdPYQ.png" /></figure><h3>Agent Identity or Creator Identity?</h3><p>This is the part I’d discuss with the team before writing any code. When nobody is chatting, whose permissions does the agent use?</p><ul><li><strong>Agent identity (default):</strong> The agent runs using its own Microsoft Entra identity. Use it when the tools support that authentication flow and grant only the permissions they need.</li><li><strong>Creator identity (opt-in):</strong> The routine delegates the identity of the person or service principal who <strong>created</strong> it. Use it only when the tools support the required delegated-access flow.</li></ul><p>My take: default to agent identity and least privilege. <strong>Choose a creator principal supported by each tool’s authentication flow. A service principal is not a substitute for user consent or delegated scopes.</strong> Saving a creator-identity setting doesn’t prove every tool can use it; verify each tool’s permissions and consent independently.</p><h3>Recap</h3><p>We turned a chat-only agent into an automated one: a weekly routine with an explicit time zone, a manual test dispatch with run history, and a GitHub issue trigger — all in a few lines of C#, without a single scheduler or webhook of our own. And finaly, Routines are GA in Microsoft foundry 🥳</p><p>I am also looking forward to new ideas using Routines and the github but especially the Teams trigger. Simple setups can now be done directly within Foundry, for more sophisticated one I guess Power Automate or an Azure Function are still the way-to-go.</p><h3>References</h3><ul><li><a href="https://devblogs.microsoft.com/foundry/from-chatbots-to-automated-assistants-routines-in-microsoft-foundry-are-now-generally-available/">Microsoft Foundry Blog: Routines are generally available</a></li><li><a href="https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/use-routines">Microsoft Learn: Automate agents with routines</a></li><li><a href="https://learn.microsoft.com/en-us/azure/foundry/agents/concepts/routines">Microsoft Learn: Routines concepts and limitations</a></li><li><a href="https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/tools/connectors">Microsoft Learn: Connector namespaces, consent and prerequisites</a></li><li><a href="https://learn.microsoft.com/en-us/connectors/github/">Microsoft Learn: GitHub connector triggers and limitations</a></li><li><a href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Projects/samples/Routines/Sample_Routines_ManualDispatch.md">Azure SDK for .NET: Manual dispatch sample</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=341536b92646" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/microsoft-foundry-from-agents-to-automation-with-routines-341536b92646">Microsoft Foundry: From Agents to Automation with Routines</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model-Context-Protocol in .NET: Elicitation]]></title>
            <link>https://medium.com/data-science-collective/model-context-protocol-in-net-elicitation-5789dc082895?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5789dc082895</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 20:42:30 GMT</pubDate>
            <atom:updated>2025-11-24T18:41:07.271Z</atom:updated>
            <content:encoded><![CDATA[<h3>Model-Context-Protocol in .NET: Elicitation</h3><p>The Model Context Protocol (MCP) can be considered as a standardisation of the exchange of context, tools and results between AI applications and external systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5f2cI5dlsDnLYyiIq6bUg.jpeg" /><figcaption><a href="https://www.pexels.com/de-de/@cottonbro/">Pexels — Cottonbro</a></figcaption></figure><p>MCP supports both <strong>developer use cases</strong> (e.g., local tools in IDEs) and <strong>business use cases</strong> (e.g., secure HTTP-based integration with enterprise systems). For a deeper dive into MCP basics and implementation in .NET, check out my previous article: 👉 <a href="https://medium.com/data-science-collective/model-context-protocol-in-net-06c6076b6385">Model-Context Protocol in .NET</a></p><p>Today, I want to talk about an advanced feature of the MCP, called Elicitation and how we can use it to implement a Human-in-the-loop approach in .NET.</p><h3>Table of Content</h3><p>· <a href="#2413">MCP in a nutshell</a><br>· <a href="#b8ae">Elicitation: The Concept in Detail</a><br> ∘ <a href="#0ea4">Elicitation Flow:</a><br>· <a href="#be5e">Step-by-Step Implementation: Human-in-the-Loop with Elicitation</a><br> ∘ <a href="#59c7">MCP Server</a><br> ∘ <a href="#927b">MCP Client:</a><br> ∘ <a href="#5aeb">WebClient SignalR version</a><br>· <a href="#6df5">Recap</a></p><h3>MCP in a nutshell</h3><p>The <strong>MCP Host</strong> is our AI application with access to an LLM. The <strong>MCP Server</strong> exposes tools and may integrate some external systems. To invoke these tools, an <strong>MCP Client</strong> connects to the MCP Server; the MCP Host handles this. This connection can be initialized with stdio when the server runs locally or via HTTP when the server runs remotely. When the LLM proposes executing a tool, the MCP Host sends the request to the MCP Client. The client will then forward the request to the server, where the tool will finally be invoked, and the result will be returned to the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*oryBLNaQ-yECTk21.png" /></figure><h3>Elicitation: The Concept in Detail</h3><p>Elicitation is a concept in MCP that allows the Server to pause execution and request additional information from the Client when needed. Think of a support agent who has access to an MCP Server to open a support case. During the tool invocation, the MCP Server realizes that, with the given e-mail, there is no user associated. Instead of aborting the creation of the case, it can now initiate a process to ask for the correct e-mail by the user (aka the MCP Client). This is what we can implement with Elicitation. Elicitation needs to be supported by the Client and will always be initiated by the Server.</p><p>So, in general, it is especially useful in scenarios where:</p><ul><li>The model lacks sufficient data to proceed.</li><li>A human decision or approval is required.</li><li>The system needs clarification or confirmation.</li></ul><h4>Elicitation Flow:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*PpeDZ4b0NDZziE9ZgowPEg.png" /><figcaption>modelcontextprotocol.io</figcaption></figure><p>Here you can find the <a href="https://modelcontextprotocol.io/docs/learn/client-concepts#elicitation">overall description</a> and the <a href="https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation">specification</a>.</p><h3>Step-by-Step Implementation: Human-in-the-Loop with Elicitation</h3><p>Now, let’s take a look at how we can implement human-in-the-loop for your MCP Server and Client. I am building upon the demo I created in my former <a href="https://medium.com/data-science-collective/model-context-protocol-in-net-06c6076b6385">blog post</a>, and you can also find the code on <a href="https://medium.com/r?url=https%3A%2F%2Fgithub.com%2Fdamienbod%2FMcpSecurity">GitHub</a>.</p><h4>MCP Server</h4><p>The MCP Server will initiate the Elicitation process. So let’s see how we can do that on our MCP Tools:</p><pre><br>[McpServerToolType]<br>public class DateTool<br>{<br>  [McpServerTool]<br>  [Description(&quot;Provides the current date and time in UTC format&quot;)]<br>  public async Task&lt;string&gt; GetCurrentDateTime2(IMcpServer mcpServer)<br>  {<br>    if (mcpServer.ClientCapabilities?.Elicitation == null)<br>    {<br>      throw new McpException(&quot;Client does not support Elicitation!&quot;);<br>    }<br><br>    var elicitationResult = await mcpServer.ElicitAsync(GetApprovalParams(nameof(GetCurrentDateTime)));<br>    if (elicitationResult.Action != &quot;accept&quot; || <br>      elicitationResult.Content?[&quot;answer&quot;].ValueKind != System.Text.Json.JsonValueKind.True)<br>    {<br>      throw new McpException(&quot;User declined to proceed&quot;);<br>    }<br><br>    return DateTime.UtcNow.ToString(CultureInfo.InvariantCulture);<br>  }<br><br>  private static ElicitRequestParams GetApprovalParams(string name) =&gt; new()<br>  {<br>    Message = $&quot;Do you want to execute tool &#39;{name}&#39;&quot;,<br>    RequestedSchema = new RequestSchema()<br>    {<br>      Properties =<br>      {<br>        [&quot;answer&quot;] = new BooleanSchema()<br>      },<br>    },<br>  };<br>}</pre><h4>MCP Client:</h4><p>For the client, we can add an Elicitation handler during the creation of our MCP Client:</p><pre><br>using var httpClient = new HttpClient();<br>var transport = new SseClientTransport(new()<br> {<br>     Endpoint = new Uri(&quot;https://localhost:7133/mcp&quot;),<br>     Name = &quot;MCP Desktop Client&quot;,<br> }, httpClient);<br><br>var options = new McpClientOptions()<br>       {<br>           ClientInfo = new()<br>           {<br>               Name = &quot;McpDemoClient&quot;,<br>               Version = &quot;1.0.0&quot;,<br>           },<br>           Capabilities = new()<br>           {<br>               Elicitation = new()<br>               {<br>                   ElicitationHandler = HandleElicitationAsync,<br>               },<br>           }<br>       };<br><br>await using IMcpClient mcpClient = <br>  await McpClientFactory.CreateAsync(transport, options);<br>...</pre><p>For a console app, you can easily implement it like that:</p><pre>public static ValueTask&lt;ElicitResult&gt; HandleElicitationAsync(ElicitRequestParams? requestParams, CancellationToken token)<br>{<br>    // Bail out if the requestParams is null or if the requested schema has no properties<br>    if (requestParams?.RequestedSchema?.Properties == null)<br>    {<br>        return ValueTask.FromResult(new ElicitResult());<br>    }<br><br>    // Process the elicitation request<br>    if (requestParams?.Message is not null)<br>    {<br>        Console.WriteLine(requestParams.Message);<br>    }<br><br>    Console.WriteLine($&quot;Please allow/decline function execution with [y,n]&quot;);<br>    var key = Console.ReadKey();<br>    Console.WriteLine();<br><br>    var userAllowance = key.KeyChar == &#39;y&#39; || key.KeyChar == &#39;Y&#39;;<br>    var content = new Dictionary&lt;string, JsonElement&gt;();<br>    content[&quot;answer&quot;] = JsonSerializer.Deserialize&lt;JsonElement&gt;(JsonSerializer.Serialize(userAllowance));<br><br>    // Return the user&#39;s input<br>    return ValueTask.FromResult(new ElicitResult<br>    {<br>        Action = &quot;accept&quot;,<br>        Content = content<br>    });<br>}</pre><h4>WebClient SignalR version</h4><p>For a web client, it gets a little bit more complicated. First, we need to handle the MCP Server and MCP Client correctly. Finally, the client also needs to implement Human-In-The-Loop in the UI.</p><p>In your Program.cs file, add:</p><pre>builder.Services.AddSignalR();</pre><p>The MCP Client handler is only forwarding to the ElicitationCoordinator:</p><pre>private ValueTask&lt;ElicitResult&gt; HandleElicitationAsync(ElicitRequestParams? requestParams, CancellationToken token)<br>{<br>    return _elicitationCoordinator.HandleAsync(requestParams, token);<br>}</pre><p>Now we first need a SignalR Hub:</p><pre>[Authorize]<br>public class ElicitationHub : Hub<br>{<br>    private readonly ElicitationCoordinator _coordinator;<br>    public ElicitationHub(ElicitationCoordinator coordinator) =&gt; _coordinator = coordinator;<br><br>    public IEnumerable&lt;object&gt; Pending()<br>        =&gt; _coordinator.GetAll().Select(p =&gt; new { id = p.Id, message = p.Message });<br><br>    public bool Approve(string id) =&gt; _coordinator.Approve(id);<br>    public bool Decline(string id) =&gt; _coordinator.Decline(id);<br>}</pre><p>Which will be used by our ElicitationCoordinator:</p><pre>public partial class ElicitationCoordinator<br>{<br>    private readonly TimeSpan _timeout = TimeSpan.FromMinutes(2);<br>    private readonly IHubContext&lt;ElicitationHub&gt;? _hubContext;<br><br>    public ElicitationCoordinator(IHubContext&lt;ElicitationHub&gt; hubContext)<br>    {<br>        _hubContext = hubContext;<br>    }<br><br>    private readonly ConcurrentDictionary&lt;string, ToolCallPending&gt; _pending = new();<br><br>    public IEnumerable&lt;(string Id, string? Message)&gt; GetAll() =&gt; _pending.Select(kv =&gt; (kv.Key, kv.Value.Request.Message));<br><br>    public ValueTask&lt;ElicitResult&gt; HandleAsync(ElicitRequestParams? requestParams, CancellationToken token)<br>    {<br>        if (requestParams is null)<br>        {<br>            return ValueTask.FromResult(new ElicitResult());<br>        }<br><br>        var id = Guid.NewGuid().ToString(&quot;N&quot;);<br>        var entry = new ToolCallPending(requestParams);<br>        _pending[id] = entry;<br><br>        _ = _hubContext?.Clients.All.SendAsync(&quot;ElicitationPending&quot;, new { id, message = requestParams.Message });<br><br>        _ = Task.Run(async () =&gt;<br>        {<br>            try<br>            {<br>                using var cts = CancellationTokenSource.CreateLinkedTokenSource(token);<br>                cts.CancelAfter(_timeout);<br>                await Task.WhenAny(entry.Tcs.Task, Task.Delay(Timeout.Infinite, cts.Token));<br>                if (!entry.Tcs.Task.IsCompleted)<br>                {<br>                    entry.Tcs.TrySetResult(false);<br>                }<br>            }<br>            catch<br>            {<br>                entry.Tcs.TrySetResult(false);<br>            }<br>        });<br><br>        return AwaitDecisionAsync(id, entry);<br>    }<br><br>    private async ValueTask&lt;ElicitResult&gt; AwaitDecisionAsync(string id, ToolCallPending pending)<br>    {<br>        var approved = await pending.Tcs.Task.ConfigureAwait(false);<br>        _pending.TryRemove(id, out _);<br>        var content = new Dictionary&lt;string, JsonElement&gt;();<br>        content[&quot;answer&quot;] = JsonSerializer.Deserialize&lt;JsonElement&gt;(JsonSerializer.Serialize(approved));<br>        _ = _hubContext?.Clients.All.SendAsync(&quot;ElicitationCompleted&quot;, new { id, approved });<br>        return new ElicitResult<br>        {<br>            Action = &quot;accept&quot;,<br>            Content = content<br>        };<br>    }<br><br>    public bool Approve(string id)<br>    {<br>        if (_pending.TryGetValue(id, out var p))<br>        {<br>            return p.Tcs.TrySetResult(true);<br>        }<br>        return false;<br>    }<br><br>    public bool Decline(string id)<br>    {<br>        if (_pending.TryGetValue(id, out var p))<br>        {<br>            return p.Tcs.TrySetResult(false);<br>        }<br>        return false;<br>    }<br>}</pre><p>Some DTOs for completeness:</p><pre>public class ToolCallPending<br>{<br>    public TaskCompletionSource&lt;bool&gt; Tcs { get; } = new(TaskCreationOptions.RunContinuationsAsynchronously);<br>    public ElicitRequestParams Request { get; }<br>    public DateTime CreatedUtc { get; } = DateTime.UtcNow;<br>    public ToolCallPending(ElicitRequestParams req) { Request = req; }<br>}<br><br></pre><p>On the Client Web Frontend, I injected the SignalR part using Javascript:</p><pre>(async function(){<br>  if(!window.signalR){ console.error(&#39;SignalR client not loaded&#39;); return; }<br>  const listContainerId = &#39;elicitation-requests&#39;;<br>  function ensureContainer(){<br>    let c = document.getElementById(listContainerId);<br>    if(!c){<br>      c = document.createElement(&#39;div&#39;);<br>      c.id = listContainerId;<br>      c.className = &#39;mt-4&#39;;<br>      c.innerHTML = &#39;&lt;h5&gt;Live Elicitation Requests&lt;/h5&gt;&lt;ul class=&quot;list-group&quot; id=&quot;elicitation-list&quot;&gt;&lt;/ul&gt;&#39;;<br>      // place directly after the first POST form (Send Prompt form)<br>      const promptForm = document.querySelector(&#39;form[method=&quot;post&quot;]&#39;);<br>      if(promptForm){<br>        promptForm.insertAdjacentElement(&#39;afterend&#39;, c);<br>      } else {<br>        // fallback: append to main<br>        document.querySelector(&#39;main&#39;)?.appendChild(c);<br>      }<br>    }<br>    return c;<br>  }<br><br>  const connection = new signalR.HubConnectionBuilder()<br>    .withUrl(&#39;/hubs/elicitation&#39;)<br>    .withAutomaticReconnect()<br>    .build();<br><br>  connection.on(&#39;ElicitationPending&#39;, (payload)=&gt;{<br>    ensureContainer();<br>    const ul = document.getElementById(&#39;elicitation-list&#39;);<br>    if(!ul) return;<br>    const li = document.createElement(&#39;li&#39;);<br>    li.className = &#39;list-group-item&#39;;<br>    li.id = `elic-${payload.id}`;<br>    li.innerHTML = `&lt;div&gt;&lt;strong&gt;Request:&lt;/strong&gt; ${payload.message || &#39;(no message)&#39;}&lt;/div&gt;<br>      &lt;div class=&quot;mt-2&quot;&gt;<br>        &lt;button class=&quot;btn btn-sm btn-success me-2&quot; data-action=&quot;approve&quot;&gt;Approve&lt;/button&gt;<br>        &lt;button class=&quot;btn btn-sm btn-danger&quot; data-action=&quot;decline&quot;&gt;Decline&lt;/button&gt;<br>      &lt;/div&gt;`;<br>    li.querySelectorAll(&#39;button&#39;).forEach(btn=&gt;{<br>      btn.addEventListener(&#39;click&#39;, async ()=&gt;{<br>        const act = btn.getAttribute(&#39;data-action&#39;);<br>        btn.disabled = true;<br>        try{<br>          await connection.invoke(act === &#39;approve&#39; ? &#39;Approve&#39; : &#39;Decline&#39;, payload.id);<br>        }catch(e){ console.error(e); }<br>      });<br>    });<br>    ul.appendChild(li);<br>  });<br><br>  connection.on(&#39;ElicitationCompleted&#39;, (payload)=&gt;{<br>    const li = document.getElementById(`elic-${payload.id}`);<br>    if(li){<br>      li.classList.add(payload.approved ? &#39;list-group-item-success&#39; : &#39;list-group-item-danger&#39;);<br>      li.querySelectorAll(&#39;button&#39;).forEach(b=&gt; b.remove());<br>      const status = document.createElement(&#39;div&#39;);<br>      status.className = &#39;mt-2 fw-bold&#39;;<br>      status.textContent = payload.approved ? &#39;Approved&#39; : &#39;Declined&#39;;<br>      li.appendChild(status);<br>    }<br>  });<br><br>  try{<br>    await connection.start();<br>  }catch(e){ console.error(&#39;SignalR start failed&#39;, e); }<br>})();</pre><p>You can find a running example here (not yet migrated to the new Microsoft Agent Framework): <a href="https://github.com/damienbod/McpSecurity">https://github.com/damienbod/McpSecurity</a></p><h3>Recap</h3><p>Elicitation brings a new level of interactivity and control to AI systems built with MCP. By allowing models to request clarification or approval, we can build agents that are not only smart but also <strong>safe, transparent, and user-centric</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5789dc082895" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/model-context-protocol-in-net-elicitation-5789dc082895">Model-Context-Protocol in .NET: Elicitation</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure AI Search in Copilot Studio: The Right Way with Custom Knowledge Sources]]></title>
            <link>https://medium.com/data-science-collective/azure-ai-search-in-copilot-studio-the-right-way-with-custom-knowledge-sources-ff0f62ffccc2?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff0f62ffccc2</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[azure-ai-search]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[copilot-studio]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Thu, 06 Nov 2025 21:31:05 GMT</pubDate>
            <atom:updated>2025-11-11T17:04:00.084Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, while working on a Microsoft Copilot Studio project, I wanted to add Azure AI Search as a knowledge source. Sounds simple, right? Well… it wasn’t. To be host, the out-of-the-box integration is frustrating. In my opinion, the built-in Azure AI Search knowledge provider just doesn’t work as expected (I’ll explain why in a second).</p><p>But there is a solution: It’s called <strong>Custom Knowledge Sources</strong>. This recently introduced capability is still under the radar as it is not yet visible in the UI, but it opens the door to implementing Azure AI Search in a way that finally feels right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MOnaMnf_hyNuXc3b" /><figcaption>Photo by <a href="https://unsplash.com/@viktortalashuk?utm_source=medium&amp;utm_medium=referral">Viktor Talashuk</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Table of Content</h3><p>· <a href="#4e8e">Azure AI Search in a nutshell</a><br>· <a href="#123c">Why does the out-of-the-box knowledge provider suck?</a><br>· <a href="#f047">The new approach: Custom Knowledge Sources in Copilot Studio</a><br> ∘ <a href="#f95a">Step 1: The trigger OnKnowledgeRequested</a><br> ∘ <a href="#f47e">Step 2: Semantic Hybrid Search Connector</a><br> ∘ <a href="#68b3">Step 3: Result Parsing</a><br> ∘ <a href="#2d05">Step 4: Limiting results and set SearchResults:</a><br> ∘ <a href="#dc3c">Complete Topic</a><br>· <a href="#5076">Final Thoughts</a><br>· <a href="#f522">References</a></p><h3>Azure AI Search in a nutshell</h3><p>Azure AI Search is Microsoft’s powerful search and vector database service. It supports full-text, vector, and hybrid search modes, and includes advanced features such as semantic reranking and scoring profiles. If you’re developing an RAG solution on Azure, this is the obvious choice.</p><p>Here are a few key concepts:</p><ul><li><strong>Index</strong>: The structured container for your content, defined by a schema.</li><li><strong>Chunk</strong>: Individual documents within the index, often referred to as chunks.</li><li><strong>Index Fields</strong>: Schema-defined fields with attributes like searchable, filterable, sortable, etc.</li><li><strong>Vector Store</strong>: Fields can store vector embeddings, enabling semantic search.</li><li><strong>Query Processing</strong>: Supports full-text, vector, and hybrid search. Hybrid search is often the best choice, combining lexical and semantic relevance.</li><li><strong>Reranking</strong>: A two-stage process that refines search results using semantic understanding. My prefered feature and often a game-changer in retrieval quality.</li></ul><p>I have already written two blog articles explaining how to implement RAG with Azure AI Search in .NET, as well as detailing some of the advanced features.</p><p><a href="https://medium.com/c-sharp-programming/llm-apps-in-net-implement-rag-on-azure-in-under-10-minutes-d8b5b500ea1b"><em>LLM Apps in .NET: Implement RAG on Azure in under 10 minutes</em></a><em><br></em><a href="https://medium.com/data-science-collective/llm-apps-in-net-advanced-search-options-for-azure-openai-on-your-data-8c33fcadaf83"><em>LLM Apps in .NET: Advanced Search Options for Azure OpenAI — On your Data</em></a></p><h3>Why does the out-of-the-box knowledge provider suck?</h3><p>Until now, there were several limitations to Copilot Studio’s out-of-the-box integration with Azure AI Search. Essentially, you could only add it as a knowledge source and select the index. This would allow you to view some of the configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I9LzRuC2_p6dNBR0-xjypQ.png" /></figure><p>And that’s basically it. There is no way to define the query type (keyword, vector or hybrid), activate reranking or add a filter. When configuring the knowledge, you can only define a description and specify whether the knowledge can be called from a topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RS6666NJ9t9ucQHq-ioy9Q.png" /></figure><p>So what am I missing specifically:</p><ul><li>Proper way to <strong>define query type</strong></li><li><strong>Specify number of documents</strong> retrieved</li><li><strong>Threshold </strong>for <strong>minimal score</strong> of the documents</li><li>Other Azure AI search functionalities like <strong>filter, query rewrite, etc.</strong></li></ul><h3>The new approach: Custom Knowledge Sources in Copilot Studio</h3><p>The new Custom Knowledge Source feature removes these barriers. It enables you to add knowledge to your agent yourself. You can activate it as a trigger for your topic and access context from wherever you want. In my case, I used the PowerPlatform AI Search connector, which offers many more configuration options.<br>The Microsoft CAT team wrote a blog article about how to use the feature: <a href="https://microsoft.github.io/mcscatblog/posts/copilot-studio-custom-knowledge-source/">Microsoft CAT Team Blog — Custom Knowledge source</a>. I recommend that everyone reads it — it’s rather short and straightforward.</p><h4>Step 1: The trigger OnKnowledgeRequested</h4><p>The trigger is not yet available via the UI. Create a new topic, switch to code view, then add:</p><pre>kind: AdaptiveDialog<br>beginDialog:<br>  kind: OnKnowledgeRequested<br>  id: main<br>  intent: {}<br>  actions:<br><br>    <br>inputType: {}<br>outputType: {}</pre><p>This will activate the trigger, allowing you to implement custom knowledge. The trigger will be activated whenever the agent requests knowledge. Three variables will be added to your topic:</p><ul><li><strong>System.SearchQuery:</strong> A derived query from user input and history, optimized for semantic search. This is what we will use for our hybrid search approach!</li><li><strong>System.KeywordSearchQuery:</strong> A derived query from user input and history, optimized for keyword search.</li><li><strong>System.SearchResults</strong>: This is the output variable in which we need to store our results.</li></ul><h4>Step 2: Semantic Hybrid Search Connector</h4><p>Rather than using the knowledge connector in Copilot Studio, we will use the Power Platform Connector for Semantic Hybrid Search. Other connectors are available if you want to apply other query types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-cELE1svwx0SQz61kHb_Qw.png" /></figure><p>Now for the interesting part: the options. In the input variables, we can already see many parameters that allow us to define our search more specifically. We can specify the select parameter, filter and limit our search result (Top Searches).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*TyY54TTuzKQRkzovHXxJhg.png" /></figure><p>That’s exactly what we were looking for! 🥳</p><h4>Step 3: Result Parsing</h4><p>We now need to transfer the results to the trigger’s output variable. To do this, we first need to parse the output from the PP connector into the desired schema for the trigger output variables. We can use the <em>Parse Value </em>task for this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*ZVeH2-U2LkZH6ZyJ7nQbTw.png" /></figure><p>With the following schema:</p><pre>kind: Table<br>properties:<br>  content: String<br>  reRankerScore: Float<br>  score: Float<br>  title: String<br>  url: String</pre><h4>Step 4: Limiting results and set SearchResults:</h4><p>Now we are ready to set the System.SearchResults variable, where we can use the <em>Set Variable</em> task:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*DV67Jugw8AA0MMK2wyoBgA.png" /></figure><p>I also added a filter to ensure that only documents with a rerankScore greater than 2.5 are added. (Reranking score are within the range 0–4, see detailed descripion in the <a href="https://learn.microsoft.com/en-us/azure/search/semantic-search-overview#how-results-are-scored">docs</a>).</p><pre>ForAll(<br>    Filter(Topic.TempSearchResult, reRankerScore &gt; 2.5), {<br>        Content: Text(content),<br>        ContentLocation: Text(url),<br>        Title: Text(title)<br>        })</pre><p>That’s it. Know, when the agent want’s to retrieve knowledge, the topic is executed and the agent will have access to the provided custom knowledge source!</p><h4>Complete Topic</h4><p>And for completeness, the complete flow as YAML:</p><pre>kind: AdaptiveDialog<br>modelDescription: This Topic is an example for how to implement AI Search Service correctly.<br>beginDialog:<br>  kind: OnKnowledgeRequested<br>  id: main<br>  intent: {}<br>  actions:<br>    - kind: InvokeConnectorAction<br>      id: invokeConnectorAction_de<br>      input:<br>        binding:<br>          indexName: your index name<br>          searchText: =System.SearchQuery<br>          selectFields:<br>            - Value: content<br>            - Value: url<br>            - Value: title<br>          semanticConfiguration: semantic-config<br>          top: 10<br>          vectorizedSearchFields:<br>            - Value: embedding<br>      output:<br>        kind: SingleVariableOutputBinding<br>        variable: Topic.SemanticHybridSearch<br>      connectionReference: your_connection_ref<br>      connectionProperties:<br>        mode: Maker<br>      operationId: SemanticHybridSearch<br><br>    - kind: ParseValue<br>      id: parseSearchResult<br>      displayName: Parse value<br>      variable: Topic.TempSearchResult<br>      valueType:<br>        kind: Table<br>        properties:<br>          content: String<br>          reRankerScore: Float<br>          score: Float<br>          title: String<br>          url: String<br>      value: =Topic.SemanticHybridSearch<br><br>    - kind: SetVariable<br>      id: setVariable_38dU4L<br>      displayName: Filter values &lt; 2.5 rerankScore<br>      variable: System.SearchResults<br>      value: |-<br>        =ForAll(<br>            Filter(Topic.TempSearchResult, reRankerScore &gt; 2.5), {<br>                Content: Text(content),<br>                ContentLocation: Text(url),<br>                Title: Text(title)<br>                })<br><br>inputType: {}<br>outputType: {}</pre><h3>Final Thoughts</h3><p><strong>Custom Knowledge Sources</strong> is an amazing new Copilot Studio feature. In our case, it allows us to use Azure AI Search as intended. However, I also see a lot of potential for other use cases, as it makes it easy to bring context to your agent. You can implement multiple topics with the <strong>OnKnowledgeRequested </strong>trigger. During processing, up to 15 documents can be added to the result set.</p><h3>References</h3><p><a href="https://learn.microsoft.com/en-us/microsoft-copilot-studio/knowledge-azure-ai-search">Copilot Studio — Azure AI Search Knowledge</a></p><p><a href="https://microsoft.github.io/mcscatblog/posts/copilot-studio-custom-knowledge-source/">Microsoft CAT Team Blog — Custom Knowledge source</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff0f62ffccc2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/azure-ai-search-in-copilot-studio-the-right-way-with-custom-knowledge-sources-ff0f62ffccc2">Azure AI Search in Copilot Studio: The Right Way with Custom Knowledge Sources</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model Context Protocol in .NET]]></title>
            <link>https://medium.com/data-science-collective/model-context-protocol-in-net-06c6076b6385?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/06c6076b6385</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 19:47:26 GMT</pubDate>
            <atom:updated>2025-11-24T15:30:39.989Z</atom:updated>
            <content:encoded><![CDATA[<h3>Model Context Protocol in .NET</h3><p>A Large Language Model (LLM) is designed to understand and generate natural language. These days, LLMs are used for a variety of other tasks and perform well in these areas. However, ultimately, an LLM is a fixed machine learning model, so it cannot answer simple questions such as “What is the current date?” because it does not have access to this information.<br>This is why, these days, an <strong>LLM based AI Agent </strong>does not only have access to an LLM. It also needs Memory to bring context from external data sources to the system. We also need tools, that enable the LLM to interact with APIs, the OS and other aspects of the outer World.<br>This is where the Model Context Protocol (MCP) comes in. The MCP provides a structured way to manage context, function calls, and human-in-the-loop scenarios, and is ready for use within the .NET ecosystem. By standardizing these interactions, the MCP enables developers to build AI-powered applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7jHKr2TsA0YstlJq3tR_Jg.png" /><figcaption>Source: Security of AI Agents, He et al. 202 — <a href="https://arxiv.org/pdf/2406.08689">https://arxiv.org/pdf/2406.08689</a></figcaption></figure><h4>Related Article:</h4><p><a href="https://medium.com/data-science-collective/model-context-protocol-in-net-elicitation-5789dc082895">MCP in .NET: Elicitation</a> (follow up read)</p><h4>Table of Content</h4><p>· <a href="#5d0a">LLM Function Calling</a><br> ∘ <a href="#5681">Function Calling with Semantic Kernel in dotnet</a><br> ∘ <a href="#e21a">Human in the Loop</a><br>· <a href="#8ccc">MCP Basics</a><br> ∘ <a href="#9219">MCP Use Cases</a><br> ∘ <a href="#daaf">MCP Server Capabilities</a><br> ∘ <a href="#3ef0">MCP Client Capabilities</a><br> ∘ <a href="#584a">MCP Host — The AI Application</a><br>· <a href="#953b">How to Be Implemented in .NET</a><br> ∘ <a href="#023d">MCP Server</a><br> ∘ <a href="#49b9">MCP Tool</a><br> ∘ <a href="#9b7d">MCP Host &amp; Client</a><br>· <a href="#130e">Conclusion</a></p><h3>LLM Function Calling</h3><p>First things first: in the LLM world, tools, functions, and even Semantic Kernel plug-ins are all one and the same. Yes, it’s confusing, and it would be better to use one name for the same thing, well… 😉</p><blockquote><strong>I consider function calling to be the most powerful feature of modern LLMs!</strong></blockquote><p>Rather than simply responding with text, LLMs can now select the function they want to execute. The model itself cannot execute the function (thankfully), but it can respond that it would like the function to be executed. Then, the AI agent must execute the tool and send the response back to the LLM. This capability opens the way for the development of intelligent agents that can automate tasks, retrieve information or even make decisions, sometimes autonomously and sometimes with human oversight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/0*9AKCexcORRaXees0.png" /><figcaption>Source: <a href="https://learn.microsoft.com/en-us/semantic-kernel/concepts/ai-services/chat-completion/function-calling/?pivots=programming-language-csharp">https://learn.microsoft.com/en-us/semantic-kernel/concepts/ai-services/chat-completion/function-calling/?pivots=programming-language-csharp</a></figcaption></figure><h4>Function Calling with Semantic Kernel in dotnet</h4><p>Semantic Kernel is an excellent tool for implementing function calling within .NET. It essentially orchestrates the tools provided to the LLM, as well as the execution. Best of all, we can write our tools in C# code❤️</p><p>So let’s create a simple function then:</p><pre>public class DateAndTimePlugin<br>{<br>  [KernelFunction(&quot;DateAndTime&quot;)]<br>  [Description(&quot;Provides the current date and time in UTC format&quot;)]<br>  public string CurrentDateAndtimeInUTC() =&gt;<br>    DateTime.UtcNow.ToString(CultureInfo.InvariantCulture);<br>}</pre><p>Now, let’s allow the LLM to select the tool to be executed.</p><pre>var modelId = &#39;&#39;<br>var endpoint = &#39;&#39;;<br>var apikey = &#39;&#39;;<br><br>// establishing the kernel<br>var kernel = Kernel. CreateBuilder()<br>.AddAzureOpenAIChatCompletion(modelId, endpoint, apiKey)<br>.Build();<br><br>// importing the tool<br>kernel.ImportPluginFromType&lt;DateAndTimePlugin&gt;();<br><br>// executing the prompt with the tool activated<br>var chatHistory = new ChatHistory();<br>chatHistory.AddUserMessage(&quot;What important historic events happend today in the past?&quot;);<br>var executioSettings = new OpenAIPromptExecutionSettings()<br>{<br>  FunctionChoiceBehavior = FuntionChoiceBehavior.Auto()<br>}<br><br>// execute prompt<br>var chatCompletionService = kernel.GetRequiredService&lt;IChatCompletionService&gt;();<br>var messageContent = await chatCompletionService<br>  .GetChatMessageContentAsync(chatHistory, executioSettings, kernel);</pre><p>That’s it. Now, when the model wants to access the function, Semantic Kernel automatically invokes the tool and sends the information back to the LLM. We have implemented our first function-calling behaviour with Semantic Kernel 🥳</p><h4>Human in the Loop</h4><p>Despite the power of automation, there are many scenarios in which human approval remains essential. Human-in-the-loop workflows ensure that sensitive, ambiguous or high-impact decisions are reviewed and approved by people. In practice, this means that an LLM may suggest a tool to be invoked, such as approving a transaction or generating a report, but the final decision rests with a human approver. This approach increases trust and accountability, and allows organisations to leverage AI while maintaining control over critical processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5f2cI5dlsDnLYyiIq6bUg.jpeg" /></figure><h3>MCP Basics</h3><p>At its core, the Model Context Protocol is about standardising the exchange of context, actions and results between AI applications and external systems. The MCP defines clear contracts for how requests are structured, how context is maintained and updated, and how responses, including those requiring human intervention, are handled. SDKs are available for major programming languages. When it comes to implementing the MCP server, I prefer .NET. Ultimately, it’s simply a matter of implementing an API: <a href="https://github.com/modelcontextprotocol/csharp-sdk.">https://github.com/modelcontextprotocol/csharp-sdk.</a></p><p>The <strong>MCP Host</strong> is our AI application with access to an LLM. The <strong>MCP Server</strong> exposes tools and may integrate some external systems. To invoke these tools, an <strong>MCP Client</strong> connects to the MCP Server; the MCP Host handles this. This connection can be initialized with stdio when the server runs locally or via HTTP when the server runs remotely. When the LLM proposes executing a tool, the MCP Host sends the request to the MCP Client. The client will then forward the request to the server, where the tool will finally be invoked, and the result will be returned to the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*LuBmVP75SBpyy8enZj6bww.png" /></figure><h4>MCP Use Cases</h4><p>The MCP is designed to be flexible enough to support a wide range of scenarios. I like to distinguish between a developer use case and a business use case.</p><p>In the developer use case, we install our servers locally and integrate them with our preferred AI coding assistant and IDE, such as GitHub Copilot and VSCode. A solid understanding of how to set this up and use it successfully is required. This is not applicable to most knowledge workers.</p><p>In contrast, in the business use case, end users connect to the company AI assistant, such as Copilot, ChatGPT Enterprise, or any other. With MCP, we can integrate line-of-business (LOB) applications into this ecosystem, enabling users to interact with them. Therefore, we need a secure solution over HTTP with proper authentication and authorization.</p><blockquote>In the era of business use cases, there is huge potential to generate true business value for our end users.</blockquote><h4>MCP Server Capabilities</h4><p>The MCP Server’s main capability is exposing tools. You can access a list of all the available tools and invoke them with the defined arguments. There are also other functionalities, such as read-only resources, file exposure from server to client, and prompts, which provide examples of how to use the exposed tools. Finally, the server supports different utilities, such as completion (used for autocompletion), logging, and pagination.</p><h4>MCP Client Capabilities</h4><p>On the client side, there are a number of capabilities. Let’s start with Roots, which allows data to be exposed from the client to the server, such as source files or others. Then there’s Elicitation and Sampling, which were introduced to MCP just this summer. These are powerful concepts that enable the server to interact with the client. With elicitation, the server can interact with the client to gather additional information, which the client needs to support. This can be used to implement human-in-the-loop processes. Before invoking the tool, the MCP Server can start an elicitation request to obtain user approval. Sampling is similar to elicitation, but instead of requesting additional data, the server can prompt the client to invoke a prompt.</p><h4>MCP Host — The AI Application</h4><p>The MCP Host is the application that brings all these elements together. It can be a desktop IDE extension, a web-based application or a custom agent that runs locally or in the cloud. The host delivers a seamless user experience by integrating with data sources and external systems and scaling to support multiple users and concurrent sessions. Leveraging MCP ensures that AI-driven workflows remain transparent, controllable and adaptable to changing requirements.</p><h3>How to Be Implemented in .NET</h3><p>Let’s have a look how this can be implemented in .NET.</p><h4>MCP Server</h4><p>The MCP is basically just a API and can be easily be setup with just a few lines of code. Create a new API Project, add the <em>ModelContextProtocol.AspNetCore </em>nuget library and adjust your Program.cs :</p><pre>var builder = WebApplication.CreateBuilder(args);<br><br>builder.Services<br>       .AddMcpServer()<br>       .WithHttpTransport()<br>       .WithTools&lt;DateTool&gt;();<br><br>// Add services to the container.<br>var app = builder.Build();<br><br>// map the mcp endpoit<br>app.MapMcp(&quot;/mcp&quot;);<br><br>await app.RunAsync();</pre><h4>MCP Tool</h4><p>The tools looks rather similar than the Semantic Kernel implementaiton</p><pre>[McpServerToolType]<br>public class DateTool<br>{<br>    [McpServerTool]<br>    [Description(&quot;Provides the current date and time in UTC format&quot;)]<br>    public string CurrentDateAndtimeInUTC() =&gt;<br>      DateTime.UtcNow.ToString(CultureInfo.InvariantCulture);<br>}</pre><p>And that’s it. Now our MCP server is ready to be used 🥳.</p><h4>MCP Host &amp; Client</h4><pre>... <br><br>// importing the tool<br>using var httpClient = new HttpClient();<br>var transport = new SseClientTransport(new()<br> {<br>     Endpoint = new Uri(&quot;https://localhost:7133/mcp&quot;),<br>     Name = &quot;MCP Desktop Client&quot;,<br> }, httpClient);<br>await using IMcpClient mcpClient = await McpClientFactory.CreateAsync(transport);<br><br>// Retrieve the list of tools available on the MCP server<br>var tools = await mcpClient.ListToolsAsync().ConfigureAwait(false);<br><br>// import the tools into the kernel<br>kernel.Plugins.AddFromFunctions(&quot;Tools&quot;, tools. Select(aiFunction = aiFunction.AsKernelFunction()));<br><br>// executing the prompt with the tool activated<br>// do not have to change something here!<br>...</pre><p>That’s it. We have just implemented our first MCP Server and Client. If you want to test your MCP Server without a client, you can use the MCP Inspector — a cool, tiny Node.js application that makes it easy to get started with MCP (although it lacks some security features for server authentication).</p><h3>Conclusion</h3><p>The Model Context Protocol represents a significant step forward in orchestrating complex, collaborative AI workflows in .NET. By standardizing context exchange, function calling, and human-in-the-loop processes, MCP empowers both developers and businesses to build intelligent, auditable, and trustworthy applications. Combined with the flexibility of Semantic Kernel, MCP provides the foundation for the next generation of AI-powered solutions — where automation and human expertise work hand in hand.</p><p>The documentation is written straight forward and easy to understand. Everybody who digs into the topic should have a look here: <a href="https://modelcontextprotocol.io/docs/getting-started/intro">https://modelcontextprotocol.io/docs/getting-started/intro</a></p><p>All the code is available in the following github repo: <a href="https://github.com/damienbod/McpSecurity">https://github.com/damienbod/McpSecurity</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06c6076b6385" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/model-context-protocol-in-net-06c6076b6385">Model Context Protocol in .NET</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Apps with .Net: Implement a Reflection Agent with AutoGen and SemanticKernel]]></title>
            <link>https://medium.com/data-science-collective/llm-apps-with-net-implement-a-reflection-agent-with-autogen-and-semantickernel-e5ce1fb36142?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5ce1fb36142</guid>
            <category><![CDATA[autogen]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[semantic-kernel]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 19:52:04 GMT</pubDate>
            <atom:updated>2025-09-12T10:51:28.223Z</atom:updated>
            <content:encoded><![CDATA[<h3>LLM Apps with .Net: Implement a Reflection Agent with AutoGen and SemanticKernel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FUZRxagi8Sl6HEVI" /><figcaption>Photo by <a href="https://unsplash.com/@hjwinunsplsh?utm_source=medium&amp;utm_medium=referral">Jungwoo Hong</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The expectation of an LLM-generated answer is high. The user expects a correct and meaningful answer in no time. But sometimes, the answers of LLMs are not good, ending up in hallucination or other cut-off sentences. When we think of RAG, there are two crucial steps. First of all the retrieval step (do we find the relevant documents to answer the question) and then the answer generation step (do we write a correct answer, citing the expected document). In my former blog posts, I showed you how to setup RAG in dotnet and how to improve your retrieval step. This post focuses on how to improve the answer generation part with a reflection agent.</p><p><strong>Related Articles<br></strong><a href="https://medium.com/@cedric.mendelin/llm-apps-with-net-tools-and-frameworks-dd3812e4df61">LLM Apps with .NET: Tools and Frameworks</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-in-net-implement-rag-on-azure-in-under-10-minutes-d8b5b500ea1b">LLM Apps in .NET: Implement RAG on Azure in under 10 minutes</a><br><a href="https://medium.com/data-science-collective/llm-apps-in-net-advanced-search-options-for-azure-openai-on-your-data-8c33fcadaf83">LLM Apps in .NET: Advanced Search Options for Azure OpenAI — On your Data</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-with-net-evaluation-with-microsoft-extensions-ai-evaluation-meai-a593fe122bc5">LLM Apps with .NET: Evaluation with MEAI.Evaluation</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-with-net-automate-evaluation-with-azuredevops-550776b28388">LLM Apps with .NET: Automate Evaluation with AzureDevOps</a></p><h3>Table of Content</h3><p>· <a href="#1e64">From More Agents Is All you Need to Reflexion</a><br>· <a href="#c273">Implement Reflection with AutoGen</a><br> ∘ <a href="#a57e">Reflection Agent</a><br> ∘ <a href="#b633">Reflection Middleware</a><br> ∘ <a href="#af6d">Writer Agent</a><br> ∘ <a href="#65e9">Reflection Agent execution</a><br>· <a href="#e05c">Conclusion</a></p><h3>From More Agents Is All you Need to Reflexion</h3><p>The paper <a href="https://arxiv.org/abs/2402.05120"><em>More Agents Is All You Need</em></a> introduces <strong>Agent Forest</strong>, a method that runs the same prompt many times in parallel and picks the most common or most similar answer. It’s like asking a group of people the same question and trusting the group’s overall opinion to get a better result. This approach can highly improve the quality of the LLM’s answer, but we need to execute the same prompt many times. The output of the paper is very interesting, but not very useful in practise.</p><p>A more goal oriented way was introduced in the paper <a href="https://arxiv.org/pdf/2303.11366"><em>Reflexion: Language Agents with Verbal Reinforcement Learning</em></a><em>.</em> Within a feedback loop between two roles: a writer agent that tries to solve a task, and a critic agent that reviews the result and gives verbal feedback, the answer will be iteratively improved. This setup allows the agent to reflect on its own mistakes and use it to improve the final answer. This loop helps the agent get better without needing external training or multiple agents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p6TgxC8MpiuxlDjq.png" /><figcaption>Source: <a href="https://blog.langchain.com/reflection-agents/">https://blog.langchain.com/reflection-agents/</a></figcaption></figure><p>The <a href="https://blog.langchain.com/reflection-agents/">Langchain blog </a>introduces two different approaches of a reflection agent, I focus here on what they call <em>Basic Reflection</em>.</p><h3>Implement Reflection with AutoGen</h3><p>There are a couple of steps needed to implement a reflection agent with AutoGen:<br>Let’s start with the reflection agent itself. First, we start a critic agent. The critic agent collects feedback and interacts directly with the writer agent later on. The second step is to implement a middleware and add checker agents to it. The middleware is a concept in AutoGen that lets you stop the agent from running. The conversation will go like this: The writer agent sends a message to the critic agent, where the middleware will intercept the message, create the feedback with the checker agents, and finally the critic agent will provide the feedback back to the writer agent.</p><h4>Reflection Agent</h4><pre>private static IAgent CreateReflectionAgent(Kernel kernel, string grounding)<br>{<br>  // 1. initialize critic agent<br>  var critic = CreateCriticAgent(kernel);<br>  <br>  // 2. initialize middleware with checkers<br>  var middleware = new AutoGenReflectionMiddleware(<br>    CreateFactChecker(kernel, grounding),<br>    CreateStyleChecker(kernel)<br>    );<br><br>   // 3. return the reflection agent<br>   return critic.RegisterMiddleware(middleware);<br>}</pre><p>Let see the agent definitions:</p><p>The critic agent, which acts as a feedback aggregator.</p><pre>private static IAgent CreateAggregatorAgent(Kernel kernel)<br>{<br>    var criticAgent = new SemanticKernelAgent(<br>        kernel: kernel,<br>        name: &quot;Aggregator&quot;,<br>        systemMessage: &quot;&quot;&quot;<br>        You are a meta reviewer.<br>        You aggregate the feedback from the specialized criticers and you give a final feedback with clear suggestions to improve the content.<br>        Do not all new suggestions, only aggregate the provided ones and combined in a final feedback.<br>        You only provide feedback, do not rewrite the original message and please do not add it in your response either.<br>        &quot;&quot;&quot;,<br>        settings: new AzureOpenAIPromptExecutionSettings()<br>        {<br>            MaxTokens = 1024,<br>            Seed = 1,<br>        }<br>          );<br>    return criticAgent.RegisterMiddleware(new SemanticKernelChatMessageContentConnector());<br>}</pre><p>The Checker Agents, which will provide feedback within a certain domain:</p><pre>private static IAgent CreateFactChecker(Kernel kernel, string grounding)<br>{<br>    var criticAgent = new SemanticKernelAgent(<br>        kernel: kernel,<br>        name: &quot;FactChecker&quot;,<br>        systemMessage: $&quot;&quot;&quot;<br>        You are a FactChecker. Your job is to ensure that all facts mentioned in the article are accurate and derived from the provided source material.<br>        You will avoid any hallucinations and that all the facts are cross-checked with the source material.<br>        Please make sure that enumerations provided in the answer use the same number or character as in the provided sources.<br>        Make sure that there is no grounded content used, which is not cited!<br>        Please make sure that ciations use the structure [title], where title refers to the grounding source title property.<br>       <br>        Cross-check the content against the following source:<br>      <br>        {grounding}<br>      <br>        You only provide feedback, do not rewrite the original message and please do not add it in your response either.<br>        Make sure no invented information is included, and suggest corrections if any discrepancies are found.<br>        If all the facts and citations are valid response with &#39;FACTS NO SUGGESTIONS&#39; only and to not provide any feedback.<br>        &quot;&quot;&quot;,<br>        settings: new AzureOpenAIPromptExecutionSettings()<br>        {<br>            MaxTokens = 1024,<br>            Seed = 1,<br>        }<br>          );<br>    return criticAgent.RegisterMiddleware(new SemanticKernelChatMessageContentConnector());<br>}<br><br>private static IAgent CreateStyleChecker(Kernel kernel)<br>{<br>    var styleChecker = new SemanticKernelAgent(<br>        kernel: kernel,<br>        name: &quot;StyleChecker&quot;,<br>        systemMessage: &quot;&quot;&quot;<br>        You are a Style Checker. Your task is to ensure that the article is written in a proper style. <br>        Check that the writing style is positive, factual, informative and businesslike. <br>        The phrases should not be too complex, and the tone should be businesslike, yet polite.<br>        Provide suggestions to improve the style if necessary.<br>        You only provide feedback, do not rewrite the original message and please do not add it in your response either.<br>        If the style of the article is good and you do not want to provide feedback, return with &#39;STYLING NO SUGGESTIONS&#39;.<br>        &quot;&quot;&quot;,<br>        settings: new AzureOpenAIPromptExecutionSettings()<br>        {<br>            MaxTokens = 1024,<br>            Seed = 1,<br>        });<br><br>    return styleChecker.RegisterMiddleware(new SemanticKernelChatMessageContentConnector());<br>}</pre><h4>Reflection Middleware</h4><p>And finally the middleware to intercept the critic agent (feedback aggregator).</p><pre>using AutoGen.Core;<br><br>namespace ReflectionAgent;<br><br>public class AutoGenReflectionMiddleware : IMiddleware<br>{<br>    private readonly IAgent _factcheckerCriticAgent;<br>    private readonly IAgent _stylecheckerCriticAgent;<br><br>    public AutoGenReflectionMiddleware(<br>        IAgent factchecker,<br>        IAgent stylechecker)<br>    {<br>        _factcheckerCriticAgent = factchecker;<br>        _stylecheckerCriticAgent = stylechecker;<br>    }<br><br>    public string? Name =&gt; nameof(AutoGenReflectionMiddleware);<br><br>    public async Task&lt;IMessage&gt; InvokeAsync(<br>        MiddlewareContext context,<br>        IAgent agent,<br>        CancellationToken cancellationToken = default)<br>    {<br>        // get last message (from writer)<br>        var messageToReview = context.Messages.Last();<br><br>        var reviewPrompt = $&quot;&quot;&quot;<br>            Please provide feedback to the following article:<br>            {messageToReview.GetContent()}<br>            &quot;&quot;&quot;;<br><br>        // execute the two critic tasks in parallel<br>        var tasks = GetCriticTasks(reviewPrompt, cancellationToken);<br>        var criticHistory = await Task.WhenAll(tasks);<br><br>        // check if critic agents provided some feedback<br>        var critics = criticHistory.OfType&lt;TextMessage&gt;()<br>          .Where(x =&gt; !x.Content.Contains(&quot;NO SUGGESTIONS&quot;));<br><br>        if (!critics.Any())<br>        {<br>            // if not, send the AutoGen early terminate string as result<br>            return new TextMessage(Role.Assistant, &quot;[GROUPCHAT_TERMINATE]&quot;, agent.Name);<br>        }<br><br>        // otherwise, finally send the message to the critic agent istelf<br>        var result = await agent.GenerateReplyAsync(<br>               critics,<br>               context.Options,<br>               cancellationToken);<br><br>        return result;<br>    }<br><br>    private IList&lt;Task&lt;IMessage&gt;&gt; GetCriticTasks(string reviewPrompt, CancellationToken cancellationToken)<br>    {<br>        var inputMsg = new TextMessage(Role.User, reviewPrompt);<br><br>        return<br>            [<br>                CreateCriticTask(_factcheckerCriticAgent, inputMsg, cancellationToken),<br>                CreateCriticTask(_stylecheckerCriticAgent, inputMsg, cancellationToken),<br>            ];<br>    }<br><br>    private static Task&lt;IMessage&gt; CreateCriticTask(IAgent criticer, IMessage message, CancellationToken cancellationToken) =&gt;<br>        criticer.SendAsync(message, ct: cancellationToken);<br>}</pre><h4>Writer Agent</h4><p>Now let’s have a look at the writer agent:</p><pre> private static IAgent CreateWriterAgent(Kernel kernel)<br> {<br>     var writerAgent = new SemanticKernelAgent(<br>         kernel: kernel,<br>         name: &quot;Writer&quot;,<br>         systemMessage: &quot;You are an expert in answering questions about random facts.&quot;,<br>         settings: new AzureOpenAIPromptExecutionSettings()<br>         {<br>             MaxTokens = 1024,<br>         }<br>         );<br><br>     return writerAgent.RegisterMiddleware(new SemanticKernelChatMessageContentConnector());<br> }</pre><h4>Reflection Agent execution</h4><p>It’s crunch time! 🥊 Stick everything together and run the reflection agent🤖<br> There is a method <strong>SendAsync</strong> on the <strong>IAgent </strong>interface of AutoGen, where we can provide a <strong>receiver </strong>and <strong>maxRound</strong>. This will start a round robin group chat. The first message will be sent to the writer to answer the questions. The writer’s message will then be sent back to the reflection agent (the critic agent with middleware). The conversation will keep going until it gets the message that says “[GROUPCHAT_TERMINATE]” or until the group chat has sent the maximum number of messages that it can.</p><pre>public static async Task&lt;string&gt; CreateAndRunReflectionAgentAsync(<br>    string input,<br>    string grounding,<br>    int numberOfCriticRounds,<br>    Kernel kernel)<br>{<br>    var maxRounds = numberOfCriticRounds * 2 + 1;<br>    var writerAgent = CreateWriterAgent(kernel);<br>    var reflectionAgent = CreateReflectionAgent(kernel, grounding);<br><br>    var prompt = $&quot;&quot;&quot;<br> Please answer the following questions with the provided source or your history:<br><br> {input}<br> <br> ## Source ##<br> {grounding}<br> ## End ##<br><br> Make sure to not forget the citations!<br> &quot;&quot;&quot;;<br><br>    // starts a round robin chat group, with odd number of rounds<br>    // means n critic rounds and n+1 writer rounds<br>    var conversation = await reflectionAgent.SendAsync(<br>        message: prompt,<br>        receiver: writerAgent,<br>        maxRound: maxRounds)<br>        .ToListAsync();<br><br>    var finalResult = ConversationEarlyAbort(conversation, maxRounds)<br>        ? conversation[^2] // take 2nd last msg, last one is abort message<br>        : conversation[^1];// take last msg from writer<br><br>    return finalResult.GetContent()!;<br>}</pre><p>Here is an example, how you can run it in a console app with SemanticKernel and AzureOpenAI:</p><pre>var config = new ConfigurationBuilder()<br>    .AddUserSecrets&lt;Program&gt;()<br>    .Build();<br><br>// Prepare and build kernel<br>var builder = Kernel.CreateBuilder();<br><br>builder.Services.AddLogging(c =&gt; c.AddDebug().SetMinimumLevel(LogLevel.Trace));<br><br>builder.Services.AddAzureOpenAIChatCompletion(<br>    config[&quot;OpenAI:ModelId&quot;],<br>    config[&quot;OpenAI:Endpoint&quot;],<br>    config[&quot;OpenAI:ApiKey&quot;]!);<br><br>var kernel = builder.Build();<br><br>var grounding = ReflectionAgentHelper.GetGrounding();<br><br><br>var result = await ReflectionAgentHelper.CreateAndRunReflectionAgentAsync(<br>    &quot;What is the national animal of Scotland?.&quot;,<br>    grounding,<br>    2,<br>    kernel);</pre><p>The following packages installed:</p><pre>  &lt;PackageReference Include=&quot;AutoGen&quot; Version=&quot;0.2.3&quot; /&gt;<br>  &lt;PackageReference Include=&quot;Microsoft.Extensions.Configuration&quot; Version=&quot;9.0.8&quot; /&gt;<br>  &lt;PackageReference Include=&quot;Microsoft.Extensions.Configuration.UserSecrets&quot; Version=&quot;9.0.8&quot; /&gt;<br>  &lt;PackageReference Include=&quot;Microsoft.Extensions.Logging.Debug&quot; Version=&quot;9.0.8&quot; /&gt;<br>  &lt;PackageReference Include=&quot;Microsoft.SemanticKernel&quot; Version=&quot;1.64.0&quot; /&gt;</pre><p><a href="https://microsoft.github.io/autogen-for-net/">AutoGen documentation for dotnet.</a></p><h3>Conclusion</h3><p>That’s it! We have implemented an Agentic AI design pattern 🥳 Reflection helpes in my opinion a lot to improve overall answer quality, citing more relevant documents and get rid of unfinished sentences completely. Give it a try!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5ce1fb36142" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/llm-apps-with-net-implement-a-reflection-agent-with-autogen-and-semantickernel-e5ce1fb36142">LLM Apps with .Net: Implement a Reflection Agent with AutoGen and SemanticKernel</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Apps in .NET: Advanced Search Options for Azure OpenAI — On your Data]]></title>
            <link>https://medium.com/data-science-collective/llm-apps-in-net-advanced-search-options-for-azure-openai-on-your-data-8c33fcadaf83?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c33fcadaf83</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[semantic-kernel]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Wed, 20 Aug 2025 20:47:39 GMT</pubDate>
            <atom:updated>2025-08-21T11:18:59.741Z</atom:updated>
            <content:encoded><![CDATA[<h3>LLM Apps in .NET: Advanced Search Options for Azure OpenAI — On your Data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NqiOywfF9kexSS7y" /><figcaption>Photo by <a href="https://unsplash.com/@rocinante_11?utm_source=medium&amp;utm_medium=referral">Mick Haupt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In my previous post (<a href="https://medium.com/c-sharp-programming/llm-apps-in-net-implement-rag-on-azure-in-under-10-minutes-d8b5b500ea1b">LLM Apps in .NET: Implement RAG on Azure in under 10 minutes</a>), I demonstrated how straightforwardit is to set up Retrieval-Augmented Generation (RAG) using .NET, Semantic Kernel, and Azure AI Search 🥳. Now, let’s take things a step further.</p><p>When it comes to RAG, the retrieval step is arguably the most critical. If your system fails to surface the right chunks of information, the LLM doesn’t even get a fair shot at producing a correct or useful answer.</p><p>Yet, in many developer discussions, the focus tends to drift toward which model to use or which shiny new agentic pattern to implement. While those are exciting topics, I’d argue it’s time to zoom out and revisit the fundamentals: your use case, your chunking strategy, and — most importantly — your retrieval strategy.</p><p>In this article, we’ll explore the various search options and advanced features of Azure AI Search that can enhance the success of your RAG solution.</p><p><strong>Related Articles<br></strong><a href="https://medium.com/@cedric.mendelin/llm-apps-with-net-tools-and-frameworks-dd3812e4df61">LLM Apps with .NET: Tools and Frameworks</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-in-net-implement-rag-on-azure-in-under-10-minutes-d8b5b500ea1b">LLM Apps in .NET: Implement RAG on Azure in under 10 minutes </a><br><a href="https://medium.com/c-sharp-programming/llm-apps-with-net-evaluation-with-microsoft-extensions-ai-evaluation-meai-a593fe122bc5">LLM Apps with .NET: Evaluation with MEAI.Evaluation</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-with-net-automate-evaluation-with-azuredevops-550776b28388">LLM Apps with .NET: Automate Evaluation with AzureDevOps</a></p><p><strong>Table of Content</strong></p><p>· <a href="#05b7">Why is retrieval so hard?</a><br> ∘ <a href="#250b">Vector Representations</a><br>· <a href="#380d">Different Retrieval Approaches</a><br> ∘ <a href="#81dc">Keyword search</a><br> ∘ <a href="#564a">Vector Search</a><br> ∘ <a href="#4c1b">Hybrid Search</a><br>· <a href="#5a47">Advanced Search Capabilities</a><br> ∘ <a href="#ee6c">Semantic Reranking</a><br> ∘ <a href="#bc5f">Filters</a><br>· <a href="#331e">Summary</a><br>· <a href="#8dfb">References:</a></p><h3>Why is retrieval so hard?</h3><p>You might be thinking:</p><p><em>“I just want to get the relevant documents — how hard can it be?”</em></p><p>Well, it turns out that it’s very hard (and painful for the developer). During the retrieval step in RAG, our aim is to extract the most relevant documents based on the user’s input and the chat history. Sounds simple, right? However, deriving a search query for our AI Search service that retrieves the correct documents is a complex challenge!</p><ol><li><strong>Query Understanding and Reformulation:</strong> Deriving an effective query from the user’s input is crucial. Poorly formulated queries can lead to irrelevant or low-quality document retrieval, reducing the overall performance of the RAG system. If you are using the Azure OpenAI on Your Data — implementation, you do not need to implement that step by yourself.</li><li><strong>Document Limitation</strong>: Language models have a limited context window size (e.g. 16k or 32k tokens, or even larger), which restricts the amount of retrieved content that can be passed to the generator. Furthermore, LLMs tend to hallucinate less when fewer documents and context are provided. Therefore, the number of documents should be limited; I have had good results with a value between 5 and 10.</li><li><strong>Overlapping or Redundant Content:</strong> Many enterprise documents repeat the same information in slightly different ways. Without smart filtering or reranking, you risk retrieving near-duplicates that waste valuable context space.</li><li><strong>Poor Document Structure:</strong>PDFs are designed to be read as one piece, so it can be very difficult to split them into smaller documents. Poor document structure and fancy layouts with tables, references, etc. are the most challenging aspects during chunking. If your chunking strategy doesn’t preserve meaning, you’ll end up with fragments that are either too vague or too specific, meaning you’ll miss relevant aspects of your data.</li></ol><h4>Vector Representations</h4><p>Unlike traditional keyword search, where you match exact terms, RAG relies on semantic search — understanding the <em>meaning</em> behind the user’s words. This is where vector representations come into play — numerical encodings of text that capture its semantic meaning.</p><p>The process is rather simple in principle. We have data for which it is difficult to find a good similarity measure (because traditional metrics either make no sense or cannot be computed — for example, we cannot calculate cosine similarity for two strings). So, how can we compare two values in our dataset? Well, we can’t — or not with the required level of quality. This is where embedding models come in. We map our data to an embedding space, and hopefully the similarity measure in this space will capture the similarity of our original data.</p><p>So how it works, step-by-step:</p><ol><li><strong>Embedding Model:</strong> A model (like OpenAI’s text-embedding-3-largetransforms text into a high-dimensional vector.</li><li><strong>Vectorized Content</strong>: Each document chunk is embedded into a vector space and stored in a vector database or search index.</li><li><strong>Query Embedding</strong>: The user’s input (plus chat history) is also embedded into a vector.</li><li><strong>Similarity Search</strong>: During retrieval , the system compares the query vector to the stored vectors and retrieves the most similar ones — those that are semantically closest. Cosine Similarity is often used as a similarity measure, but you could also use different ones (which derive better results in your domain).</li></ol><p>Our data is not limited to text alone. Some embedding models are multimodal and support different types of input, such as text, audio, video and images, which all end up in the same vector space. To achieve the best results in a multimodal environment, I would strongly recommend AI enrichment (for example, describe an image in text and use the description during your retrieval step).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T3pHHOFXKRnED34HHLu8VA.png" /><figcaption>Source: <a href="https://weaviate.io/blog/how-to-choose-an-embedding-model">https://weaviate.io/blog/how-to-choose-an-embedding-model</a></figcaption></figure><h3>Different Retrieval Approaches</h3><p>So, during the search process, we can make use of vector representation🥳. As I demonstrated in my previous post, setting up RAG with Azure OpenAI is straightforward. But let’s take a look at the different search approaches one by one, and see how to configure them on the Azure OpenAI-On-Your-Data endpoint.</p><h4>Keyword search</h4><p>This is the most traditional form of search. It works by scanning your documents for exact matches to the words or phrases in the user’s query. It uses techniques like term frequency (how often a word appears) and inverse document frequency (how unique a word is across documents) to rank results. It’s fast and effective when users know the exact terms they’re looking for.</p><pre>// setup the promptsettings for interacting with the on your data endpoint<br>var azureSearchEndpoint = &quot;&quot;;<br>var azureSearchKey = &quot;&quot;;<br>var azureSearchIndexName = &quot;&quot;;<br><br>var promptSettings = new AzureOpenAIPromptExecutionSettings<br>{<br>    AzureChatDataSource = new AzureSearchChatDataSource<br>    {<br>        Endpoint = new Uri(azureSearchEndpoint),<br>        Authentication = DataSourceAuthentication.FromApiKey(azureSearchKey),<br>        IndexName = azureSearchIndexName,<br>        TopNDocuments = 10,<br>        QueryType = DataSourceQueryType.Simple,<br>    },<br>};</pre><p>✅ Fast and efficient<br>✅ Easy to implement</p><p>❌ Doesn’t understand synonyms or context</p><h4>Vector Search</h4><p>This method uses embeddings to understand the meaning behind a query. Both the query and the documents are converted into vectors, and the system finds documents whose vectors are closest to the query vector using similarity measures like cosine similarity. This allows it to retrieve relevant content even if the wording is different.</p><pre>var promptSettings = new AzureOpenAIPromptExecutionSettings<br>{<br>    AzureChatDataSource = new AzureSearchChatDataSource<br>    {<br>        ...<br>        QueryType = DataSourceQueryType.Vector,<br>        VectorizationSource = DataSourceVectorizer.FromDeploymentName(embeddingModelId),<br>    },<br>};</pre><p>✅ Better understands context<br>✅ Great for natural language queries<br>✅ Can overcome different wording</p><p>❌ Requires embedding models and vector stores</p><h4>Hybrid Search</h4><p>Hybrid search combines keyword and vector search to leverage the strengths of both. It runs both searches in parallel and merges the results, often using a scoring system to balance between exact matches and semantic relevance. This improves both recall (finding more relevant documents) and precision (ranking them well).</p><pre>var promptSettings = new AzureOpenAIPromptExecutionSettings<br>{<br>    AzureChatDataSource = new AzureSearchChatDataSource<br>    {<br>        ...<br>        QueryType = DataSourceQueryType.VectorSimpleHybrid,<br>        VectorizationSource = DataSourceVectorizer.FromDeploymentName(embeddingModelId),<br>    },<br>};</pre><p>✅ Improves both recall (finding more relevant documents) and precision (ranking them well)<br>✅ Great for natural language queries<br>✅ Can overcome different wording</p><p>❌ More resource-intensive</p><h3>Advanced Search Capabilities</h3><p>The Azure AI Search service has various capabilities, including Synonym Maps, Scoring Profiles, Query Rewriting, AI Enrichment and Agentic Search. Depending on your use case, applying one or more of these capabilities may be a good option. In my opinion, Semantic Reranking is by far the most powerful advanced search capability. So let’s take a closer look at what it is exactly.</p><h4>Semantic Reranking</h4><p>This is an advanced version of hybrid search. After retrieving results using both the keyword and vector methods, a semantic ranker is applied to refine the ranking of the documents. This ranker is a deep learning model that first evaluates the semantic similarity between the retrieved documents and the query.</p><p>You need to activate this feature on a search service level and create a semantic configuration on your index.</p><ol><li>In the Azure Portal, go to your Search service -&gt; Settings -&gt; Semantic Ranker and activate it</li><li>On your Search Index, add a Semantc Configuration:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*Q2XsY5GtYNoEuj-_I9n71w.png" /></figure><p>Now you can use it in your <em>promptSettings</em>.</p><pre>var promptSettings = new AzureOpenAIPromptExecutionSettings<br>{<br>    AzureChatDataSource = new AzureSearchChatDataSource<br>    {<br>        ...<br>        VectorizationSource = DataSourceVectorizer.FromDeploymentName(embeddingModelId),<br>        QueryType = DataSourceQueryType.VectorSemanticHybrid,<br>        SemanticConfiguration = &quot;semantic-config&quot;<br>    },<br>};</pre><p>✅ More accurate and context-aware ranking<br>✅ Improves user satisfaction by showing the most relevant results first</p><p>❌ Adds additional costs</p><h4>Filters</h4><p>Filters are an easy yet powerful way to improve your retrieval process. This is particularly useful when your AI Search index consists of a large number of documents. I recommend using them, especially when it is obvious which subset of your data needs to be searched.</p><pre>var promptSettings = new AzureOpenAIPromptExecutionSettings<br>{<br>    AzureChatDataSource = new AzureSearchChatDataSource<br>    {<br>        ...<br>        Filter = &quot;category eq &#39;Food&#39;&quot;<br>    },<br>};</pre><h3>Summary</h3><p>I showed you how you can improve your retrieval step by applying hybrid search and semantic reranking. I strongly recommend testing both of these methods for your solution. In my last project, we systematically applied LLM evaluation and improved the accuracy of retrieving relevant documents from 45% using plain vector search to 80% using hybrid search with reranking.</p><h4>References</h4><p><a href="https://learn.microsoft.com/en-us/azure/ai-foundry/openai/concepts/use-your-data?tabs=ai-search%2Ccopilot#search-types">[1] Azure OpenAI — On your Data — Search Types</a><br><a href="https://learn.microsoft.com/en-us/azure/ai-foundry/openai/concepts/use-your-data?tabs=ai-search%2Ccopilot#index-field-mapping">[2] Azure OpenAI — On your Data — Index field mapping</a><br><a href="https://learn.microsoft.com/en-us/azure/search/semantic-search-overview">[3] Semantic Ranking in Azure AI Search</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c33fcadaf83" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science-collective/llm-apps-in-net-advanced-search-options-for-azure-openai-on-your-data-8c33fcadaf83">LLM Apps in .NET: Advanced Search Options for Azure OpenAI — On your Data</a> was originally published in <a href="https://medium.com/data-science-collective">Data Science Collective</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vibe Coding: Implementing my first feature with GitHub Copilot in agent mode]]></title>
            <link>https://medium.com/c-sharp-programming/vibe-coding-implementing-my-first-feature-with-github-copilot-in-agent-mode-8569fa813eaa?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8569fa813eaa</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Mon, 09 Jun 2025 20:23:53 GMT</pubDate>
            <atom:updated>2025-06-18T19:41:04.955Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BAodggpdwNruil_lrpnxqQ.jpeg" /><figcaption>Source: Pexels free image (by <a href="https://www.pexels.com/@shvetsa/">shvetsa</a>)</figcaption></figure><p>Another buzzword that’s really caught on recently is ‘vibe coding’. Well, I somehow get tired of these buzzwords, but ok, lets vibe code today🚀🤖</p><p>I use GitHub Copilot as my coding assistant. It’s very effective, and I especially like that, as a senior developer, it allows you to get into new domains and programming languages much faster. In February of this year, agent mode was released in the stable version of VS Code, and I finally had the opportunity to test it on a complete feature. By the way, agent mode just got introduced to Visual Studio as well: <a href="https://learn.microsoft.com/en-us/visualstudio/ide/copilot-agent-mode?view=vs-2022">Blog Post</a>, but I did not yet had the time to test it. So, let’s take a look at the project architecture and the features I want to implement, as well as how well Agent mode can support me with them.</p><h3>Project Architecture</h3><p>It is a simple chatbot application using C# with ASP.Net on the back end and TypeScript with React on the frontend (using React Material UI), implemented using the Backend-for-Frontend pattern. The solution also contains Azure DevOps pipelines and IaC code with Terraform.</p><h4>Development IDE</h4><p>I use Visual Studio for backend code implementation and Visual Studio Code for frontend coding. The source structure looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*ERSrxSJeqGsbDljLN3TlWA.png" /><figcaption>App Folder structure</figcaption></figure><h3>Feature to be implemented — Feedback</h3><p>As I mentioned, the application is a simple chatbot. It already has an implemented persistent chat feature, for which we use CosmosDB to store conversation and user information. User feedback is crucial, and we wanted to provide an easy option for users. The feature we wanted to implement was therefore defined as follows:</p><ul><li>User can give Feedback via the conversation chat bubbles, either positive or negative represented by 👍👎 buttons</li><li>In a opening modal, the user can add a description and some ratings from 1–5 about</li><li>Feedback will be stored in CosmosDB</li></ul><h4>Estimation</h4><p>The feature looked rather straightforward and essentially involved the following steps:: creating a new CosmosDB container with Terraform; adding a backend controller and repository; and implementing the functionality in the UI to add a button to the input box and a modal to add the feedback content. As I am already familiar with the solution and we have a similar component in place, I would estimate that it would take me 4–6 hours to implement it myself, based on my experience and instinct.</p><h3>Let’s vibe code today</h3><p>From my experience, GitHub Copilot works much better in Visual Studio Code than in Visual Studio. Therefore, after opening my Visual Studio solution and the Client folder in Visual Studio Code, I open the root folder in Visual Studio Code as well, and started vibe coding from there.</p><p>First of all, lets switch GitHub Copilot to agent mode:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*edEiU0auH0i4aEdxU30toQ.png" /></figure><h4>Instruction</h4><p>I began by providing a description of my desired outcome, along with some implementation suggestions (e.g. implement in this class, use this React MUI component). The prompt looked like this:</p><blockquote>I want to add a feedback mechanism in the ui. It should be a thumb-up / thumb-down button in the ChatBubbleSecondaryActions. The button should open a Modal, where you can add some textfield (multiline) detailed feedback. The feedback should then be persistent in the already available cosmos db. Please create a new container called Feedback and add the Feeback with the user who created it and save it.</blockquote><h4>First result</h4><p>I didn’t provide any instructions regarding the backend implementation, so it’s not surprising that it wasn’t implemented. However, the Terraform code was spot on, and the UI implementation was not great to begin with. But it was more a problem with my prompt. I wanted a dialog, not a modal, to be implemented.</p><h4>Keeping Changes in Context</h4><p>Once the agent has added or changed some code in agent mode, it will be visible over the input field. You can then choose to keep or undo the changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*ax90bxwNTOOSRJ_i1oVNDA.png" /></figure><p>This will help you to keep track of the changes and interact with the following prompts in a fairly straightforward way. That worked surprisingly well. Furthermore, when you select the file, it will open and the changes will be clearly displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*lA-aN_Ixh9E4Ogz6nBG5Yw.png" /></figure><h4>But this is not buildable!</h4><p>I felt that code generation was not working particularly well for my backend solution. I already had a similar service and repository implemented. After mentioning this in the conversation, the code was generated in the right direction. However, there were quite a few scenarios where the code could not be built.</p><ul><li>Creating a class implementing an interface, which does not exist and was not created either</li><li>Derive non existing base-class</li><li>Completely messed up dependency injection registration of services (created non buildable class in super wrong namespace)</li><li>CosmosDB serialization -&gt; was using Newtonsoft and not System.Text.Json</li></ul><p>After a couple of prompts, I managed to get the UI working. For the backend, I ended up in given super precise instruction and finally, the job was completed (or I implemented some of the code by myself).</p><h4>Review, Review, Review</h4><p>Overall, the process of developing code has changed somewhat. In fact, I was doing more code reviews than development, which I find more exhausting and less enjoyable. First, you create a prompt, then you review what has been created. Then you create another prompt to describe more specifically what you want and do another review. A couple of times, I gave up after a few prompts and implemented the part myself.</p><h3>Get the job done</h3><p>In the end, I could accomplish my goal — let’s have a look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*zhh1ShVKmP6qrgf0eopqaA.png" /><figcaption>Final result</figcaption></figure><p>The PR was ready in under 2 hours, the functionality was working and and the feature was doing what I expected.GitHub Copilot generated Terraform, TypeScript and C# code. I felt it worked better with the front-end part in TypeScript than with the back-end part in C#.</p><h3>Conclusion</h3><p>I saved time — I should be happy, right? As a developer, you experience these small, awesome moments when you finish writing your code, see it running, and realise that everything worked as expected. I guess everyone who creates something knows what I’m talking about. But you know what? I missed that moment completely. In my “vibe” of reviewing and blaming the coding assistant, I completely overlooked it. The code was working and I had saved time, but I had completely missed the best part. I ask myself: is this the new way of working, and will we evolve as developers and get those tiny moments back, even with vibe coding? I’m not sure. What do you think?</p><p>By the way, I will reuse the agent mode 100%, it worked pretty good and I already implemented a few other features with it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8569fa813eaa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/c-sharp-programming/vibe-coding-implementing-my-first-feature-with-github-copilot-in-agent-mode-8569fa813eaa">Vibe Coding: Implementing my first feature with GitHub Copilot in agent mode</a> was originally published in <a href="https://medium.com/c-sharp-programming">Any Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Apps in .NET: Implement RAG on Azure in under 10 minutes]]></title>
            <link>https://medium.com/c-sharp-programming/llm-apps-in-net-implement-rag-on-azure-in-under-10-minutes-d8b5b500ea1b?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8b5b500ea1b</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[semantic-kernel]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Mon, 26 May 2025 11:26:10 GMT</pubDate>
            <atom:updated>2025-08-30T18:45:33.693Z</atom:updated>
            <content:encoded><![CDATA[<h3>LLM Apps in .NET: Implement RAG on Azure in under 10 minutes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cTSJ2xnvEeUg4PXlMWkaFw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dengxiangs?utm_source=medium&amp;utm_medium=referral">Choong Deng Xiang</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For a .NET developer, building your own RAG application can be challenging. While there are many libraries and frameworks available for Python, are there any good solutions for .NET as well? Yes, there are! Semantic Kernel, Azure AI Search and Azure OpenAI are powerful components that will enable you to create a RAG application in no time!</p><p>In this article, I will show you how to consume an Azure AI Search index with Semantic Kernel and Azure OpenAI. This article does not focus on chunking or setting up resources, but rather on consuming an existing AI Search index and deployed Azure OpenAI model endpoints.</p><h4>Related Articles</h4><p><a href="https://medium.com/@cedric.mendelin/llm-apps-with-net-tools-and-frameworks-dd3812e4df61">LLM Apps with .NET: Tools and Frameworks</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-in-net-implement-rag-on-azure-in-under-10-minutes-d8b5b500ea1b">LLM Apps in .NET: Implement RAG on Azure in under 10 minutes</a> (this story)<br><a href="https://medium.com/data-science-collective/llm-apps-in-net-advanced-search-options-for-azure-openai-on-your-data-8c33fcadaf83">LLM Apps in .NET: Advanced Search Options for Azure OpenAI — On your Data</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-with-net-evaluation-with-microsoft-extensions-ai-evaluation-meai-a593fe122bc5">LLM Apps with .NET: Evaluation with MEAI.Evaluation</a><br><a href="https://medium.com/c-sharp-programming/llm-apps-with-net-automate-evaluation-with-azuredevops-550776b28388">LLM Apps with .NET: Automate Evaluation with AzureDevOps</a></p><h4>Table of Content</h4><p>· <a href="#25fa">Retrieval-Augmented-Generation (RAG)</a><br>· <a href="#d865">Azure Open AI</a><br> ∘ <a href="#d386">Model Availability &amp; Deployment Types</a><br>· <a href="#8a51">Azure AI Search</a><br>· <a href="#fba1">Semantic Kernel</a><br>· <a href="#cbcf">Brining everything together — Azure OpenAI on your data</a><br> ∘ <a href="#4dd0">Console App</a><br>· <a href="#088e">Conclusion</a><br>· <a href="#fe40">References</a></p><h3>Retrieval-Augmented-Generation (RAG)</h3><p>Interacting with an LLM can be frustrating; they don’t know the current time and can’t access your data. RAG is a technique that brings your data as additional context to your LLM prompts. It retrieves relevant documents from a database or vector store and uses them to generate domain-specific answers, improving the quality of the content produced.<br>As a .NET developer, I enjoy creating RAG applications comprising the following components:</p><ul><li>ASP .NET Core API</li><li>Fronted technology of your choice (React or Blazor for me)</li><li>Azure OpenAI for hosting your LLM</li><li>Azure AI Search (search enginge and vector database)</li><li>SemanticKernel Framework in C# (bringing everything together)</li></ul><p>If you call yourself a .NET developer, you should know how to develop an API and a chat front-end; this should be straightforward. There are <a href="https://github.com/Azure-Samples/azure-search-openai-demo-csharp">samples </a>out there, and Microsoft has just started publishing its first <a href="https://devblogs.microsoft.com/dotnet/announcing-dotnet-ai-template-preview2/">AI templates for Visual Studio</a> (using MEAI, not SK). But let’s take a look at how we can interact with the LLM in .NET.</p><h3>Azure Open AI</h3><p>An LLM requires significant computing power to run, so it is preferable to use a PaaS solution rather than host it yourself. Azure OpenAI offers a pay-as-you-go service for using OpenAI models, which makes it really easy to use LLMs. You just have to:</p><ol><li>Create an <em>Azure AI Services</em> (or dedicated Azure OpenAI) service in the Azure portal.</li><li>Deploy a model to your service.</li><li>Deploy an embedding model to your service.</li></ol><p>You can then access the Azure OpenAI service using the key provided in the Azure portal.</p><h4>Model Availability &amp; Deployment Types</h4><p>Azure OpenAI offers flexible hosting options that can be tailored to suit different business needs and usage patterns. Although all deployments support the same inference operations, there are significant differences in terms of billing, scalability and performance. When designing your solution, you will need to make two crucial decisions:</p><ol><li>Data processing location</li><li>Call volume</li></ol><p>Three deployment types are available: <strong>standard</strong>, <strong>provisioned </strong>and <strong>batch</strong>. With standard deployments, you only pay for what you use with a pay-per-call billing model, though models and throughput may be limited by region. With provisioned deployments, you can specify the required throughput. The service then allocates the necessary processing capacity in provisioned throughput units (PTUs), which vary by model-version pair. Batch deployments are optimised for large-scale processing tasks, allowing asynchronous groups of requests with a separate quota and 24-hour turnaround at 50% less cost.</p><p>Depending on the deployment chosen, you can match your workload with your data processing needs by selecting an Azure <strong>region</strong>, a Microsoft-specified <strong>data zone</strong> or a <strong>global </strong>processing option. Data stored at rest remains in the Azure region in which your service is located. However, data may be processed for inferencing in the selected location (globally, in a data zone or in a specific region).</p><p>Please refer to the documentation for a more detailed description of the <a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/deployment-types">deployment types</a>. You can also view the <a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/deployment-types">model availability</a> per deployment type and region.</p><h3>Azure AI Search</h3><p>Azure AI Search is Azure’s search and vector database service. It supports advanced search technologies, including vector, full-text and hybrid searches. It has enterprise-grade features such as semantic reranking and scoring profiles, as well as indexers on the pipeline side. If you want to build a custom RAG solution with C# on Azure, Azure AI Search is currently the best option. I must say, the service is rather expensive. However, for a productive environment and to use these advanced features, it’s definitely worth it!</p><p><strong>Index</strong>: The index contains your content. It is defined by a schema and is saved to the search service.</p><p><strong>Chunk: </strong>The index contains multiple documents, which are also often referred to as chunks.</p><p><strong>Index fields:</strong> The index schema contains multiple fields with different data types and attributes. These attributes determine the functionality of the field (searchable, filterable, sortable, facetable, key, retrievable). You cannot change the attributes after index creation, so make sure to defined them accordingly from the beginning.</p><p><strong>Vector Store: </strong>A field can be also be a collection, e.g: “Collection(Edm.Single)”, which would indicate a vector field. It is defined in the same schema , but is stored internally in a different way.</p><p><strong>Query processing:</strong> Running a search statement is referred to as query processing. It is a complex process, but there are many different ways to customize it for our use cases, such as filtering, query rewriting, reranking and many more. Let’s have a look at the core concepts — . Firstly, we can define the query type as <strong>full-text</strong>, <strong>vector </strong>or hybrid search. In very simple terms: Full-text searches string fields, vector searches vector fields, and hybrid searches combine the two. In a hybrid search, both approaches are executed in parallel and the results are aggregated at the end. <strong>I highly recommend hybrid search in most scenarios!</strong></p><p><strong>Reranking</strong>: During query processing, a score is calculated for each document and the best results are returned, depending on how many results you are asking for. With <a href="https://learn.microsoft.com/en-us/azure/search/semantic-search-overview">Reranking</a>, we introduce a two-stage search approach. First, the score of the documents is calculated, and then the second stage refines the original scoring based on language understanding and semantic similarity. This process can only refine the documents retrieved in the first stage, so it is important to ensure that the number of documents retrieved in the first stage is maximised.</p><p>The Azure AI Search documentation is a great place to start if you want to learn more about these concepts. This article does not cover everything. During Microsoft Build, a new query type was introduced: <a href="https://learn.microsoft.com/en-us/azure/search/search-agentic-retrieval-concept">Agentic Retrieval</a>, which handles the entire retrieval process in the RAG scenario. You can also provide context to achieve the most accurate results. This sounds highly promising.</p><h3>Semantic Kernel</h3><p>Semantic Kernel is an open-source SDK from Microsoft that enables .NET developers to integrate AI capabilities into their applications using LLMs. It provides a middleware which works as an abstraction lay for interaction with different LLMs and services. See a more detailed explanation in my former blogpost <a href="https://medium.com/@cedric.mendelin/llm-apps-with-net-tools-and-frameworks-dd3812e4df61">LLM Apps with .NET: Tools and Frameworks</a>.</p><h3>Brining everything together — Azure OpenAI on your data</h3><p>Overall, implementing RAG is straightforward. Just get some relevant documents and put them in your LLM prompt. Easy, right? Well… Implementing RAG for production use and tuning it to your domain and use case is extremely difficult.</p><p>Azure OpenAI offers a single endpoint for providing RAG implementations based on Azure OpenAI models and Azure AI Search as a grounding source. <a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/use-your-data?tabs=ai-search%2Ccopilot">Azure OpenAI — On Your Data</a> — The endpoint then takes care of the retrieval and generation steps and returns the result with metadata showing which documents from Azure AI Search were consumed. If you’re building your own custom solution with C#, I think this is the best way to get started. With Semantic Kernel, it’s as easy as setting up Prompt Configuration and providing it to the chat completion.</p><h4>Step — by — step Guide: Console App</h4><p>Let’s see how we can implement the approach in a console App:</p><p>Create a new dotnet console app:</p><pre>dotnet new console<br><br>dotnet add package Microsoft.SemanticKernel<br>dotnet add package Microsoft.SemanticKernel.Connectors.AzureAISearch</pre><p>Now let’s take the Semantic Kernel getting started example and update it slightly. The only change required is to provide a different promptSettings to our IChatCompletionService. The AzureOpenAI — on your data endpoint can be mapped using the <a href="https://learn.microsoft.com/en-us/dotnet/api/azure.ai.openai.chat.azuresearchchatdatasource?view=azure-dotnet">AzureSearchChatDataSource</a> configuration, where we define the search endpoint (url and authentication), as well as how the search will be executed.</p><pre><br>// Import packages<br>using Microsoft.Extensions.DependencyInjection;<br>using Microsoft.SemanticKernel;<br>using Microsoft.SemanticKernel.ChatCompletion;<br>using Microsoft.SemanticKernel.Connectors.OpenAI;<br>using Microsoft.SemanticKernel.Connectors.AzureOpenAI;<br><br>// Populate values from your OpenAI deployment<br>var modelId = &quot;&quot;;<br>var endpoint = &quot;&quot;;<br>var apiKey = &quot;&quot;;<br>var embeddingModelId= &quot;&quot;;<br><br>// Create a kernel with Azure OpenAI chat completion<br>var kernel = Kernel.CreateBuilder()<br>  .AddAzureOpenAIChatCompletion(modelId, endpoint, apiKey)<br>  .AddAzureOpenAITextEmbeddingGeneration(embeddingModelId, endpoint, apiKey)<br>  .Build();<br><br>var chatCompletionService = kernel.GetRequiredService&lt;IChatCompletionService&gt;();<br><br>// setup the promptsettings for interacting with the on yourdata endpoint<br>var azureSearchEndpoint = &quot;&quot;;<br>var azureSearchKey = &quot;&quot;;<br>var azureSearchIndexName = &quot;&quot;;<br><br>var promptSettings = new AzureOpenAIPromptExecutionSettings<br>{<br>    AzureChatDataSource = new AzureSearchChatDataSource<br>    {<br>        Endpoint = new Uri(azureSearchEndpoint),<br>        Authentication = DataSourceAuthentication.FromApiKey(azureSearchKey),<br>        IndexName = azureSearchIndexName,<br>        TopNDocuments = 10,<br>        InScope = false,<br>        QueryType = DataSourceQueryType.VectorSimpleHybrid,<br>        VectorizationSource = DataSourceVectorizer.FromDeploymentName(embeddingModelId),<br>    },<br>};<br><br>// Create a history store the conversation<br>var history = new ChatHistory();<br><br>// Initiate a back-and-forth chat<br>string? userInput;<br>do {<br>    // Collect user input<br>    Console.Write(&quot;User &gt; &quot;);<br>    userInput = Console.ReadLine();<br><br>    // Add user input<br>    history.AddUserMessage(userInput);<br><br>    // Get the response from the AI<br>    var result = await chatCompletionService.GetChatMessageContentAsync(<br>        history,<br>        executionSettings: promptSettings,<br>        kernel: kernel);<br><br>    // Print the results<br>    Console.WriteLine(&quot;Assistant &gt; &quot; + result);<br><br>    // Add the message from the agent to the chat history<br>    history.AddMessage(result.Role, result.Content ?? string.Empty);<br>} while (userInput is not null);<br><br></pre><p>That’s it! We implemented a RAG chat client with hybrid search with just these few lines of code. The endpoint expects your search index fields to be named in a certain way. You can customize them by setting the <em>FieldMappings </em>parameter in the <em>AzureSearchChatDataSource </em>configuration. There are also other parameters related the retrieval Step with Azure AI Search (<em>Filter, Strictness, MaxSearchQueries, InScope, SemanticConfiguration</em>), have a look at the documentation and think about how you want to design the search.</p><h3>Conclusion</h3><p>With the AzureOpenAI — on your data endpoint, setting up a RAG implementation within Azure services is super simple. If you are starting your own implementation with C#, I would always recommend starting with this endpoint and the straightforward implementation with Semantic Kernel. This is a great way to get started and can be used for most scenarios. However, sometimes you will have advanced requirements that the endpoint cannot fulfil. In this case, you can start implementing the RAG pipeline yourself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8b5b500ea1b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/c-sharp-programming/llm-apps-in-net-implement-rag-on-azure-in-under-10-minutes-d8b5b500ea1b">LLM Apps in .NET: Implement RAG on Azure in under 10 minutes</a> was originally published in <a href="https://medium.com/c-sharp-programming">Any Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying AI: Five common misconceptions everyone should know about]]></title>
            <link>https://pub.towardsai.net/demystifying-ai-five-common-misconceptions-everyone-should-know-about-e52caa96d33f?source=rss-5cda01cbd49e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e52caa96d33f</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Cédric Mendelin]]></dc:creator>
            <pubDate>Sun, 18 May 2025 21:01:37 GMT</pubDate>
            <atom:updated>2025-05-18T21:01:37.985Z</atom:updated>
            <content:encoded><![CDATA[<h3>Demystifying AI: Five Common Misconceptions Everyone Should Know About</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XbCzcA5JtY7q34esWSpVeA.jpeg" /><figcaption>Source: Pavel Danilyuk: <a href="https://www.pexels.com/de-de/foto/reflektierung-spiegelung-reflexion-figur-8294666/">https://www.pexels.com/de-de/foto/reflektierung-spiegelung-reflexion-figur-8294666/</a></figcaption></figure><p>About 10 years ago, I was a computer science student. Every semester I had to register for new courses. This year, my university introduce a brand new course called “Natural Language Processing” (NLP), and I thought — “What the heck? What kind of exciting things can you build with natural language? <br>Well — today I feel so wrong. It is crazy to see how far NLP came since. The emergence of LLMs has taken the field to a whole new level, perhaps one of the most improved fields in all of science in the last 10 years?</p><p>But every medal has a downside. With the advent of LLMs, AI is being hyped like probably never before. Every product you launch these days has AI in its name or description, of course it is powered by AI. Every problem we face these days needs to be solved by AI, even if we don’t need it at all! I’m not talking about my LinkedIn AI bubble, every day a new game-changing AI approach is released and hyped, again, even if we don’t need it.</p><p>As an experienced dotnet and AI developer, I love the current hype, don’t get me wrong. It opens doors in so many cases and brings a kind of awareness. But I feel there are some crucial misunderstandings in society, decision makers but also among the tech “experts”, that make me think. With this post I want to address at least some of them and hopefully bring a little more clarity.</p><h3>Table of Content</h3><p>· <a href="#a259">Definition of AI</a><br>· <a href="#a348">AI Agent</a><br>· <a href="#09e7">Agentic AI</a><br>· <a href="#b074">Five Common Misconceptions Everyone should understand</a><br>· <a href="#3850">1. AI continuously learns and gets better over time.</a><br>· <a href="#2099">2. AI behaves non-deterministically.</a><br>· <a href="#b439">3. AI systems are unbiased.</a><br>· <a href="#0280">4. AI is infallible and always makes the right decisions.</a><br>· <a href="#913f">5. LLMs and agents will solve every problem in the future.</a><br>· <a href="#da16">🎯 Final Thought: From Hype to Strategy</a></p><h3><strong>Definition of AI</strong></h3><p>But first, let’s talk about the definition of AI. This is not that easy, because there is no clear definition. At the university, we categorized the understanding of AI into 4 pillars, that have emerged over time:</p><ul><li>Thinking Humanly</li><li>Acting Humanly</li><li>Thinking Rationally</li><li>Acting Rationally</li></ul><p>There is already a nice article about the characteristics of the four categories on Medium: <a href="https://medium.com/@fahmisajid8/understanding-the-four-types-of-artificial-intelligence-ai-25678fe89da3">Four Types of AI</a></p><p>I really like the idea of the evolution of the definition. In the early days of AI in the 50s, we could only dream of a system that could think like a human. As the world changed, computing power increased dramatically, and a proper mathematical understanding of AI emerged, the idea of what it is changed as well. Eventually, we settled on today’s definition of <strong>acting rationally</strong>. In my own words, I would describe it as</p><blockquote>Based of the available information, taking the best possible action — maximize your reward.</blockquote><h3>AI Agent</h3><p>I recently attended an AI conference in Zurich. There were about 8 talks and I feel that in every talk a different definition of an AI agent was given. I mean, how can that be not confusing?<br>But all these definitions had some common parts:</p><ul><li>Autonomous</li><li>Actions</li><li>Goal-Oriented</li><li>Decision Making</li></ul><p>With the advent of LLMs, I feel the term is being misused a bit for this domain. But an AI agent it not specific for LLMs. I still prefer the formal definition I learned at university:</p><blockquote>The agent is defined as an autonomous system, capable of perceiving its environment (sensors) and responding to it by applying actions (actuators).</blockquote><p>There are many types of agents, but this definition applies to all of them. Yes, I know, formal definitions are boring, but look how cool you can illustrate the AI agent::</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/0*mhQo4t38uKzHkxWB" /><figcaption>Source: <a href="https://www.solutelabs.com/blog/ai-agents-guide">https://www.solutelabs.com/blog/ai-agents-guide</a></figcaption></figure><h3>Agentic AI</h3><p>It gets even worse with the term Agentic AI. These days, everything has to be agentic, but I don’t think there is any real or let’s say formal definition (sorry, no university statement at this point).</p><p>I like to think of Agentic AI as a construction team. All together they are building a house, so they are aiming for the same result. But each worker has their own strengths and their own set of tools to use. Together they aim to achieve the goal. For an Agentic AI system, each individual agent has its own deputy and its own functionality (querying a database, automating a task, integrating with other systems, etc.), and together they make up the AI system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-oWWBLBzxwaxFoA0gp4ZA.jpeg" /><figcaption>Source: AI generated image</figcaption></figure><p>A music orchestra is another nice idea of Agentic AI.</p><h3>Five Common Misconceptions Everyone should understand</h3><p>As artificial intelligence becomes more embedded in business strategy, it’s important for decision-makers to separate the hype from reality. Misunderstandings about how AI works can lead to misaligned expectations, risky deployments, or missed opportunities. Let’s explore five common misconceptions— and how to think about them more clearly.</p><h3>1. AI continuously learns and gets better over time.</h3><p>If I could build my dream world, this would definitely be true! But mostly it is not. There are some AI systems that are built specifically for this (like recommender systems, reinforcement learning, or online learning) where it is true by design.</p><p>But for most AI systems it is not. They are trained on a fixed dataset and the resulting model is fixed after training and used as a static model that does not change. It takes a clear process and a lot of work to continuously improve the model over time (data collection, retraining pipeline).</p><h3>2. AI behaves non-deterministically.</h3><p>A function can be deterministic, which means that for the same input, the function always returns the same output. In contrast, a non-deterministic function can produce different results for the same input. In most systems we aim for determinism as it is easy to understand and reproduce. Sometimes, and especially when LLMs are referred to as AI, it feels like AI is non-deterministic. But all in all, most AI models, especially machine learning models, are deterministic. After the training phase, the model is fixed and will predict the same output for the same input.</p><p>But being non-deterministic is not always a bad thing. Imagine if you always gave the same answer to the question “How are you? Hopefully you do not. Your answer is determined by your current mood, the energy you have, the person asking the questions. If the place where the questions are asked is important. So how can an AI system behave in a consistent way?</p><p>Yes, there are a lot of scenarios where we want the AI system to behave deterministically. But especially for LLMs, the non-deterministic behaviour is somewhat desired. We can make the LLM behave more repetitively by adjusting parameters like temperate or top-k sampling. It is important that the model can reflect tiny nuances in the input questions to answer. Is it ever anything? Of course there are! (Especially as an AI engineer who wants to make his prompts as stable and deterministic as possible). But this is the design and the desired behaviour, we have to accept it and somehow appreciate it (too much?).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5f2cI5dlsDnLYyiIq6bUg.jpeg" /><figcaption>Source: cottonbro studio <a href="https://www.pexels.com/de-de/foto/person-die-schwarzes-und-silbernes-handwerkzeug-halt-6153354/">https://www.pexels.com/de-de/foto/person-die-schwarzes-und-silbernes-handwerkzeug-halt-6153354/</a></figcaption></figure><h3>3. AI systems are unbiased.</h3><p>Wikipedia defines bias as:</p><blockquote>Bias is a disproportionate weight in favor of or against an idea or thing, usually in a way that is inaccurate, closed-minded, prejudicial, or unfair</blockquote><p>Everyone has a slight bias on most subjects. The problem arises when the bias dominates your opinion. You become unfair and no longer objective.</p><p>AI systems are not neutral by nature. They learn from data — and data often reflects human opinion. It’s not just your opinion, data also reflects your culture, society, stereotypes and historical inequalities. So any AI system trained on data will have a bias or reflect a particular domain. Even if the algorithm is mathematically fair, the results may not be. You need to make sure you have the right data set, and that there is no skewed data or under-representation of certain groups. You can combat bias with audits and human oversight of the results. But you will never get rid of them and you will have to accept them somehow or find an alternative solution (like LLM trained from European data, American data or Chinese data, which one is your favourite and can you work with the others — where is your line?)</p><h3>4. AI is infallible and always makes the right decisions.</h3><p>Imagine you are an expert C# developer. You have been working in this field for more than 15 years. During the year, you are asked 100 questions about C# by Junior-Dev and you answer 98 of them correctly. What a great score, right? Well, you don’t know which questions you got wrong, so hopefully the two Junior Devs will find out for themselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qFyXrVc_uExENKz7qQWc6w.jpeg" /><figcaption>Source: AI generated image</figcaption></figure><p>Now imagine you are a doctor and you have 100 cancer patients. The patients may have a rare cancer. If they test positive, they will most likely die in the next 3 months. You have tested all your 100 patients and you have misclassified two of them, saying that the test was positive when it was not. So 98 out of 100 again. But is that a good result?</p><p>AI systems are statistical tools, not oracles. They make predictions based on patterns — and they can be wrong. We cannot change that. We can try to make them as good as possible, but there will always be a chance that they will be wrong. They should in many cases augment human judgement, not replace it. So it depends on the domain in which we want to apply the AI system. Is it critical that a LLM-based AI can answer every single question correctly to make your employee more productive? Probably not, even the experts in that domain make mistakes, so why not for an AI? But for a cancer diagnosis system, it might be worth the effort to introduce a human-in-the-loop system to finally accept the AI’s diagnosis suggestions.</p><h3>5. LLMs and agents will solve every problem in the future.</h3><p>LLMs are great but all in all, they were designed as a <strong>language model</strong>. Again, l a n g u a g e — m o d e l. They are trying to apply and understand our language. And you know what, they are amazing at it!<br>But we realised that they are also pretty good at a lot of other tasks, learning from huge amounts of data, working with context, basically doing anything you ask them to do that can be done with the power of language alone. And yes, they are not perfect at all of these tasks.<br>How could they be? They are designed to use and understand our language. Sometimes they lack real understanding, hallucinate or struggle with proper reasoning.<br>But the way the LLM is designed, it cannot solve any problems. I see it as a Swiss army knife. A collection of different tools in one thing. Not optimal for most things, but they get the job done. The more tools the knife has, the more versatile you can apply it to new domains. We have not yet arrived at an artificial general intelligence, and LLMs alone cannot fulfil this dream.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xCrhef9xQBAEP9_I" /><figcaption>Photo by <a href="https://unsplash.com/@dmjdenise?utm_source=medium&amp;utm_medium=referral">Denise Jans</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>🎯 Final Thought: From Hype to Strategy</h3><p>AI is not perfect, but most of the time it does not need to be. It can be a powerful transformational tool if applied with clarity and care.<br>Start using the tools today, don’t wait! You need to learn and apply them to your business quickly. Follow top AI leaders like Andrew Ng, Yann LeCun or others to learn from the best.</p><p>But how do you start bringing AI into your business? First, align AI with business goals and identify areas where it can add real business value to your organisation. Aim for innovation, not just efficiency! Think about user adoption and get them involved early in the process. Often when AI is introduced, there is a need for adoption, which requires time and a clear process. Don’t forget legal and governance, it’s important to involve them early on. Finally, data is the critical part of all AI systems, so invest in a clean data platform to get the most out of it.</p><p>Let me know what you think about this article in the comments! Where do you agree, where do you disagree? I would love to hear from you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e52caa96d33f" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/demystifying-ai-five-common-misconceptions-everyone-should-know-about-e52caa96d33f">Demystifying AI: Five common misconceptions everyone should know about</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>