[PR #145] [MERGED] fix(deepagents): use new StateSchema class #155

Closed
opened 2026-02-16 06:17:18 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/145
Author: @christian-bromann
Created: 1/26/2026
Status: Merged
Merged: 1/28/2026
Merged by: @christian-bromann

Base: mainHead: cb/state-reducer


📝 Commits (9)

📊 Changes

11 files changed (+1263 additions, -93 deletions)

View changed files

📝 libs/cli/src/index.test.ts (+1 -1)
📝 libs/deepagents/package.json (+10 -10)
libs/deepagents/src/middleware/fs.test.ts (+314 -0)
📝 libs/deepagents/src/middleware/fs.ts (+53 -21)
📝 libs/deepagents/src/middleware/skills.test.ts (+191 -1)
📝 libs/deepagents/src/middleware/skills.ts (+73 -21)
📝 libs/deepagents/src/middleware/subagents.int.test.ts (+93 -1)
📝 libs/deepagents/src/middleware/subagents.ts (+0 -3)
📝 libs/deepagents/tsdown.config.ts (+5 -0)
📝 package.json (+8 -8)
📝 pnpm-lock.yaml (+515 -27)

📄 Description

This PR fixes a LangGraph LastValue channel error that occurs when parallel subagents update state simultaneously. The fix migrates state schemas to use LangGraph's new StateSchema class with ReducedValue to enable proper concurrent state updates.

Problem: When skills or filesystem middleware is enabled and multiple subagents run in parallel, each subagent returns state updates (e.g., skillsMetadata, files). Since these fields used implicit LastValue semantics (no custom reducer), LangGraph fails with:

Invalid update for channel "skillsMetadata" with values [[...],[...],[...]]:
LastValue can only receive one value per step.

Solution: Use StateSchema with ReducedValue and custom reducers that properly merge concurrent updates:

  • skillsMetadataReducer: Merges skill arrays, deduplicating by name (later values override earlier)
  • fileDataReducer: Merges file records with support for deletions (null values remove files)

closes #142
fixes #143
fixes #144
fixes #122


🔄 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/145 **Author:** [@christian-bromann](https://github.com/christian-bromann) **Created:** 1/26/2026 **Status:** ✅ Merged **Merged:** 1/28/2026 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `main` ← **Head:** `cb/state-reducer` --- ### 📝 Commits (9) - [`f9e276d`](https://github.com/langchain-ai/deepagentsjs/commit/f9e276d7d797a20ace393cff811ea00a45c72bc3) fix(deepagents): use new StateSchema class - [`487b28a`](https://github.com/langchain-ai/deepagentsjs/commit/487b28af653bb5904cff4654431496a0d60443af) format - [`0fdbfb3`](https://github.com/langchain-ai/deepagentsjs/commit/0fdbfb3f770aa8e9af9581b57f084cfe45bc41e9) fix bundling - [`822fa7c`](https://github.com/langchain-ai/deepagentsjs/commit/822fa7c06d6949f9cf19fd70bc22421e971a1ae8) run unit tests also in windows - [`fca3792`](https://github.com/langchain-ai/deepagentsjs/commit/fca3792dcce0377701ba72a256702b2d383a78ef) revert - [`48a7fd9`](https://github.com/langchain-ai/deepagentsjs/commit/48a7fd943c8c51acd14db0c2590be8ea37ccea5c) fix windows test issue - [`0e5f621`](https://github.com/langchain-ai/deepagentsjs/commit/0e5f62181b431ed5a00c472433e435be1282f704) bump lc - [`0b6c6f6`](https://github.com/langchain-ai/deepagentsjs/commit/0b6c6f6fb6eaec2823be333d666d92fe48979252) bump lc - [`9079963`](https://github.com/langchain-ai/deepagentsjs/commit/90799639dfd2e4ec4e8db3a3b0a606c1754c7add) path normalization ### 📊 Changes **11 files changed** (+1263 additions, -93 deletions) <details> <summary>View changed files</summary> 📝 `libs/cli/src/index.test.ts` (+1 -1) 📝 `libs/deepagents/package.json` (+10 -10) ➕ `libs/deepagents/src/middleware/fs.test.ts` (+314 -0) 📝 `libs/deepagents/src/middleware/fs.ts` (+53 -21) 📝 `libs/deepagents/src/middleware/skills.test.ts` (+191 -1) 📝 `libs/deepagents/src/middleware/skills.ts` (+73 -21) 📝 `libs/deepagents/src/middleware/subagents.int.test.ts` (+93 -1) 📝 `libs/deepagents/src/middleware/subagents.ts` (+0 -3) 📝 `libs/deepagents/tsdown.config.ts` (+5 -0) 📝 `package.json` (+8 -8) 📝 `pnpm-lock.yaml` (+515 -27) </details> ### 📄 Description This PR fixes a LangGraph `LastValue` channel error that occurs when parallel subagents update state simultaneously. The fix migrates state schemas to use LangGraph's new `StateSchema` class with `ReducedValue` to enable proper concurrent state updates. **Problem:** When skills or filesystem middleware is enabled and multiple subagents run in parallel, each subagent returns state updates (e.g., `skillsMetadata`, `files`). Since these fields used implicit `LastValue` semantics (no custom reducer), LangGraph fails with: ``` Invalid update for channel "skillsMetadata" with values [[...],[...],[...]]: LastValue can only receive one value per step. ``` **Solution:** Use `StateSchema` with `ReducedValue` and custom reducers that properly merge concurrent updates: - `skillsMetadataReducer`: Merges skill arrays, deduplicating by name (later values override earlier) - `fileDataReducer`: Merges file records with support for deletions (null values remove files) closes #142 fixes #143 fixes #144 fixes #122 --- <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-02-16 06:17:18 -05:00
yindo closed this issue 2026-02-16 06:17:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#155