Skip to content

Commit f57ecbe

Browse files
feat(summarizing_conversation_manager): introduce docs
1 parent 9936ab7 commit f57ecbe

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/user-guide/concepts/agents/context-management.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,42 @@ Key features of the `SlidingWindowConversationManager`:
6464
- **Maintains Window Size**: Automatically removes messages from the window if the number of messages exceeds the limit.
6565
- **Dangling Message Cleanup**: Removes incomplete message sequences to maintain valid conversation state.
6666
- **Overflow Trimming**: In the case of a context window overflow, it will trim the oldest messages from history until the request fits in the models context window.
67+
68+
#### SummarizingConversationManager
69+
70+
The [`SummarizingConversationManager`](../../../api-reference/agent.md#strands.agent.conversation_manager.summarizing_conversation_manager.SummarizingConversationManager) extends the sliding window approach with optional summarization of older messages. Instead of simply discarding old context, it can summarize older messages to preserve important information while staying within context limits.
71+
72+
```python
73+
from strands import Agent
74+
from strands.agent.conversation_manager import SummarizingConversationManager
75+
from strands.models import AnthropicModel
76+
77+
# Create a model for generating summaries
78+
summarizing_model = AnthropicModel(
79+
model_id="claude-opus-4-20250514",
80+
max_tokens=500, # Maximum tokens the model can generate in response
81+
params={
82+
"temperature": 0.3 # Lower temperature for more consistent summaries
83+
},
84+
)
85+
86+
# Create the summarizing conversation manager
87+
conversation_manager = SummarizingConversationManager(
88+
window_size=6, # Maximum number of messages to keep in history
89+
enable_summarization=True, # Enable the feature
90+
summarization_model=summarizing_model, # Use Anthropic model for summaries
91+
summary_ratio=0.5, # Summarize 50% of oldest messages
92+
preserve_recent_messages=3, # Always keep 3 most recent messages
93+
)
94+
95+
agent = Agent(
96+
conversation_manager=conversation_manager
97+
)
98+
```
99+
100+
Key features of the `SummarizingConversationManager`:
101+
102+
- **Intelligent Summarization**: Summarizes older context instead of discarding it, preserving important information.
103+
- **Configurable Strategy**: Control how much of the conversation to summarize and how many recent messages to preserve.
104+
- **Fallback Behavior**: Falls back to sliding window behavior if summarization is disabled or fails.
105+
- **Flexible Model Support**: Use any model for generating summaries, allowing for cost optimization.

0 commit comments

Comments
 (0)