docs(agents): update manage message history section (#4482)

Co-authored-by: Lauren Hirata Singh <lauren@langchain.dev>
This commit is contained in:
Vadym Barda
2025-04-30 19:11:45 +00:00
committed by GitHub
co-authored by Lauren Hirata Singh
parent d08ed5f42e
commit c5de8f4e50
2 changed files with 54 additions and 5 deletions
@@ -17,8 +17,8 @@
"\n",
"Message history can grow quickly and exceed LLM context window size, whether you're building chatbots with many conversation turns or agentic systems with numerous tool calls. There are several strategies for managing the message history:\n",
"\n",
"* [message trimming](#keep-the-original-message-history-unmodified) - remove first or last N messages in the history\n",
"* [summarization](#summarizing-message-history) - summarize earlier messages in the history and replace them with a summary\n",
"* [message trimming](#keep-the-original-message-history-unmodified) remove first or last N messages in the history\n",
"* [summarization](#summarizing-message-history) summarize earlier messages in the history and replace them with a summary\n",
"* custom strategies (e.g., message filtering, etc.)\n",
"\n",
"To manage message history in `create_react_agent`, you need to define a `pre_model_hook` function or [runnable](https://python.langchain.com/docs/concepts/runnables/) that takes graph state an returns a state update:\n",