Prevent secrets from reaching the LLM in .NET Microsoft Agent Framework and Ollama
Authorised Territory shows how to stop passwords, API keys, and other secrets from being sent to an LLM when building AI agents with the Microsoft Agent Framework in .NET and Ollama, by adding middleware that detects and redacts sensitive values before model calls.
Overview
The tutorial covers a practical pattern for protecting sensitive data in agentic applications:
- Build a simple IT helpdesk agent.
- Add middleware that intercepts messages before they reach the model.
- Detect sensitive values (for example passwords and API keys).
- Redact those values.
- Send only the sanitised content to the LLM.