Back Home

GitHub Repo

LangChain Community Reports Summary Validation Gap That Could Cause Agents to Lose Working Context

A LangChain community report dated October 20 says the middleware may remove original messages when a summarization model returns blank text, silently leaving agents without context. The report includes a minimal reproduction and a proposed fix, but no maintainer confirmation or verifiable release containing a fix is available yet.

Dirck van Baburen · Public domain · Image source
zh-Hant

A new edge case has emerged in LangChain’s conversation compaction mechanism. A report filed on October 20 says SummarizationMiddleware may still replace messages when it receives a blank summary, causing an agent to continue with context that is missing key information. The reported environment used langchain 1.4.6 and langchain-core 1.6.12. The issue remains open, and it cannot be assumed that all versions are affected. Community report

The middleware is designed to support long conversations: after a configured threshold is reached, it compresses older messages into a text summary while retaining recent content. The official documentation lists trigger conditions based on token count, message count, and context ratio; keep controls how much recent content is retained. The summary is therefore responsible for preserving older information, rather than serving as optional supplementary text. Official documentation

The reporter used a mock model that always returns an empty string, with the trigger set to six messages and two messages retained. In the example, the agent first reads a file and remembers a code, then is asked to read another file. The resulting update contains only the summary header and the final tool interaction; neither the earlier code nor the latest user instruction is retained, and no error is raised. This is an inspectable minimal case, not a measurement of how often the problem occurs with real model services. Reproduction code and output

The technical issue is a gap between a successful model call and a valid summary. According to the report’s analysis, the relevant path obtains the text and strips leading and trailing whitespace, then proceeds to replace history without first rejecting an empty result. Participants proposed raising an exception before creating deletion messages and applying the same check to synchronous, asynchronous, and custom summarizers. Another option is to skip compaction for that turn, at the cost of continued context growth. These remain proposed fixes. Technical discussion

For engineering teams, this case highlights the need for compaction workflows to have an independent success condition. Based on the mechanism described above, validation should check whether a blank summary preserves the original state and whether user instructions and tool results remain traceable after compaction. Worth watching are the failure-handling strategy maintainers adopt and whether the fix covers all execution paths. The available evidence is insufficient to claim that complete conversations in persistent databases were permanently deleted.

Sources

  1. SummarizationMiddleware deletes conversation history when the summary model returns an empty reply · Issue #41323
  2. Prebuilt middleware — Summarization