Home / Function/ _build_new_messages() — langchain Function Reference

_build_new_messages() — langchain Function Reference

Architecture documentation for the _build_new_messages() function in summarization.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  92208811_f4d6_b832_02e2_b45867badb82["_build_new_messages()"]
  a622f56b_f697_966d_5bc7_095699ccca34["SummarizationMiddleware"]
  92208811_f4d6_b832_02e2_b45867badb82 -->|defined in| a622f56b_f697_966d_5bc7_095699ccca34
  833a9d39_5a26_a8d9_09c7_26020ad85079["before_model()"]
  833a9d39_5a26_a8d9_09c7_26020ad85079 -->|calls| 92208811_f4d6_b832_02e2_b45867badb82
  ca36a689_bbb0_72cf_124a_722e38d87df0["abefore_model()"]
  ca36a689_bbb0_72cf_124a_722e38d87df0 -->|calls| 92208811_f4d6_b832_02e2_b45867badb82
  style 92208811_f4d6_b832_02e2_b45867badb82 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/summarization.py lines 511–517

    def _build_new_messages(summary: str) -> list[HumanMessage]:
        return [
            HumanMessage(
                content=f"Here is a summary of the conversation to date:\n\n{summary}",
                additional_kwargs={"lc_source": "summarization"},
            )
        ]

Domain

Subdomains

Frequently Asked Questions

What does _build_new_messages() do?
_build_new_messages() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/summarization.py.
Where is _build_new_messages() defined?
_build_new_messages() is defined in libs/langchain_v1/langchain/agents/middleware/summarization.py at line 511.
What calls _build_new_messages()?
_build_new_messages() is called by 2 function(s): abefore_model, before_model.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free