This tutorial shows how to use conversation managers to control how an agent's message history grows, shrinks, and stays within model context limits. You'll learn the three built-in strategies: sliding window (default), null (no management), and summarizing.
| Information | Details |
|---|---|
| Strands Features | SlidingWindowConversationManager, NullConversationManager, SummarizingConversationManager |
| Agent Pattern | Single agent with different conversation management strategies |
| Tools | Custom mock tools for demonstrating tool-pair preservation and truncation |
| Model | Amazon Nova Lite on Amazon Bedrock |
- SlidingWindowConversationManager (default) keeps the last N messages, preserving tool-use/tool-result pairs and optionally truncating large tool outputs
- NullConversationManager does nothing — full history is sent every time, and raises an error on overflow
- SummarizingConversationManager summarizes old messages instead of dropping them, preserving context while staying within limits
- Python 3.10 or later
- AWS account with Amazon Bedrock access configured
- Basic familiarity with Strands Agents — see 01-first-agent if needed
17-conversation-management/
├── README.md
├── requirements.txt
└── conversation-management.ipynb
| File | Description |
|---|---|
| conversation-management.ipynb | Step-by-step notebook covering all three conversation managers and their configuration options |
- Default behavior: how
SlidingWindowConversationManagerworks out of the box withwindow_size=40 - Tuning
window_size: choosing the right size based on your use case - Tool-pair preservation: how trimming keeps
toolUse/toolResultpairs together should_truncate_results: truncating large tool outputs before dropping messagesper_turnparameter: proactive management during tool-heavy agent loopsNullConversationManager: disabling management and handling overflow manuallySummarizingConversationManager: summarizing old messages instead of dropping them
Install the required dependencies:
pip install -r requirements.txtThen open conversation-management.ipynb from the 17-conversation-management/ directory.
- 01-first-agent — creating agents (uses default conversation manager)
- 06-memory — persisting agent memory across sessions
- 02-tools-and-mcp — tools that generate large outputs (where truncation matters)