fix(deepagents): merge custom middleware by name - #672
Conversation
🦋 Changeset detectedLatest commit: 2b1c1a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
deepagents-acp
deepagents
@langchain/sandbox-standard-tests
@langchain/daytona
@langchain/deno
@langchain/modal
@langchain/node-vfs
@langchain/quickjs
commit: |
| const novelMiddleware = customMiddleware.filter( | ||
| (middleware) => !defaultMiddlewareNames.has(middleware.name), | ||
| ); | ||
|
|
||
| // Apply profile middleware exclusions. | ||
| let middleware: AgentMiddleware[] = [ | ||
| ...mergeMiddleware( | ||
| coreMiddleware, | ||
| customMiddleware.filter((middleware) => | ||
| coreMiddlewareNames.has(middleware.name), | ||
| ), | ||
| ), | ||
| ...novelMiddleware, |
There was a problem hiding this comment.
🟡 Novel duplicate middleware no longer deduplicates
This bypasses mergeMiddleware for custom names that do not match a default. As a result, middleware: [firstFoo, secondFoo] where both entries are named Foo now inserts both instances into the runtime stack, so both hooks execute. Before this split, mergeMiddleware(coreMiddleware, customMiddleware) applied the documented last-wins behavior to novel names as well. Deduplicate the novel subset by name (for example by merging it into an empty base) before spreading it into the stack.
(Refers to lines 456-467)
Your feedback helps Open SWE learn. React with 👍 or 👎 to tell us if this review comment was useful.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## deepagents@1.11.0 ### Minor Changes - [#671](#671) [`6ae9d1e`](6ae9d1e) Thanks [@hntrl](https://github.com/hntrl)! - feat(filesystem): add allowlist for filesystem middleware tools - [#669](#669) [`4643148`](4643148) Thanks [@hntrl](https://github.com/hntrl)! - feat(deepagents): add structured system prompt configuration - [#673](#673) [`eb18c70`](eb18c70) Thanks [@hntrl](https://github.com/hntrl)! - feat(backends): add delete protocol support Adds a `DeleteResult` type and optional backend `delete` method, preserves delete through backend protocol adaptation, and implements file deletion across the built-in state, store, filesystem, composite, context hub, sandbox, and node-vfs backends. ### Patch Changes - [#691](#691) [`39a7049`](39a7049) Thanks [@colifran](https://github.com/colifran)! - fix(deepagents): backend adapter drops route prefixes - [#672](#672) [`cc26c41`](cc26c41) Thanks [@hntrl](https://github.com/hntrl)! - fix(deepagents): allow custom middleware to replace defaults by name ## deepagents-acp@0.1.19 ### Patch Changes - Updated dependencies [[`39a7049`](39a7049), [`6ae9d1e`](6ae9d1e), [`cc26c41`](cc26c41), [`4643148`](4643148), [`eb18c70`](eb18c70)]: - deepagents@1.11.0 ## @langchain/node-vfs@0.2.1 ### Patch Changes - [#673](#673) [`eb18c70`](eb18c70) Thanks [@hntrl](https://github.com/hntrl)! - feat(backends): add delete protocol support Adds a `DeleteResult` type and optional backend `delete` method, preserves delete through backend protocol adaptation, and implements file deletion across the built-in state, store, filesystem, composite, context hub, sandbox, and node-vfs backends. ## @deepagents/evals@0.0.18 ### Patch Changes - Updated dependencies [[`39a7049`](39a7049), [`6ae9d1e`](6ae9d1e), [`cc26c41`](cc26c41), [`4643148`](4643148), [`eb18c70`](eb18c70)]: - deepagents@1.11.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
## Summary Adds middleware override behavior to replace default middleware by `.name` instead of always being appended. ## Changes - Add name-keyed middleware merging so custom middleware replaces matching default middleware in-place and appends novel middleware after the core stack. - Apply default-slot middleware overrides consistently when constructing main-agent and subagent middleware stacks, while preventing parent-only middleware from propagating unless it matches a subagent default slot. - Move harness tool exclusion into a private `_ToolExclusionMiddleware` helper so excluded tools are stripped after tool-injecting middleware has run. - Add coverage for main-agent replacement, subagent/default override propagation, parent-only middleware isolation, profile exclusions, tool-exclusion ordering, and merge precedence.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## deepagents@1.11.0 ### Minor Changes - [#671](#671) [`6ae9d1e`](6ae9d1e) Thanks [@hntrl](https://github.com/hntrl)! - feat(filesystem): add allowlist for filesystem middleware tools - [#669](#669) [`4643148`](4643148) Thanks [@hntrl](https://github.com/hntrl)! - feat(deepagents): add structured system prompt configuration - [#673](#673) [`eb18c70`](eb18c70) Thanks [@hntrl](https://github.com/hntrl)! - feat(backends): add delete protocol support Adds a `DeleteResult` type and optional backend `delete` method, preserves delete through backend protocol adaptation, and implements file deletion across the built-in state, store, filesystem, composite, context hub, sandbox, and node-vfs backends. ### Patch Changes - [#691](#691) [`39a7049`](39a7049) Thanks [@colifran](https://github.com/colifran)! - fix(deepagents): backend adapter drops route prefixes - [#672](#672) [`cc26c41`](cc26c41) Thanks [@hntrl](https://github.com/hntrl)! - fix(deepagents): allow custom middleware to replace defaults by name ## deepagents-acp@0.1.19 ### Patch Changes - Updated dependencies [[`39a7049`](39a7049), [`6ae9d1e`](6ae9d1e), [`cc26c41`](cc26c41), [`4643148`](4643148), [`eb18c70`](eb18c70)]: - deepagents@1.11.0 ## @langchain/node-vfs@0.2.1 ### Patch Changes - [#673](#673) [`eb18c70`](eb18c70) Thanks [@hntrl](https://github.com/hntrl)! - feat(backends): add delete protocol support Adds a `DeleteResult` type and optional backend `delete` method, preserves delete through backend protocol adaptation, and implements file deletion across the built-in state, store, filesystem, composite, context hub, sandbox, and node-vfs backends. ## @deepagents/evals@0.0.18 ### Patch Changes - Updated dependencies [[`39a7049`](39a7049), [`6ae9d1e`](6ae9d1e), [`cc26c41`](cc26c41), [`4643148`](4643148), [`eb18c70`](eb18c70)]: - deepagents@1.11.0 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
Adds middleware override behavior to replace default middleware by
.nameinstead of always being appended.Changes
_ToolExclusionMiddlewarehelper so excluded tools are stripped after tool-injecting middleware has run.