LangGraph middleware¶
Middleware adapts model requests before provider invocation. AI Hub currently uses it for:
- tenant/user-aware dynamic prompts;
- active-agent and tool filtering;
- message-count and token-count history limits;
- persisted conversation summarization;
- cleanup of tool-call history and specialist-specific context.
Agents are created with langchain.agents.create_agent and receive middleware
instances or decorated dynamic-prompt functions: