docs(add): add middleware execution flow diagram to custom.mdx #1521
+16
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Adds a detailed
middleware execution flow diagramto the custom middleware documentation to help developers understand the complete agent execution lifecycle and all middleware hook points.Type of change
Type: Update existing documentation
Related issues/PRs
Checklist
docs devsrc/docs.jsonif needed(Internal team members only / optional): Create a preview deployment as necessary using the Create Preview Branch workflow
Additional notes
Changes Made
Motivations
The middleware documentation explains hooks conceptually but lacks a visual representation of how they interact during agent execution. This diagram visualizes:
Complete execution lifecycle from START to completion
Invocation order of all middleware hooks (before_agent, before_model, after_model, after_agent)
Relationship between hooks, model calls, and tool execution
For detailed background, see: What is Middleware in LangChain's createAgent?
Testing Results
✅ make test passed (82 passed in 0.14s)
✅ Locally verified SVG rendering without errors using docs dev
✅ Image displays correctly at http://localhost:3000/oss/langchain/middleware/custom
✅ Follows established patterns from overview.mdx (using
tag with absolute path)
✅ Alt text meets accessibility requirements
Feedback Welcome
If there are suggestions for improving the diagram content, styling, or placement, please provide feedback for a modified PR.