cd /news/ai-agents/agent-01-a-customer-support-agent-wi… Β· home β€Ί topics β€Ί ai-agents β€Ί article
[ARTICLE Β· art-182898] src=dev.to β†— pub= topic=ai-agents verified=true sentiment=↑ positive

Agent 01: A customer support agent with Microsoft Agent Framework, C# and React

A .NET backend engineer built a customer support agent for an online electronics store using Microsoft Agent Framework, C# and React, as the first entry in a weekly series of industry-specific AI agents. The agent wraps a gpt-5-mini model via IChatClient in a ChatClientAgent with instructions and a GetOrderStatus tool, keeps per-session conversation history keyed by sessionId, and streams answers to a React chat frontend. In testing, the agent declined to invent order contents when its tool returned only delivery status, and it recalled an order number from an earlier message without being reminded.

recommendation

Scope each tool to exactly what it returns and instruct the agent to say it cannot see anything else, so it declines rather than fabricates missing order details.

more in playbook: Designing agent systems
by read5 min views9 publishedDec 6, 2026

I'm a .NET backend engineer, and I've started a series: one AI agent every week, each one solving a real problem in a different industry. It's how I'm building deep, practical knowledge of generative AI: build an agent, break it, fix it, ship it, and write up what I learned, including what went wrong.

This is Agent 01: a customer support agent for an online electronics store.

I'm pairing two things:

The course teaches the idea. Each weekly agent makes me use it on a real problem.

IChatClient, so I'm on OpenAI today and can switch providers later by changing one class. Online stores answer the same questions all day, and "Where is my order?" is the biggest one. A support agent can answer instantly, look up the real order status instead of guessing, and hand the customer to a human when money is involved, like a refund.

Agent checking a real order and streaming the answer.

My favourite moment from testing: I asked "What are the contents of this order?" The tool only returns the delivery status, so the agent said it couldn't see the items, instead of making some up. It also remembered order 1234 from my earlier message without me repeating it. Admitting what it doesn't know matters more to me than sounding clever.

gpt-5-mini

React chat  β†’  POST /api/chat { sessionId, message }  β†’  ChatController
                                                              ↓
                                                         ChatService  (sessions + streaming)
                                                              ↓
                                                         AIAgent      (built by AgentService)
                                                              ↓
                                              OpenAIProvider β†’ OpenAI
                                                              ↓
                                      OrderTools β†’ IOrderRepository (when the customer asks about an order)

The backend is split into layers, and inner layers never know about outer ones:

backend/
β”œβ”€β”€ Controllers/        ChatController: only calls the service
β”œβ”€β”€ Domain/             Order: a plain business object
β”œβ”€β”€ Application/        interfaces, AgentService, ChatService, OrderTools
β”œβ”€β”€ Infrastructure/     OpenAIProvider, InMemoryOrderRepository
└── Extensions/         AddServices: all DI in one place

An agent is the model, plus instructions, plus tools, wrapped in one object. In Agent Framework that's a ChatClientAgent:

public AIAgent CreateAgent()
{
    IChatClient chatClient = _aiProvider.GetChatClient();

    return new ChatClientAgent(
        chatClient,
        name: "SupportAgent",
        instructions: """
            You are a friendly support agent for an online electronics store.
            Keep answers short and clear.
            Use the GetOrderStatus tool whenever a customer asks about an order.
            Never promise a refund. Offer to connect the customer to a human instead.
            """,
        tools: [AIFunctionFactory.Create(_orderTools.GetOrderStatusAsync, name: "GetOrderStatus")]);
}

The model reads the [Description] text to decide when to call the tool and what to pass in. The framework runs the method and hands the result back to the model.

[Description("Gets the delivery status of a customer's order.")]
public async Task<string> GetOrderStatusAsync([Description("The order number, for example 1234")] int orderId)
{
    Order? order = await _orderRepository.GetOrderByIdAsync(orderId);

    if (order == null)
    {
        return $"Order with ID {orderId} not found.";
    }

    return $"The status of order {orderId} is: {order.Status}.";
}

Each chat sends a sessionId, and the backend keeps one AgentSession per ID. The session holds the conversation's history.

private async Task<AgentSession> GetOrCreateSessionAsync(string sessionId)
{
    if (_sessions.TryGetValue(sessionId, out AgentSession? session))
    {
        return session;
    }

    session = await _agent.CreateSessionAsync();
    _sessions[sessionId] = session;
    return session;
}

One catch: ChatService holds the _sessions dictionary, so it must be registered as a singleton. If it's scoped, every request gets a new, empty dictionary and the agent forgets everything.

The agent produces small updates as the model writes. The service writes each one to the response and flushes it, so the browser gets it straight away instead of waiting for the full reply:

await foreach (AgentResponseUpdate update in _agent.RunStreamingAsync(request.Message, session))
{
    if (string.IsNullOrEmpty(update.Text))
    {
        continue;
    }

    byte[] bytes = Encoding.UTF8.GetBytes(update.Text);
    await output.WriteAsync(bytes);
    await output.FlushAsync();
}

On the React side, the page reads the response piece by piece and updates the reply as each piece lands:

const reader = response.body!.getReader()
const decoder = new TextDecoder()
let text = ''

while (true) {
  const { done, value } = await reader.read()
  if (done) break
  text += decoder.decode(value, { stream: true })
  setReply(text)
}

OpenAI sits behind an IAIProvider interface, and it's the only class that knows about OpenAI:

public IChatClient GetChatClient()
{
    return new OpenAIClient(_settings.ApiKey)
        .GetChatClient(_settings.Model)
        .AsIChatClient();
}

To move to another provider later, I write a new class that implements IAIProvider and change one line in AddServices.

Check Pass if Result
"My name is Fisayo", then "What's my name?" It remembers the name Pass
"Explain how to choose a laptop" The reply streams in word by word Pass
"Where is my order 1234?" It calls GetOrderStatus Pass
"Can I get a refund?" It doesn't promise one and offers a human Pass

/api/chat, but the Vite proxy only forwarded /chat and my controller listened on chat. All three have to use the same path. I now forward everything under /api and use [Route("api/chat")]. support_agent_api after the project, while some of my files used SupportAgent.Api. Classes then can't find each other. Pick one and stay consistent.Startup.cs that wouldn't compile.Configuration in the constructor but forgot to declare the public IConfiguration Configuration { get; } property. None of these were AI problems. Most of the week went into plain web plumbing, which is a useful reminder.

Later in the series, I'll take the same patterns to Claude and Anthropic's agent tools.

The full backend and frontend are on GitHub: ai-agents/support-agent

If you've built agents with Agent Framework, what tripped you up first? I'd like to hear it in the comments.

── more in #ai-agents 4 stories Β· sorted by recency
── more on @microsoft 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/agent-01-a-customer-…] indexed:0 read:5min 2026-12-06 Β· β€”