← Back to Articles         
Minimal Agent Architecture with DevUI, .NET Aspire

Minimal Agent Architecture with DevUI, .NET Aspire

Published on 23 Nov 2026 11 min read Agentic AI (.NET)
Building .NET 10 AI Agent with Microsoft Foundry

Minimal Agent Architecture with DevUI, .NET Aspire, and Microsoft Agent Framework

How to build a minimal enterprise-style AI agent architecture using ASP.NET Core Web API, .NET Aspire, Microsoft Agent Framework, DevUI, OpenTelemetry, and Microsoft Foundry/Azure OpenAI.

The main goal is to solve the “black box” problem of console-based AI agents by providing visual inspection and distributed tracing of agent activity.

1. Why Visual Testing of Agents Is Needed

Initially, an AI agent can be developed inside a simple console application.

For example:

User
  ↓
Console Application
  ↓
AI Agent
  ↓
LLM
  ↓
Response

This is useful during early development, but there is a major problem.

The console usually shows only the final response:

User: My VPN keeps disconnecting.
Agent: Try restarting the VPN client...

It does not provide enough visibility into what happened internally.

An enterprise developer or architect may want to know:

  • What system prompt was sent?
  • What user message was received?
  • Which model was called?
  • How long did the LLM call take?
  • How many input/output tokens were consumed?
  • What tools were invoked?
  • What events happened during agent execution?
  • Where did the request spend its time?

This as the black box problem because the complex cognitive steps of the LLM are hidden behind the console output.


2. The Solution: Visual Agent Architecture

The architecture moves from a simple console application to an ASP.NET Core Web API hosted through .NET Aspire.

Two important visual/observability tools are introduced:

DevUI

DevUI provides a visual interface for interacting with and inspecting agents.

It allows developers to see agent events in real time.

.NET Aspire Dashboard

The Aspire Dashboard provides distributed tracing and observability across the request lifecycle.

It uses OpenTelemetry to capture telemetry from the application.

So the architecture becomes:

                User
                 │
                 ▼
              DevUI
                 │
                 ▼
        ASP.NET Core Web API
                 │
                 ▼
       Microsoft Agent Framework
                 │
                 ▼
        Microsoft Foundry
          Azure OpenAI / LLM
                 │
                 ▼
             Response
                 │
                 ▼
              DevUI

At the same time:

ASP.NET Core Web API
        │
        ▼
  OpenTelemetry
        │
        ▼
 .NET Aspire Dashboard
        │
        ├── Traces
        ├── Metrics
        ├── LLM calls
        ├── Token usage
        └── Request lifecycle

DevUI as the agent inspection dashboard and the Aspire Dashboard as the distributed-tracing layer.


3. Why .NET Aspire Is Used

.NET Aspire is being used primarily for orchestration and observability.

The solution contains three important projects:

Minimal Agent Solution
│
├── AppHost
│
├── ServiceDefaults
│
└── WebAPI

Each project has a different responsibility.


4. AppHost Project

The AppHost project is the orchestrator.

Its responsibilities include:

  • Managing application resources
  • Connecting the different projects
  • Managing networking
  • Launching the Aspire Dashboard
  • Starting the services together

AppHost as the top-level orchestrator.

Conceptually:

             AppHost
                │
       ┌────────┴────────┐
       │                 │
    WebAPI          Other Services
       │
       ▼
     Agent

For this minimal example, only the Web API resource is registered.


5. ServiceDefaults Project

The ServiceDefaults project contains shared infrastructure configuration.

Instead of configuring telemetry, logging, resilience, etc. separately inside every service, common configuration can be centralized here.

  • OpenTelemetry
  • Resilience
  • HTTP client configuration
  • Distributed tracing

Conceptually:

             ServiceDefaults
                   │
        ┌──────────┼──────────┐
        │          │          │
   OpenTelemetry Resilience Logging
        │
        ▼
    All Services

This becomes particularly important for AI applications because LLM calls can take much longer than normal API calls.


6. WebAPI Project

The WebAPI project is the actual application that hosts the AI agent.

It performs several important jobs:

  1. Hosts the ASP.NET Core API
  2. Creates the AI chat client
  3. Creates/registers the agent
  4. Registers DevUI
  5. Exposes API endpoints
  6. Communicates with the LLM

The calls this the heart of the application.

The architecture is therefore:

AppHost
   │
   └── WebAPI
         │
         ├── Chat Client
         │
         ├── AI Agent
         │
         ├── DevUI
         │
         └── REST API

7. Why Normal HTTP Timeout Configuration Is Not Enough

This is an important enterprise consideration.

Traditional REST APIs might return within:

100 ms
500 ms
2 seconds

But an LLM request can take:

10 seconds
30 seconds
1 minute
Several minutes

therefore configures a much longer timeout.

The example uses:

Total request timeout = 5 minutes
Circuit breaker sampling duration = 6 minutes

Why 6 minutes for the circuit breaker?

Suppose the timeout is:

5 minutes

and the circuit-breaker sampling window is only:

1 minute

A slow LLM request could potentially interfere with the resilience logic.

The example therefore makes the sampling duration longer than the timeout:

Request timeout
      │
      ├────────────── 5 minutes
      │
      ▼
Circuit breaker sampling
      ├──────────────────── 6 minutes
      │
      ▼

The important principle is:

AI workloads require resilience settings that account for long-running LLM operations.


8. OpenTelemetry Configuration

Another major part of the architecture is OpenTelemetry.

The application configures tracing for AI-related libraries, including:

Microsoft.Extensions.AI
Microsoft.Extensions.Agents

This allows AI operations to appear in the Aspire Dashboard.

Wildcard tracing configuration for these libraries.

Conceptually:

Agent Request
     │
     ▼
Microsoft Agent Framework
     │
     ▼
Microsoft.Extensions.AI
     │
     ▼
OpenTelemetry
     │
     ▼
Aspire Dashboard

This gives an observability layer around the AI execution.


9. Sensitive Data in OpenTelemetry

One of the most important settings in the example is enabling sensitive data.

The configuration enables the equivalent of:

EnableSensitiveData = true

This allows telemetry to contain information such as:

  • System prompts
  • User messages
  • Model completions
  • Token information

if sensitive data is disabled, the telemetry may show that an LLM call happened but hide the actual prompt text for privacy.

So there is an important distinction:

Sensitive Data = false

Trace:
"LLM call happened"

                    ❌ Prompt hidden
                    ❌ Completion hidden

versus:

Sensitive Data = true

Trace:
"LLM call happened"

                    ✓ System prompt
                    ✓ User message
                    ✓ Completion
                    ✓ Token information

Important production consideration

This setting for development/inspection.

In a production system, prompts and responses may contain confidential information, personal information, credentials, business data, or customer information.

Therefore, this type of detailed telemetry should be handled carefully.


10. Creating the AI Chat Client

The Web API creates an IChatClient.

The important concept is that the application is not directly writing low-level HTTP calls to the LLM.

Instead:

IChatClient
     │
     ▼
Microsoft.Extensions.AI
     │
     ▼
LLM Provider

This provides a common abstraction for chat-based AI interaction.

This as the Microsoft.Extensions.AI builder pattern.

The OpenTelemetry/GenAI instrumentation is also attached to this client so that LLM operations can be traced.


11. Creating the Agent

Once the chat client exists, the application creates an agent.

Conceptually:

Chat Client
     │
     ▼
AI Agent
     │
     ├── Name
     ├── Instructions
     └── Chat Client

The example creates an agent called:

Network Support Agent

and gives it instructions representing a Tier-1 IT support role.

The agent is then registered with ASP.NET Core dependency injection using the AI-agent registration mechanism described.

This is important because the agent becomes a dependency that can be retrieved through the application's DI container.


