Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Summarizing conversation history management with configurable options."""

import logging
from typing import TYPE_CHECKING, Any, List, Optional
from typing import TYPE_CHECKING, Any, List, Optional, cast

from typing_extensions import override

Expand Down Expand Up @@ -201,8 +201,7 @@ def _generate_summary(self, messages: List[Message], agent: "Agent") -> Message:

# Use the agent to generate summary with rich content (can use tools if needed)
result = summarization_agent("Please summarize this conversation.")

return result.message
return cast(Message, {**result.message, "role": "user"})

finally:
# Restore original agent state
Expand Down
4 changes: 2 additions & 2 deletions tests/strands/agent/test_summarizing_conversation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_reduce_context_with_summarization(summarizing_manager, mock_agent):
assert len(mock_agent.messages) == 4

# First message should be the summary
assert mock_agent.messages[0]["role"] == "assistant"
assert mock_agent.messages[0]["role"] == "user"
first_content = mock_agent.messages[0]["content"][0]
assert "text" in first_content and "This is a summary of the conversation." in first_content["text"]

Expand Down Expand Up @@ -438,7 +438,7 @@ def test_reduce_context_tool_pair_adjustment_works_with_forward_search():
assert len(mock_agent.messages) == 2

# First message should be the summary
assert mock_agent.messages[0]["role"] == "assistant"
assert mock_agent.messages[0]["role"] == "user"
summary_content = mock_agent.messages[0]["content"][0]
assert "text" in summary_content and "This is a summary of the conversation." in summary_content["text"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_summarization_with_context_overflow(model):

# First message should be the summary (assistant message)
summary_message = agent.messages[0]
assert summary_message["role"] == "assistant"
assert summary_message["role"] == "user"
assert len(summary_message["content"]) > 0

# Verify the summary contains actual text content
Expand Down Expand Up @@ -362,7 +362,7 @@ def test_dedicated_summarization_agent(model, summarization_model):

# Get the summary message
summary_message = agent.messages[0]
assert summary_message["role"] == "assistant"
assert summary_message["role"] == "user"

# Extract summary text
summary_text = None
Expand Down
Loading