Skip to content

Commit 2eea576

Browse files
authored
refactor(summarization): state rework, move to wrap pattern (#210)
* refactor(summarization): state rework, move to wrap pattern * cr
1 parent 7f82473 commit 2eea576

File tree

6 files changed

+828
-423
lines changed

6 files changed

+828
-423
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"deepagents": patch
3+
---
4+
5+
refactor(summarization): state rework, move to wrap pattern
6+
7+
Refactors `createSummarizationMiddleware` to use the `wrapModelCall` hook instead of `beforeModel`. Instead of rewriting LangGraph state with `RemoveMessage(REMOVE_ALL_MESSAGES)` on each summarization, the middleware now tracks a `SummarizationEvent` in private state and reconstructs the effective message list on each call, avoiding full state rewrites. Supports chained summarizations with correct cutoff index progression.

libs/deepagents/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
},
3939
"homepage": "https://github.com/langchain-ai/deepagentsjs#readme",
4040
"dependencies": {
41-
"@langchain/core": "^1.1.19",
42-
"@langchain/langgraph": "^1.1.3",
41+
"@langchain/core": "^1.1.21",
42+
"@langchain/langgraph": "^1.1.4",
4343
"fast-glob": "^3.3.3",
44-
"langchain": "^1.2.17",
44+
"langchain": "^1.2.20",
4545
"micromatch": "^4.0.8",
4646
"yaml": "^2.8.2",
4747
"zod": "^4.3.6"

libs/deepagents/src/middleware/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export {
4545
// Backend-aware summarization middleware with history offloading
4646
createSummarizationMiddleware,
4747
type SummarizationMiddlewareOptions,
48+
type SummarizationEvent,
4849
type ContextSize,
4950
type TruncateArgsSettings,
5051
// Re-export base summarization middleware from langchain for users who don't need backend offloading

0 commit comments

Comments
 (0)