LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Configuration
  • Types
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
  • Vitest
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsConfigurationTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentsmiddlewarecreateSummarizationMiddleware
Function●Since v1.6

createSummarizationMiddleware

Create summarization middleware with backend support for conversation history offloading.

This middleware:

  1. Monitors conversation length against configured thresholds
  2. When triggered, offloads old messages to backend storage
  3. Generates a summary of offloaded messages
  4. Replaces old messages with the summary, preserving recent context
Copy
createSummarizationMiddleware(
  options: SummarizationMiddlewareOptions
): AgentMiddleware<ZodObject<__type, strip>, undefined, unknown, readonly ClientTool | ServerTool[]>

Parameters

NameTypeDescription
options*SummarizationMiddlewareOptions

Configuration options

View source on GitHub