Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: fix manual summarization (#6466)
Sarah Wooders90e2030f4131
diff --git a/letta/agents/letta_agent_v2.py b/letta/agents/letta_agent_v2.pyindex 7b2723b30..3969a8f1d 100644--- a/letta/agents/letta_agent_v2.py+++ b/letta/agents/letta_agent_v2.py@@ -1208,6 +1208,7 @@ class LettaAgentV2(BaseAgentV2):total_tokens: int | None = None,force: bool = False,) -> list[Message]:+ self.logger.warning("Running deprecated v2 summarizer. This should be removed in the future.")# always skip summarization if last message is an approval request messageskip_summarization = Falselatest_messages = in_context_messages + new_letta_messagesdiff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.pyindex 7e8330c98..be46a2d7e 100644--- a/letta/server/rest_api/routers/v1/agents.py+++ b/letta/server/rest_api/routers/v1/agents.py@@ -16,6 +16,7 @@ from letta.agents.agent_loop import AgentLoopfrom letta.agents.base_agent_v2 import BaseAgentV2from letta.agents.letta_agent import LettaAgentfrom letta.agents.letta_agent_v2 import LettaAgentV2+from letta.agents.letta_agent_v3 import LettaAgentV3from letta.constants import DEFAULT_MAX_STEPS, DEFAULT_MESSAGE_TOOL, DEFAULT_MESSAGE_TOOL_KWARG, REDIS_RUN_ID_PREFIXfrom letta.data_sources.redis_client import get_redis_clientfrom letta.errors import (@@ -2107,7 +2108,7 @@ async def summarize_messages(]if agent_eligible and model_compatible:- agent_loop = LettaAgentV2(agent_state=agent, actor=actor)+ agent_loop = LettaAgentV3(agent_state=agent, actor=actor)in_context_messages = await server.message_manager.get_messages_by_ids_async(message_ids=agent.message_ids, actor=actor)await agent_loop.summarize_conversation_history(in_context_messages=in_context_messages,diff --git a/letta/services/summarizer/summarizer_sliding_window.py b/letta/services/summarizer/summarizer_sliding_window.pyindex 29c530a9d..e1f9f3504 100644--- a/letta/services/summarizer/summarizer_sliding_window.py+++ b/letta/services/summarizer/summarizer_sliding_window.py@@ -80,6 +80,10 @@ async def summarize_via_sliding_window(# Mark the approximate cutoffmessage_cutoff_index = round(message_count_cutoff_percent * len(all_in_context_messages))+ # we've reached the maximum message cutoff+ if message_cutoff_index >= total_message_count:+ break+# Walk up the list until we find the first assistant messagefor i in range(message_cutoff_index, total_message_count):if all_in_context_messages[i].role == MessageRole.assistant: