docs(langchain): document summarization prompt contract (#38256)

Adds a contract note for the default summarization prompt so future
edits preserve the pieces downstream consumers depend on. The key risk
is not the prompt text itself, but the `<messages>` marker and
`{messages}` placeholder that other middleware uses to splice in
additional instructions.
This commit is contained in:
Mason Daugherty
2026-06-18 16:35:30 -04:00
committed by GitHub
parent a807a9c7f6
commit a979105085

View File

@@ -76,6 +76,17 @@ Respond ONLY with the extracted context. Do not include any additional informati
Messages to summarize:
{messages}
</messages>""" # noqa: E501
"""Default prompt used to summarize conversation history.
The `<messages>` marker (on its own line) and the `{messages}` placeholder are
part of this constant's public contract, not just cosmetic formatting.
Downstream consumers depend on them: for example, deep agents'
`SummarizationMiddleware` splices an extra instruction block in immediately
before the `<messages>` marker via `str.replace`. Removing, renaming, or
reformatting the marker (or the `{messages}` placeholder) is a breaking change
for those consumers even though it does not alter any function signature, so
treat edits to it accordingly.
"""
_DEFAULT_MESSAGES_TO_KEEP = 20
_DEFAULT_TRIM_TOKEN_LIMIT = 4000