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.
How I'm learning
I'm pairing two things:
- Generative AI for .NET, Microsoft's free course. It covers the building blocks: what generative AI is, chat with context and memory, calling models through Microsoft.Extensions.AI, embeddings, RAG, agents with Microsoft Agent Framework, and responsible AI.
- Microsoft Agent Framework (MAF), which turns those building blocks into real agents.
The course teaches the idea. Each weekly agent makes me use it on a real problem.
Why Microsoft Agent Framework
- It's .NET-native. I write agents in C# with the same dependency injection, services and onion architecture I use in production code.
- It's where Microsoft's agent work is going. MAF is the open-source successor to Semantic Kernel and AutoGen, built by the same teams, and it reached version 1.0 in April 2026.
- It handles the agent plumbing. The tool-calling loop, conversation memory (sessions) and streaming are built in, so I can focus on what the agent should do.
- It grows with the series. Multi-agent workflows and human-in-the-loop approval are part of the framework, and I'll need both in the coming weeks.
- It isn't tied to one model. Agents talk to models through a standard
IChatClient, so I'm on OpenAI today and can switch providers later by changing one class.
What I learned from Generative AI for .NET this week
- A chatbot answers; an agent acts. An agent can call tools to look things up and get work done. Agent 01 checks real order status instead of guessing.
- One interface for every model. Microsoft.Extensions.AI gives every model provider the same
IChatClientinterface. That's why my OpenAI code lives in one class. - Memory is something you manage. A model doesn't remember the last message by itself. The conversation history has to be kept and sent with each request, and in MAF that's what a session does.
The problem
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.
What it does
- Chats with the customer and streams its reply word by word
- Remembers the conversation, so if you tell it your name and ask later, it knows
- Looks up order status with a tool, a normal C# method the model can call
- Never promises a refund; it offers to connect you to a human instead
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.
The stack
- Backend: ASP.NET Core, Microsoft Agent Framework, OpenAI
gpt-5-mini - Frontend: React, Vite, TypeScript, Tailwind CSS
How it fits together
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 1. The agent is instructions plus tools
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")]); } 2. A tool is just a C# method
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}."; } 3. Memory is one session per conversation
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.
4. Streaming, from the model to the browser
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) } 5. Swapping AI providers is one line
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.
How I tested it
| 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 |
What broke and how I fixed it
- A 404 on every message. My React code called
/api/chat, but the Vite proxy only forwarded/chatand my controller listened onchat. All three have to use the same path. I now forward everything under/apiand use[Route("api/chat")]. - Mixed namespaces. Visual Studio named my namespace
support_agent_apiafter the project, while some of my files usedSupportAgent.Api. Classes then can't find each other. Pick one and stay consistent. - A
Startup.csthat wouldn't compile. I setConfigurationin the constructor but forgot to declare thepublic 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.
Code
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.


