[PR #1015] fix(deepagents): avoid unnecessary REMOVE_ALL_MESSAGES in PatchToolCallsMiddleware #1065

Open
opened 2026-02-16 09:18:03 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagents/pull/1015
Author: @christian-bromann
Created: 2/2/2026
Status: 🔄 Open

Base: mainHead: cb/improve-dangling-toolcall-fix


📝 Commits (2)

  • 1f9a744 fix(deepagents): avoid unnecessary REMOVE_ALL_MESSAGES in PatchToolCallsMiddleware
  • e39ea8a Merge branch 'master' into cb/improve-dangling-toolcall-fix

📊 Changes

2 files changed (+257 additions, -0 deletions)

View changed files

📝 libs/deepagents/deepagents/middleware/patch_tool_calls.py (+7 -0)
libs/deepagents/tests/unit_tests/middleware/test_patch_tool_calls.py (+250 -0)

📄 Description

Adding to check wether we need to update the state if no dangling tool calls were found.

Overwrite is an explicit state replacement signal - When we return {"messages": Overwrite(patched_messages)}, LangGraph will perform a state update operation, replacing the messages entirely. This happens regardless of whether the content is identical to what was already there.

Returning None seems a more performant approach.


🔄 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/deepagents/pull/1015 **Author:** [@christian-bromann](https://github.com/christian-bromann) **Created:** 2/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `cb/improve-dangling-toolcall-fix` --- ### 📝 Commits (2) - [`1f9a744`](https://github.com/langchain-ai/deepagents/commit/1f9a7446c07cf60ba6134f399d6c4f7e93931ad1) fix(deepagents): avoid unnecessary REMOVE_ALL_MESSAGES in PatchToolCallsMiddleware - [`e39ea8a`](https://github.com/langchain-ai/deepagents/commit/e39ea8a18f478d25a988dac2ec31c8510a377122) Merge branch 'master' into cb/improve-dangling-toolcall-fix ### 📊 Changes **2 files changed** (+257 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `libs/deepagents/deepagents/middleware/patch_tool_calls.py` (+7 -0) ➕ `libs/deepagents/tests/unit_tests/middleware/test_patch_tool_calls.py` (+250 -0) </details> ### 📄 Description Adding to check wether we need to update the state if no dangling tool calls were found. Overwrite is an explicit state replacement signal - When we return `{"messages": Overwrite(patched_messages)}`, LangGraph will perform a state update operation, replacing the messages entirely. This happens regardless of whether the content is identical to what was already there. Returning `None` seems a more performant approach. --- <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 09:18:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagents#1065