You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**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) implements intelligent conversation context management by summarizing older messages instead of simply discarding them. This approach preserves important information while staying within context limits.
71
+
72
+
Configuration parameters:
73
+
74
+
-**`summary_ratio`** (float, default: 0.3): Percentage of messages to summarize when reducing context (clamped between 0.1 and 0.8)
75
+
-**`preserve_recent_messages`** (int, default: 10): Minimum number of recent messages to always keep
76
+
-**`summarization_agent`** (Agent, optional): Custom agent for generating summaries. If not provided, uses the main agent instance. Cannot be used together with `summarization_system_prompt`.
77
+
-**`summarization_system_prompt`** (str, optional): Custom system prompt for summarization. If not provided, uses a default prompt that creates structured bullet-point summaries focusing on key topics, tools used, and technical information in third-person format. Cannot be used together with `summarization_agent`.
78
+
79
+
**Basic Usage:**
80
+
81
+
By default, the `SummarizingConversationManager` leverages the same model and configuration as your main agent to perform summarization.
82
+
83
+
```python
84
+
from strands import Agent
85
+
from strands.agent.conversation_manager import SummarizingConversationManager
**Advanced Configuration with Custom Summarization Agent:**
138
+
139
+
For advanced use cases, you can provide a custom `summarization_agent` to handle the summarization process. This enables using a different model (such as a faster or a more cost-effective one), incorporating tools during summarization, or implementing specialized summarization logic tailored to your domain. The custom agent can leverage its own system prompt, tools, and model configuration to generate summaries that best preserve the essential context for your specific use case.
140
+
141
+
```python
142
+
from strands import Agent
143
+
from strands.agent.conversation_manager import SummarizingConversationManager
144
+
from strands.models import AnthropicModel
145
+
146
+
# Create a cheaper, faster model for summarization tasks
147
+
summarization_model = AnthropicModel(
148
+
model_id="claude-haiku-4-20250514", # More cost-effective for summarization
149
+
max_tokens=1000,
150
+
params={"temperature": 0.1} # Low temperature for consistent summaries
0 commit comments