Skip to content

docs(langchain): fix SummarizationMiddleware AND vs OR trigger logic documentation#2959

Open
Prince (PrinceThummar011) wants to merge 1 commit intolangchain-ai:mainfrom
PrinceThummar011:fix/summarization-middleware-and-or-docs
Open

docs(langchain): fix SummarizationMiddleware AND vs OR trigger logic documentation#2959
Prince (PrinceThummar011) wants to merge 1 commit intolangchain-ai:mainfrom
PrinceThummar011:fix/summarization-middleware-and-or-docs

Conversation

@PrinceThummar011

Summary

Fixes #2027

The SummarizationMiddleware documentation under Built-in middleware →
Configuration options
contained misleading and incorrect information about
the trigger parameter's AND vs OR logic, causing user confusion.

Problem

The Python "Full example" accordion labelled a list of tuples as
"Single condition (AND logic)", then showed a second example — also a
list of tuples — labelled "Multiple conditions (OR logic)". Both
examples were syntactically identical, making it impossible to understand
how AND logic differed from OR logic.

Additionally, the JavaScript trigger ParamField described AND/OR behaviour
in abstract text only, with no code examples to illustrate the difference.

Changes

src/oss/langchain/middleware/built-in.mdx

  • Python trigger ParamField — added a <Note> block explicitly
    stating that Python's ContextSize is a single ("key", value) tuple and
    does not support AND logic. A list of tuples always evaluates as OR
    logic (summarization fires when any one condition is met).
  • JavaScript trigger ParamField — added inline TypeScript code examples
    for both AND logic (trigger: { tokens: 4000, messages: 10 }) and OR logic
    (trigger: [{ tokens: 3000 }, { messages: 6 }]), making the structural
    difference immediately visible.
  • "Full example" accordion (Python bullet list) — added a "No AND
    logic"
    bullet clarifying there is no Python equivalent of JavaScript's
    multi-property AND object.

Type of change

  • Documentation fix (incorrect / misleading content)

Checklist

  • Targets the correct file (src/oss/langchain/middleware/built-in.mdx)
  • No changes to reference/ (auto-generated)
  • docs.json navigation unchanged (no new pages added)
  • Frontmatter intact on all edited files
  • Follows Google Developer Documentation Style Guide

- Clarify Python only supports OR logic (list of tuples)
- Add <Note> explaining Python has no AND logic equivalent
- Add TypeScript code examples to JS ParamField for AND/OR
- Add 'No AND logic' bullet to Full example accordion

Fixes langchain-ai#2027
@github-actions github-actions bot added langchain For docs changes to LangChain oss external User is not a member of langchain-ai labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external User is not a member of langchain-ai langchain For docs changes to LangChain oss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation Issue: Identical code examples for Single (AND) vs Multiple (OR) conditions in SummarizationMiddleware

1 participant