# createSummarizationMiddleware

> **Function** in `deepagents`

📖 [View in docs](https://reference.langchain.com/javascript/deepagents/middleware/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

## Signature

```javascript
createSummarizationMiddleware(options: SummarizationMiddlewareOptions): AgentMiddleware<ZodObject<__type, $strip>, undefined, unknown, readonly ClientTool | ServerTool[], readonly []>
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `options` | `SummarizationMiddlewareOptions` | Yes | Configuration options |

## Returns

`AgentMiddleware<ZodObject<__type, $strip>, undefined, unknown, readonly ClientTool | ServerTool[], readonly []>`

AgentMiddleware for summarization and history offloading

---

[View source on GitHub](https://github.com/langchain-ai/deepagentsjs/blob/60e32118b0ba24ea7ef636476a9a96add9d1a99b/libs/deepagents/src/middleware/summarization.ts#L297)