[PR #806] [MERGED] feat(deepagents): truncate old write / edit calls in message history #908

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagents/pull/806
Author: @ccurme
Created: 1/16/2026
Status: Merged
Merged: 1/21/2026
Merged by: @ccurme

Base: masterHead: cc/summarization-cleaning


📝 Commits (10+)

📊 Changes

3 files changed (+969 additions, -17 deletions)

View changed files

📝 libs/deepagents/deepagents/graph.py (+10 -0)
📝 libs/deepagents/deepagents/middleware/summarization.py (+270 -17)
📝 libs/deepagents/tests/unit_tests/middleware/test_summarization_middleware.py (+689 -0)

📄 Description

(description added by @mdrxy)

Truncates large write_file and edit_file tool call arguments in older messages to reduce context size without losing important structural information.

As conversations grow, old file write/edit operations consume significant context with content that's no longer relevant. This PR truncates these large arguments while preserving the tool call structure.

Example:

Before truncation:

{
    "name": "write_file",
    "args": {
        "path": "/src/components/Button.tsx",
        "content": "import React from 'react';\n\nexport interface ButtonProps {\n  label: string;\n  onClick: () => void;\n  disabled?: boolean;\n}\n\nexport const Button: React.FC<ButtonProps> = ({ label, onClick, disabled }) => {\n  return (\n    <button onClick={onClick} disabled={disabled}>\n      {label}\n    </button>\n  );\n};\n"
    }
}

After truncation (default max_length=100):

{
    "name": "write_file",
    "args": {
        "path": "/src/components/Button.tsx",
        "content": "import React from 'rea...(argument truncated)"
    }
}

The model can still understand what was written and where, without the full file contents consuming context.


🔄 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/806 **Author:** [@ccurme](https://github.com/ccurme) **Created:** 1/16/2026 **Status:** ✅ Merged **Merged:** 1/21/2026 **Merged by:** [@ccurme](https://github.com/ccurme) **Base:** `master` ← **Head:** `cc/summarization-cleaning` --- ### 📝 Commits (10+) - [`aa718a7`](https://github.com/langchain-ai/deepagents/commit/aa718a7f7f938a905d13a683d43e78971b16dfc3) feat: summarization offloading - [`900af84`](https://github.com/langchain-ai/deepagents/commit/900af849248beeab525cbc98d92de829296e8dbd) lint - [`8086589`](https://github.com/langchain-ai/deepagents/commit/80865891ac51ba71f305d467dc8c78f44f425637) cr - [`e315739`](https://github.com/langchain-ai/deepagents/commit/e3157394126327ad37488aad6a54f91569133dba) Merge branch 'master' into mdrxy/summarization-offloading - [`f6d75b4`](https://github.com/langchain-ai/deepagents/commit/f6d75b465330a8aa6de27b2c989c9a1d56ad8095) Merge branch 'master' into mdrxy/summarization-offloading - [`cbca80b`](https://github.com/langchain-ai/deepagents/commit/cbca80b43ae6c720910feb448ab09ab7d1b44f7e) cr - [`2d8e910`](https://github.com/langchain-ai/deepagents/commit/2d8e91005493816e2ac58f10cec3a307ef85c9ef) cr - [`c87f678`](https://github.com/langchain-ai/deepagents/commit/c87f6786c646a25cdb0442a97b74afbccd6b41e1) cr - [`766b1b0`](https://github.com/langchain-ai/deepagents/commit/766b1b062423f67f5bd7108d800b2b5f80afb73d) override model call tags to render summarization in cli frontend - [`a19333c`](https://github.com/langchain-ai/deepagents/commit/a19333c0d94a750b1a486c60734c24402608b22a) cr ### 📊 Changes **3 files changed** (+969 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `libs/deepagents/deepagents/graph.py` (+10 -0) 📝 `libs/deepagents/deepagents/middleware/summarization.py` (+270 -17) 📝 `libs/deepagents/tests/unit_tests/middleware/test_summarization_middleware.py` (+689 -0) </details> ### 📄 Description (description added by @mdrxy) Truncates large `write_file` and `edit_file` tool call arguments in older messages to reduce context size without losing important structural information. As conversations grow, old file write/edit operations consume significant context with content that's no longer relevant. This PR truncates these large arguments while preserving the tool call structure. **Example:** Before truncation: ```python { "name": "write_file", "args": { "path": "/src/components/Button.tsx", "content": "import React from 'react';\n\nexport interface ButtonProps {\n label: string;\n onClick: () => void;\n disabled?: boolean;\n}\n\nexport const Button: React.FC<ButtonProps> = ({ label, onClick, disabled }) => {\n return (\n <button onClick={onClick} disabled={disabled}>\n {label}\n </button>\n );\n};\n" } } ``` After truncation (default `max_length=100`): ```python { "name": "write_file", "args": { "path": "/src/components/Button.tsx", "content": "import React from 'rea...(argument truncated)" } } ``` The model can still understand *what* was written and *where*, without the full file contents consuming context. --- <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:17:36 -05:00
yindo closed this issue 2026-02-16 09:17:36 -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#908