๐ ๐ถ๐ฑ๐ฑ๐น๐ฒ๐๐ฎ๐ฟ๐ฒ ๐ถ๐ป ๐๐ฒ๐ฒ๐ฝ๐๐ด๐ฒ๐ป๐๐
Middleware sits between parts of your agent system. It manages the flow of information.
In Deep Agents, middleware works between the user request, the model, and tool execution.
You use different types of middleware for different jobs:
- TodoListMiddleware: Manages task lists for complex requests.
- PatchToolCallsMiddleware: Validates tool-calling.
- Logging Middleware: Records events.
- Summarization Middleware: Summarizes conversation history.
Not all middleware verify data. Some track progress. Others log activity.
The framework adds some middleware automatically. Use create_deep_agent() and you get TodoListMiddleware and PatchToolCallsMiddleware.
TodoListMiddleware creates a plan. Ask for the weather of the most popular city in India. The middleware makes a list:
- Find the most popular city.
- Get the weather for it.
Tool outputs go to the agent state. The middleware only tracks progress.
Some middleware come by default. You add others based on your needs.
Source: https://dev.to/uma_baleboyina_1cb374cc73/middleware-in-deepagents-3la0 Optional learning community: https://t.me/GyaanSetuAi