Agent chat history in .NET Microsoft Agent Framework with SQL Server, Ollama and Docker Desktop
Authorised Territory demonstrates how an AI agent built with the .NET Microsoft Agent Framework can persist chat history to SQL Server and then reuse that history in later conversations to influence responses.
Full summary based on description
Goal: persist and reuse agent chat history
- Store chat messages from an AI agent conversation in a SQL Server 2025 table.
- Retrieve the stored chat history later.
- Feed the retrieved history into a new conversation so it can influence the agent's response.
Tech stack used in the tutorial
- .NET Microsoft Agent Framework for building the agent.
- SQL Server 2025 for storing chat messages.
- Docker Desktop to run SQL Server locally.
- Ollama running locally as the LLM runtime.
- gpt-oss used as the chat LLM.
- nomic-embed-text used to generate embeddings.
Data storage and retrieval flow
- Persist conversation messages into SQL Server.
- Query SQL Server to retrieve prior messages.
- Use the retrieved messages as context in a new conversation to shape the agent output.
Embeddings usage
- Generate embeddings with nomic-embed-text.
- Use embeddings as part of the approach to make prior conversation content retrievable and reusable as context.