-
Notifications
You must be signed in to change notification settings - Fork 546
Description
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:
summarizingis not a built-in feature of this middleware. The only built-inContextEditstrategy provided in thecontext_editing.pysource code isClearToolUsesEdit.- It creates confusion with
SummarizationMiddleware. LangChain provides a separate, dedicatedSummarizationMiddlewareat the same level, whose sole purpose issummarizing. - It misrepresents the middleware's function. The current implementation of
ContextEditingMiddlewareis a framework for applyingContextEditstrategies. The only out-of-the-box strategy provided (ClearToolUsesEdit) is forclearing tool uses, which in turn achievestrimming.
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
ClearToolUsesEditstrategy, 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
ClearToolUsesEditwhich removes old tool results.For context summarization, please see the separate
SummarizationMiddleware.