[PR #392] [MERGED] refactor(deepagents): clean up createDeepAgent middleware wiring #419

Closed
opened 2026-06-05 17:23:00 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/392
Author: @hntrl
Created: 3/30/2026
Status: Merged
Merged: 4/1/2026
Merged by: @hntrl

Base: alphaHead: hunter/middleware-order


📝 Commits (4)

  • 070568a refactor(deepagents): clean up createDeepAgent middleware wiring
  • 5208d94 fix(deepagents): avoid duplicate HITL middleware on subagents
  • faad8bb add comments, remove iife
  • fe9cfde Create ten-masks-flow.md

📊 Changes

4 files changed (+217 additions, -217 deletions)

View changed files

.changeset/ten-masks-flow.md (+5 -0)
📝 libs/deepagents/package.json (+1 -1)
📝 libs/deepagents/src/agent.ts (+197 -214)
📝 pnpm-lock.yaml (+14 -2)

📄 Description

Summary

This refactor cleans up createDeepAgent so the middleware pipeline lines up with the python implementation of deepagents. Along the way, the system prompt composition and subagent normalization were tightened up to keep cache/memory behavior and type inference stable, as well as giving a refresh to the createDeepAgent jsdocs.

Changes

  • libs/deepagents/src/agent.ts
    • Refactors createDeepAgent middleware assembly to keep ordering explicit and consistent.
    • Simplifies async vs inline subagent filtering and keeps general-purpose subagent insertion explicit.
    • Normalizes subagent middleware composition (including optional skills, cache middleware, and HITL behavior).
    • Updates createDeepAgent JSDoc to be product-facing and deepagents-native.
    • Switches base prompt handling to context + explicit SystemMessage block composition.
  • libs/deepagents/src/utils.ts
    • Adds a small iife helper used to keep local value construction readable.
  • libs/deepagents/package.json and pnpm-lock.yaml
    • Bumps @langchain/anthropic dev dependency to support the updated defaults used in this refactor.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/392 **Author:** [@hntrl](https://github.com/hntrl) **Created:** 3/30/2026 **Status:** ✅ Merged **Merged:** 4/1/2026 **Merged by:** [@hntrl](https://github.com/hntrl) **Base:** `alpha` ← **Head:** `hunter/middleware-order` --- ### 📝 Commits (4) - [`070568a`](https://github.com/langchain-ai/deepagentsjs/commit/070568a0cbf2301ded16962c37b3154ac2ff0923) refactor(deepagents): clean up createDeepAgent middleware wiring - [`5208d94`](https://github.com/langchain-ai/deepagentsjs/commit/5208d9460913c365adec94a1a6235478197b6d91) fix(deepagents): avoid duplicate HITL middleware on subagents - [`faad8bb`](https://github.com/langchain-ai/deepagentsjs/commit/faad8bbba23a359e98ad493259bf9d61a4bce2c9) add comments, remove iife - [`fe9cfde`](https://github.com/langchain-ai/deepagentsjs/commit/fe9cfde7a90a8642ad2e057fa840e2050bd595f7) Create ten-masks-flow.md ### 📊 Changes **4 files changed** (+217 additions, -217 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/ten-masks-flow.md` (+5 -0) 📝 `libs/deepagents/package.json` (+1 -1) 📝 `libs/deepagents/src/agent.ts` (+197 -214) 📝 `pnpm-lock.yaml` (+14 -2) </details> ### 📄 Description ## Summary This refactor cleans up `createDeepAgent` so the middleware pipeline lines up with the python implementation of deepagents. Along the way, the system prompt composition and subagent normalization were tightened up to keep cache/memory behavior and type inference stable, as well as giving a refresh to the `createDeepAgent` jsdocs. ## Changes - **`libs/deepagents/src/agent.ts`** - Refactors `createDeepAgent` middleware assembly to keep ordering explicit and consistent. - Simplifies async vs inline subagent filtering and keeps general-purpose subagent insertion explicit. - Normalizes subagent middleware composition (including optional skills, cache middleware, and HITL behavior). - Updates `createDeepAgent` JSDoc to be product-facing and deepagents-native. - Switches base prompt handling to `context` + explicit `SystemMessage` block composition. - **`libs/deepagents/src/utils.ts`** - Adds a small `iife` helper used to keep local value construction readable. - **`libs/deepagents/package.json` and `pnpm-lock.yaml`** - Bumps `@langchain/anthropic` dev dependency to support the updated defaults used in this refactor. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 17:23:00 -04:00
yindo closed this issue 2026-06-05 17:23:00 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#419