
LLM chat memory in ASP.NET Core: IChatReducer and MongoDB
HTTP APIs are stateless, LLM chats are not: every turn needs to see the story so far. Resending *everything* on each message blows up ==tokens and the context window==. In this tutorial I build a .NET 9 Minimal API where **MongoDB keeps the full transcript** and the model only receives the view reduced by a **IChatReducer** from *Microsoft.Extensions.AI*: the last N messages, or an LLM-generated summary. Fully local with Ollama, and measurable on every single reply.