12. Dependency Injection Flow

The overall dependency relationship looks like this:

ASP.NET Core DI Container
          │
          ▼
   Network Support Agent
          │
          ▼
      IChatClient
          │
          ▼
    OpenTelemetry
          │
          ▼
   Azure OpenAI / LLM

So the agent does not need to manually create everything each time an API request arrives.

The required services are configured during application startup.


13. Registering DevUI

The next step is registering DevUI services.

The application then maps the DevUI endpoints after building the application.

Conceptually:

builder
   │
   ├── Register AI services
   ├── Register Agent
   └── Register DevUI
          │
          ▼
      app.Build()
          │
          ▼
      Map DevUI

This allows the application to expose the DevUI interface through the ASP.NET Core application.

This requires only a small amount of configuration.


14. The Normal REST API Endpoint

In addition to DevUI, the application exposes a standard REST endpoint.

For example:

POST /api/chat

The endpoint retrieves the registered agent from the keyed dependency-injection services and executes the agent.

Conceptually:

POST /api/chat
       │
       ▼
Get Network Support Agent
       │
       ▼
agent.RunAsync(...)
       │
       ▼
LLM
       │
       ▼
Response

This specifically describes MapPost, keyed services, and RunAsync for this flow.


15. Why DevUI Is Used Instead of the REST Endpoint During Testing

The REST endpoint exists for normal application integration.

However, during development and testing, DevUI provides a visual interface.

So there are effectively two ways to interact with the agent:

                  Agent
                   │
          ┌────────┴────────┐
          │                 │
       REST API            DevUI
          │                 │
 Application              Developer
 Integration              Testing

The DevUI visual endpoints are used to test the agent during the demonstration.


16. Running the Application with Aspire

The AppHost project is selected as the startup project.

When the Aspire application starts, the Aspire Dashboard appears.

The dashboard displays the registered resources.

For this example, the Web API appears as a resource.

The dashboard provides two important URLs:

Web API
  │
  ├── DevUI URL
  │
  └── Web API URL

The DevUI URL is then opened to interact with the agent.


17. Testing the Network Support Agent

The DevUI displays the available agents.

The example selects:

Network Support Agent

and creates a new conversation.

The test question is:

My VPN keeps disconnecting every few minutes.

What should I try?

The request then travels through the architecture.

User
 │
 ▼
DevUI
 │
 ▼
ASP.NET Core Web API
 │
 ▼
Microsoft Agent Framework
 │
 ▼
Network Support Agent
 │
 ▼
Chat Client
 │
 ▼
Microsoft Foundry
 │
 ▼
Azure OpenAI / GPT-5 Mini
 │
 ▼
Response
 │
 ▼
DevUI

18. Real-Time Agent Events

One of the major advantages of DevUI is that the developer can observe events while the agent is executing.

This mentions seeing:

  • System prompt
  • User message
  • Token usage
  • Model response
  • Other agent events

Instead of only seeing:

Agent:
Try restarting your VPN...

the developer can see much more of the internal request lifecycle.

This makes debugging and understanding agent behavior significantly easier.


19. Aspire Distributed Tracing

DevUI gives an agent-focused visual experience.

The Aspire Dashboard provides another layer: distributed tracing.

After executing the request, the developer can return to Aspire and open the trace.

The trace shows the lifecycle of the request and its AI integration.

Conceptually:

HTTP Request
     │
     ▼
ASP.NET Core
     │
     ▼
Agent
     │
     ▼
Chat Client
     │
     ▼
LLM
     │
     ▼
Response

Each stage can appear as telemetry spans.


20. GenAI Details

Because the application enabled sensitive AI telemetry, the trace can expose GenAI-related information.

This describes being able to inspect:

  • Exact prompt information
  • Completion text
  • Timing
  • Token counts
  • System message
  • User message
  • Output

Calls an “X-ray vision” into the AI system.

The important idea is that the developer can move from:

