I mentioned earlier that I’d build a demo-a-day for the next week after the launch of the Microsoft Agent Framework - because frameworks are a dime a dozen, but what matters is what you can build with them. A demo a day keeps the FOMO at bay.In the first demo today, I’ll explore a feature in Agent Framework that I think is extremely useful: Middleware. You can think of middleware as a way to intercept and modify the behavior of your agent at various stages of its operation. If you have built web applications - you have probably seen similar middleware patterns where the idea is to build reusable components (e.g., auth, logging, etc) that can intercept, modify or reject the requests that come to your server.We’ll start with a simple agent with a tool that can tell the weather. Only in this case, there’s a super special location - one that no one must ever speak of - Atlantis. Other locations are fair game. Our agent must never speak of Atlantis and must warn users accordingly.While this demo scenario is whimsical, later in this post I’ll show how the same patterns apply to critical real-world scenarios like blocking PII data, enforcing rate limits, and implementing security controls.A basic agent with a tool.Let’s start with a basic weather agent that has a simple function to get the current weather:from typing import Annotated