Skip to content

[langchain]: Docs: ContextEditingMiddleware description is misleading regarding summarizing capability #1262

@lesong36

Description

@lesong36

Type of issue

issue / bug

Language

Python

Description

The documentation for the ContextEditingMiddleware (found at https.docs.langchain.com/oss/python/langchain/middleware#context-editing) is confusing and overlaps with the SummarizationMiddleware.

The Problem

The page describes the middleware's purpose as:

Manage conversation context by trimming, summarizing, or clearing tool uses.

This description is misleading for the following reasons:

  1. summarizing is not a built-in feature of this middleware. The only built-in ContextEdit strategy provided in the context_editing.py source code is ClearToolUsesEdit.
  2. It creates confusion with SummarizationMiddleware. LangChain provides a separate, dedicated SummarizationMiddleware at the same level, whose sole purpose is summarizing.
  3. It misrepresents the middleware's function. The current implementation of ContextEditingMiddleware is a framework for applying ContextEdit strategies. The only out-of-the-box strategy provided (ClearToolUsesEdit) is for clearing tool uses, which in turn achieves trimming.

This leads new users to believe that summarizing is an option or configuration within ContextEditingMiddleware, which is incorrect. They should be guided to SummarizationMiddleware for that specific capability.

Suggested Solution

The documentation should be updated to clarify this middleware's specific role and its built-in capabilities, while clearly differentiating it from summarization.

Recommendation:

Change the description from:

Manage conversation context by trimming, summarizing, or clearing tool uses.

To something more precise, like:

Manages conversation context by applying pluggable editing strategies. The built-in ClearToolUsesEdit strategy, for example, trims context by clearing old tool results.

Alternatively, and perhaps even better:

Manages conversation context by applying pluggable editing strategies, such as the built-in ClearToolUsesEdit which removes old tool results.

For context summarization, please see the separate SummarizationMiddleware.

Metadata

Metadata

Assignees

No one assigned

    Labels

    langchainFor docs changes to LangChain

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions