[PR #555] fix(deepagents): bump langchain to ^1.4.2 to fix Buffer.from(undefined) crash in v3 stream #557

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/555
Author: @anouar-bm
Created: 5/24/2026
Status: 🔄 Open

Base: mainHead: fix/bundle-langchain-1.4.2-buffer-from-crash


📝 Commits (4)

  • 08ca6ef fix(deepagents): bump langchain to ^1.4.2 to fix Buffer.from(undefined) crash in v3 stream
  • 525211f chore: update pnpm-lock.yaml for langchain ^1.4.2
  • 49402d0 fix(deepagents): bump langgraph to ^1.3.2 and add explicit return types to fix TS2883
  • f608bec fix(deepagents): restore middleware state inference, remove AgentMiddleware annotations

📊 Changes

5 files changed (+50 additions, -127 deletions)

View changed files

📝 libs/deepagents/package.json (+2 -2)
📝 libs/deepagents/src/agent.ts (+0 -14)
📝 libs/deepagents/src/middleware/async_subagents.ts (+2 -1)
📝 libs/deepagents/src/middleware/memory.ts (+3 -1)
📝 pnpm-lock.yaml (+43 -109)

📄 Description

Summary

  • Bumps langchain dependency from ^1.4.0^1.4.2 in libs/deepagents/package.json
  • Ensures the next build includes the fix from langchain-ai/langchainjs#10900 ("fix(langchain): unwrap tool message outputs in agent streams")

Root cause

deepagents bundles langchain into dist/index.js via tsdown. The 1.10.2 bundle was built against langchain ^1.4.0, which predates the fix in 1.4.2. Upgrading langchain in a host project has no effect — the bundled copy inside dist/index.js still contains the pre-fix code.

Symptom (follow-up to #534)

When using v3 streamEvents and a tool call fails then retries (e.g. write_code op=replace after a compile error), the stream crashes with:

Error: The first argument must be of type string or an instance of Buffer,
       ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Object.process (langchain/src/agents/stream.ts:327:36)
    at StreamMux.push (@langchain/langgraph/src/stream/mux.ts:287:24)
    at pump            (@langchain/langgraph/src/stream/mux.ts:499:13)

The crash fires because the pre-1.4.2 messages transformer calls Buffer.from(content) where content is undefined when a ToolMessage carries an array-typed content field (a tool_call block with no text). This is the same underlying bug as #534 — tool message content not unwrapped before the Buffer.from call.

Fix

Bumping to ^1.4.2 ensures the fixed unwrap logic is compiled into the next published bundle.

Test plan

  • pnpm build in libs/deepagents resolves langchain ≥ 1.4.2
  • v3 streamEvents no longer crashes when a tool call fails and retries in a multi-step run

🔄 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/555 **Author:** [@anouar-bm](https://github.com/anouar-bm) **Created:** 5/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/bundle-langchain-1.4.2-buffer-from-crash` --- ### 📝 Commits (4) - [`08ca6ef`](https://github.com/langchain-ai/deepagentsjs/commit/08ca6ef36e88310556a7d67cd19a435ed27637c7) fix(deepagents): bump langchain to ^1.4.2 to fix Buffer.from(undefined) crash in v3 stream - [`525211f`](https://github.com/langchain-ai/deepagentsjs/commit/525211fe6f213404a19645a269056fefb2a2c0e2) chore: update pnpm-lock.yaml for langchain ^1.4.2 - [`49402d0`](https://github.com/langchain-ai/deepagentsjs/commit/49402d0350ab5c9791037681a694b4d5ffbf8367) fix(deepagents): bump langgraph to ^1.3.2 and add explicit return types to fix TS2883 - [`f608bec`](https://github.com/langchain-ai/deepagentsjs/commit/f608bec62b1801063c082bb887eb935f968e3490) fix(deepagents): restore middleware state inference, remove AgentMiddleware<undefined> annotations ### 📊 Changes **5 files changed** (+50 additions, -127 deletions) <details> <summary>View changed files</summary> 📝 `libs/deepagents/package.json` (+2 -2) 📝 `libs/deepagents/src/agent.ts` (+0 -14) 📝 `libs/deepagents/src/middleware/async_subagents.ts` (+2 -1) 📝 `libs/deepagents/src/middleware/memory.ts` (+3 -1) 📝 `pnpm-lock.yaml` (+43 -109) </details> ### 📄 Description ## Summary - Bumps `langchain` dependency from `^1.4.0` → `^1.4.2` in `libs/deepagents/package.json` - Ensures the next build includes the fix from langchain-ai/langchainjs#10900 ("fix(langchain): unwrap tool message outputs in agent streams") ## Root cause deepagents bundles langchain into `dist/index.js` via `tsdown`. The 1.10.2 bundle was built against `langchain ^1.4.0`, which predates the fix in 1.4.2. Upgrading langchain in a host project has no effect — the bundled copy inside `dist/index.js` still contains the pre-fix code. ## Symptom (follow-up to #534) When using `v3` `streamEvents` and a tool call fails then retries (e.g. `write_code op=replace` after a compile error), the stream crashes with: ``` Error: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined at Object.process (langchain/src/agents/stream.ts:327:36) at StreamMux.push (@langchain/langgraph/src/stream/mux.ts:287:24) at pump (@langchain/langgraph/src/stream/mux.ts:499:13) ``` The crash fires because the pre-1.4.2 messages transformer calls `Buffer.from(content)` where `content` is `undefined` when a `ToolMessage` carries an array-typed `content` field (a `tool_call` block with no text). This is the same underlying bug as #534 — tool message content not unwrapped before the `Buffer.from` call. ## Fix Bumping to `^1.4.2` ensures the fixed unwrap logic is compiled into the next published bundle. ## Test plan - [ ] `pnpm build` in `libs/deepagents` resolves langchain ≥ 1.4.2 - [ ] v3 `streamEvents` no longer crashes when a tool call fails and retries in a multi-step run --- <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:44 -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#557