GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.langchain.com — Middleware overview - Docs by LangChain Middleware provides a way to more tightly control what happens inside the agent. Middleware is useful for the following:
create_agent:
The agent loopThe core agent loop involves calling a model, letting it choose tools to execute, and then finishing when it calls no more tools:
Middleware exposes hooks before and after each of those steps:
Use middleware inside a LangGraph workflowMiddleware is not a separate runtime: hooks run inside the compiled LangGraph thatcreate_agent returns. You can drop the whole agent (middleware and all) into a larger StateGraph as a node or subgraph, and every middleware hook continues to run.
Reach for this pattern when the surrounding topology is more than a standard “loop until done”: classifying input before routing to one of several agents, fanning out work in parallel, or stitching agent calls together with deterministic steps.
HumanInTheLoopMiddleware matches against each tool’s .name.
@tool-decorated functions take their name from the function, so the key below is "send_email".
Additional resourcesBuilt-in middlewareExplore built-in middleware for common use cases. Custom middlewareBuild your own middleware with hooks and decorators. Middleware API referenceComplete API reference for middleware. Middleware integrationsProvider-specific middleware for Anthropic, AWS, OpenAI, and more. Testing agentsTest your agents with LangSmith. Connect these docs to your agent of choice via MCP for real-time answers. Was this page helpful? |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |