Middleware: agent, function and chat
Wrap an agent with your own code at three points. Watch agent middleware wrap the whole run, chat middleware wrap every model call, and function middleware wrap every tool call, without changing the agent or the tool.
11 minPro
Checking your access…
Inside this lesson
- An animation you play, pause and step through, with each part saying what it is doing.
- The real code beside it, with the lines for each step lit up.
- Practice mode, where you route each message yourself, and a short quiz.
- About 11 minutes.
Written from the official documentation
- learn.microsoft.com/en-us/agent-framework/concepts/agents/middleware
- learn.microsoft.com/en-us/agent-framework/concepts/agents/middleware/defining-middleware
- learn.microsoft.com/en-us/agent-framework/concepts/agents/middleware/chat-middleware
- learn.microsoft.com/en-us/agent-framework/journey/adding-middleware
In this module: Middleware and safety
- Middleware: agent, function and chatCode that wraps each run, each tool call and each model call.Pro
- Guardrails: stop, override and handle errorsEnding a run early, replacing results and catching failures.Pro
- Middleware scope, shared state and runtime contextAgent level or run level, and passing values through a run.Pro
- Agent safety and Purview policiesTrust boundaries, input checks and policy enforcement.Pro
- Agent security with FIDESLabels on content that block prompt injection and data leaks.Pro
- Agent HooksInterceptors that allow, deny or change what an agent does.Pro