Request failed

to something much more useful:

HTTP Request
     │
     ├── Agent execution
     │
     ├── System prompt
     │
     ├── User message
     │
     ├── LLM call
     │
     ├── Token usage
     │
     ├── Response
     │
     └── Total duration

21. DevUI vs Aspire Dashboard

These two tools have related but different responsibilities.

Feature DevUI Aspire Dashboard
Agent interaction Yes No
Visual agent testing Yes No
Agent events Yes Yes, through telemetry
Prompt inspection Yes Yes, when sensitive telemetry is enabled
Token information Yes Yes
Distributed tracing Limited/agent-focused Yes
Service/resource monitoring Limited Yes
Application orchestration No Yes
OpenTelemetry Consumes agent telemetry Central observability layer

A useful way to remember it:

DevUI
  =
Agent Developer Experience

Aspire Dashboard
  =
Application Observability

22. Complete Architecture

Putting everything together:

                         USER
                          │
                          ▼
                    ┌──────────┐
                    │  DevUI   │
                    └────┬─────┘
                         │
                         ▼
                 ┌───────────────┐
                 │ ASP.NET Core  │
                 │    Web API    │
                 └───────┬───────┘
                         │
                         ▼
              ┌─────────────────────┐
              │ Microsoft Agent     │
              │ Framework           │
              └──────────┬──────────┘
                         │
                         ▼
              ┌─────────────────────┐
              │   Network Support   │
              │       Agent         │
              └──────────┬──────────┘
                         │
                         ▼
                    IChatClient
                         │
                         ▼
              ┌─────────────────────┐
              │ Microsoft Foundry   │
              │ Azure OpenAI / LLM  │
              └──────────┬──────────┘
                         │
                         ▼
                     RESPONSE
                         │
                         ▼
                       DevUI


       OBSERVABILITY SIDE
       ──────────────────

       ASP.NET Core
             │
             ▼
       Agent Framework
             │
             ▼
     Microsoft.Extensions.AI
             │
             ▼
       OpenTelemetry
             │
             ▼
      Aspire Dashboard
             │
        ┌────┼────┐
        │    │    │
      Traces Metrics GenAI
                   │
                   ├── Prompts
                   ├── Messages
                   ├── Tokens
                   └── Responses

23. Role of Each Technology

ASP.NET Core

Hosts the Web API and provides the HTTP endpoints.

Microsoft Agent Framework

Provides the agent abstraction and agent execution capabilities.

Microsoft.Extensions.AI

Provides the chat/AI abstraction used by the application.

Microsoft Foundry

Provides access to the model/AI service used in the example.

Azure OpenAI

Provides the underlying LLM model in the demonstrated setup.

DevUI

Provides a visual interface for interacting with and inspecting the agent.

.NET Aspire

Provides application orchestration and the Aspire Dashboard.

OpenTelemetry

Provides standardized telemetry and distributed tracing.

ServiceDefaults

Centralizes common resilience and observability configuration.

AppHost

Coordinates and launches the application resources.


24. Complete Request Lifecycle

The complete request lifecycle can be understood as follows:

1. User enters question
          │
          ▼
2. DevUI sends request
          │
          ▼
3. ASP.NET Core receives request
          │
          ▼
4. Network Support Agent is resolved
          │
          ▼
5. Agent.RunAsync()
          │
          ▼
6. Agent sends request through IChatClient
          │
          ▼
7. OpenTelemetry captures AI telemetry
          │
          ▼
8. Azure OpenAI / LLM processes request
          │
          ▼
9. LLM generates response
          │
          ▼
10. Response is streamed back
          │
          ▼
11. DevUI displays response/events
          │
          ▼
12. Aspire Dashboard contains trace

This architecture provides a minimal agent implementation combining Aspire, the backend API, Agent Framework, and Microsoft Foundry, while also providing visibility into the AI request lifecycle.

25. Complete Code

Source Code

← Back to Articles