Stop Debugging C# AI Agents in the Console: A Guide to Microsoft Agent Framework DevUI

November 26, 2026 by Anuraj

dotnet ai csharp devui

In this blog post, we will learn how to set up DevUI in ASP.NET Core to visually test, debug, and trace your C# AI agents, tool calls, and workflows in real time without writing frontend code. Building AI agents in C# often follows a repetitive pattern: tweaking a system prompt, updating a tool description, hitting F5, and staring at a wall of plain text in the terminal while trying to figure out why the model hallucinated an argument or skipped a function call entirely.

Console apps work well for quick prototypes, but they fall short when debugging multi-turn conversations and complex tool executions. That is where DevUI comes in-a built-in, zero-frontend development interface inside the Microsoft Agent Framework. With just a few lines of setup in ASP.NET Core, DevUI provides a clean browser-based chat canvas paired with real-time tool-call inspection, token tracking, and OpenTelemetry traces.

Here is how I wire it up in a .NET project to start debugging visually.

Why I Use DevUI

Before diving into the code, here is what DevUI brings to my local inner-loop workflow:

  • Zero Frontend Code: There is no need to spin up React, Blazor, or Swagger workarounds just to test conversational state.
  • Live Tool-Call Inspection: It displays the exact JSON payloads an agent sends to C# functions and what those functions return.
  • Workflow Visualization: When orchestrating multi-agent workflows (sequential, concurrent, or handoffs), DevUI lets me select and test them side-by-side.
  • Built-in Telemetry: Latency, token usage, and execution traces appear right alongside the chat window.

Step 1: Installing the NuGet Packages

In an ASP.NET Core web application, I start by adding the DevUI and Agent Framework hosting packages via the .NET CLI:

dotnet add package Azure.AI.OpenAI
dotnet add package Microsoft.Agents.AI.DevUI --prerelease

Step 2: Registering the Agent and DevUI Endpoints

DevUI communicates with agents using OpenAI-compatible Responses and Conversations endpoints. In Program.cs, I wire up an IChatClient, register the agent, and map the DevUI routes. Here is a complete, minimal example that includes a custom C# tool to show function calling in action.


// 1. Register the underlying AI provider (OpenAI, Azure OpenAI, Ollama, etc.)
var chatClient = new AzureOpenAIClient(
        new Uri(endpoint),
        new AzureKeyCredential(apiKey))
        .GetChatClient(deploymentName)
        .AsIChatClient();

builder.Services.AddChatClient(chatClient)
    .UseFunctionInvocation()
    .UseLogging();

// 2. Define a sample tool for the agent to call
[Description("Gets the current server status and uptime.")]
static string GetSystemHealth() => "All systems operational. Uptime: 99.98%.";

// 3. Register the AI Agent
builder.AddAIAgent("ops-assistant", (sp, key) =>
{
    var chatClient = sp.GetRequiredService<IChatClient>();
    
    return new ChatClientAgent(
        chatClient,
        name: key,
        instructions: "An IT operations assistant that uses tools to check system health when asked.",
        tools: [AIFunctionFactory.Create(GetSystemHealth)]
    );
});

// 4. Register the DevUI, OpenAI Responses and Conversations services required

builder.Services.AddDevUI();
builder.Services.AddOpenAIResponses();
builder.Services.AddOpenAIConversations();

var app = builder.Build();

// 5. Expose DevUI strictly in the Development environment
if (app.Environment.IsDevelopment())
{
    app.MapOpenAIResponses();
    app.MapOpenAIConversations();
    app.MapDevUI(); // Maps the UI to /devui
}

Step 3: Launching and Inspecting

  1. Start the application using dotnet run or the IDE debugger.
  2. Open a browser and navigate to https://localhost:/devui.
  3. Pick ops-assistant from the agent selector dropdown.
  4. Send a test prompt like “How are the servers looking right now?”

Instead of guessing what happened behind the scenes, the trace panel visually lays out how the agent pauses, invokes GetSystemHealth(), receives the response string, and formulates its final reply.

Building reliable AI agents comes down to observability. Fixing prompts or tool schemas becomes much easier when it is possible to see how a model interacts with them in real time. Adding DevUI takes less than two minutes and makes the C# AI development loop much smoother—replacing endless Console.WriteLine debugging with a proper visual inspector.

Happy Programming.

Support My Work

If you find my content helpful, consider supporting my work. Your support helps me continue creating valuable resources for the community.

Buy me a coffee
Share this article

Found this useful? Share it with your network!

Copyright © 2026 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub