[PR #288] [MERGED] fix(deepagents): handle non-string content blocks in tool result sizechecking #329

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/288
Author: @christian-bromann
Created: 3/9/2026
Status: Merged
Merged: 6/1/2026
Merged by: @hntrl

Base: mainHead: cb/evict-large-toolmessages


📝 Commits (4)

  • fa9576d fix(deepagents): handle non-string content blocks in tool result size checking (#277)
  • acce4e9 Merge branch 'main' into cb/evict-large-toolmessages
  • 80fdaf0 Create sour-gorillas-smoke.md
  • ea0a4f2 Merge branch 'main' into cb/evict-large-toolmessages

📊 Changes

3 files changed (+101 additions, -4 deletions)

View changed files

.changeset/sour-gorillas-smoke.md (+5 -0)
📝 libs/deepagents/src/middleware/fs.test.ts (+91 -0)
📝 libs/deepagents/src/middleware/fs.ts (+5 -4)

📄 Description

Fixes #277

The tool result eviction logic in processToolMessage only checked content when it was a plain string (typeof msg.content === "string"), which meant array-based content blocks (e.g. [{ type: "text", text: "..." }]) bypassed the size limit entirely and were sent back to the agent untruncated.

The fix uses the existing BaseMessage.text getter from @langchain/core, which already handles both content formats:

  • String content: returned as-is
  • Array content blocks: joins all blocks with type === "text" into a single string

This avoids introducing any new utility functions — the upstream API already solves this.

Changes

  • Updated processToolMessage() in fs.ts to use msg.text instead of directly checking msg.content
  • Added 2 unit tests covering array-based content block eviction (large and small)

🔄 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/288 **Author:** [@christian-bromann](https://github.com/christian-bromann) **Created:** 3/9/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@hntrl](https://github.com/hntrl) **Base:** `main` ← **Head:** `cb/evict-large-toolmessages` --- ### 📝 Commits (4) - [`fa9576d`](https://github.com/langchain-ai/deepagentsjs/commit/fa9576da25a7dc34948f377708ba562c6127d1e4) fix(deepagents): handle non-string content blocks in tool result size checking (#277) - [`acce4e9`](https://github.com/langchain-ai/deepagentsjs/commit/acce4e97fddaf7130e4b63310455bf7664bb3f69) Merge branch 'main' into cb/evict-large-toolmessages - [`80fdaf0`](https://github.com/langchain-ai/deepagentsjs/commit/80fdaf0965a1b92257dbba20d76155ee0b4befae) Create sour-gorillas-smoke.md - [`ea0a4f2`](https://github.com/langchain-ai/deepagentsjs/commit/ea0a4f239fac256814c8a2e3949b4de1c0a96ef2) Merge branch 'main' into cb/evict-large-toolmessages ### 📊 Changes **3 files changed** (+101 additions, -4 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/sour-gorillas-smoke.md` (+5 -0) 📝 `libs/deepagents/src/middleware/fs.test.ts` (+91 -0) 📝 `libs/deepagents/src/middleware/fs.ts` (+5 -4) </details> ### 📄 Description Fixes #277 The tool result eviction logic in `processToolMessage` only checked `content` when it was a plain string (`typeof msg.content === "string"`), which meant array-based content blocks (e.g. `[{ type: "text", text: "..." }]`) bypassed the size limit entirely and were sent back to the agent untruncated. The fix uses the existing `BaseMessage.text` getter from `@langchain/core`, which already handles both content formats: - **String content**: returned as-is - **Array content blocks**: joins all blocks with `type === "text"` into a single string This avoids introducing any new utility functions — the upstream API already solves this. ## Changes - Updated `processToolMessage()` in `fs.ts` to use `msg.text` instead of directly checking `msg.content` - Added 2 unit tests covering array-based content block eviction (large and small) --- <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:22:41 -04:00
yindo closed this issue 2026-06-05 17:22:41 -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#329