Skip to content

docs: use camelCase middleware factory names in agents.mdx JS examples - #4251

Merged
Naomi Pentrel (npentrel) merged 1 commit into
langchain-ai:mainfrom
emmayusufu:docs/agents-middleware-camelcase
Jun 2, 2026
Merged

docs: use camelCase middleware factory names in agents.mdx JS examples#4251
Naomi Pentrel (npentrel) merged 1 commit into
langchain-ai:mainfrom
emmayusufu:docs/agents-middleware-camelcase

Conversation

@emmayusufu

Copy link
Copy Markdown
Contributor

The JavaScript middleware examples in the agents guide use the Python class names (new TodoListMiddleware(), new ModelRetryMiddleware(), etc.), but the langchain package exports these as camelCase factory functions, so the snippets fail to compile ('langchain' has no exported member named 'TodoListMiddleware'). This switches them to the factory functions, matching the package and the middleware/built-in.mdx examples.

piiMiddleware takes a PII type argument in JS (unlike the Python PIIMiddleware()), so that one becomes piiMiddleware("email"). The deepagents middleware (FilesystemMiddleware, SubAgentMiddleware) are genuinely classes and are left as-is. Verified each fixed snippet compiles against langchain 1.4.4.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for opening a docs PR, Kimaswa Emmanuel Yusufu (@emmayusufu)! When it's ready for review, please add the relevant reviewers:

  • @npentrel or @lnhsingh (LangChain)

@github-actions github-actions Bot added external User is not a member of langchain-ai langchain For docs changes to LangChain oss labels Jun 2, 2026

@npentrel Naomi Pentrel (npentrel) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing that!

@npentrel
Naomi Pentrel (npentrel) merged commit db9f95a into langchain-ai:main Jun 2, 2026
18 checks passed
Nishitha M (imnishitha) added a commit that referenced this pull request Jul 7, 2026
## Description

Depends on:
- langchain-ai/deepagents #4251 (override a default middleware by name)
- langchain-ai/deepagents #4325 (tools allowlist on
FilesystemMiddleware)

Documents two related Python deepagents behaviors:
- A `middleware=` (or SubAgent's middleware) instance whose` .name
`matches a default replaces that default in place instead of erroring on
duplicate middleware. Updates the default middleware stack, the
`middleware= `table row, and the `SubAgent.middleware` field
description, and adds a new "Override a default middleware instance"
section with an example.
- The new tools allowlist on `FilesystemMiddleware` for enabling or
disabling individual built-in filesystem tools (`ls, read_file,
write_file, edit_file, delete, glob, grep, execute`), which relies on
the middleware-override behavior above to swap in a restricted
`FilesystemMiddleware` instance. Adds a "Restricting filesystem tools"
example.

Scoped to Python docs only (:::python fences), since both changes only
shipped in the Python SDK.

Test Plan

- [ ] vale (prose lint) passes clean on the changed files
- [ ] markdownlint shows no new violations introduced (same pre-existing
count before/after)

_Opened collaboratively by Nishitha Madhu and open-swe_

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Co-authored-by: ccurme <chester.curme@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external User is not a member of langchain-ai langchain For docs changes to LangChain oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants