๐ Agent Middleware
Overviewโ
Control and customize agent execution at every step.
Middleware provides a more fine-grained way to control the internal operations of agents. Middleware is suitable for the following scenarios:
- Track agent behavior through logging, analytics, and debugging.
- Transform prompts, tool selection, and output formats.
- Add retry, fallback, and early termination logic.
- Apply rate limiting, guardrails, and PII detection.
Agent Loopโ
The core agent loop involves calling the model, having the model choose which tools to execute, and then ending when no more tools need to be called:

Middleware exposes hooks before and after each step:

Middleware Nodesโ
In XpertAI, agent nodes support attaching multiple middleware to an Agent in a visual way. Users can manage the order and configuration of middleware in a unified manner in the right panel, achieving the same pluggable Middleware architecture as LangChain.

Each middleware has its own independent configuration panel, where you can adjust its execution parameters and behavior, forming a visual, configurable, and extensible agent execution pipeline.

Click the graph button to open the digital expert agent, and you can see the execution order andๅพช็ฏ relationship between middleware and agents:
