Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: remove recent passages and data source alert (#1887)
Kevin Linbd27718a1738
diff --git a/letta/agent.py b/letta/agent.pyindex 355d6d6e8..803cb4c0e 100644--- a/letta/agent.py+++ b/letta/agent.py@@ -1233,7 +1233,6 @@ class Agent(BaseAgent):memory_edit_timestamp=get_utc_time(),previous_message_count=self.message_manager.size(actor=self.user, agent_id=self.agent_state.id),archival_memory_size=self.agent_manager.passage_size(actor=self.user, agent_id=self.agent_state.id),- recent_passages=self.agent_manager.list_passages(actor=self.user, agent_id=self.agent_state.id, ascending=False, limit=10),)num_tokens_external_memory_summary = count_tokens(external_memory_summary)diff --git a/letta/services/agent_manager.py b/letta/services/agent_manager.pyindex 993490706..b656049af 100644--- a/letta/services/agent_manager.py+++ b/letta/services/agent_manager.py@@ -1412,7 +1412,6 @@ class AgentManager:system_prompt=agent_state.system,in_context_memory=agent_state.memory,in_context_memory_last_edit=memory_edit_timestamp,- recent_passages=self.list_passages(actor=actor, agent_id=agent_id, ascending=False, limit=10),previous_message_count=num_messages,archival_memory_size=num_archival_memories,)@@ -1476,12 +1475,10 @@ class AgentManager:num_archival_memories = await self.passage_manager.size_async(actor=actor, agent_id=agent_id)# update memory (TODO: potentially update recall/archival stats separately)- recent_passages = await self.list_passages_async(actor=actor, agent_id=agent_id, ascending=False, limit=10)new_system_message_str = compile_system_message(system_prompt=agent_state.system,in_context_memory=agent_state.memory,in_context_memory_last_edit=memory_edit_timestamp,- recent_passages=recent_passages,previous_message_count=num_messages,archival_memory_size=num_archival_memories,)diff --git a/letta/services/helpers/agent_manager_helper.py b/letta/services/helpers/agent_manager_helper.pyindex 23146bbcb..7c1429ade 100644--- a/letta/services/helpers/agent_manager_helper.py+++ b/letta/services/helpers/agent_manager_helper.py@@ -18,7 +18,6 @@ from letta.schemas.enums import MessageRolefrom letta.schemas.letta_message_content import TextContentfrom letta.schemas.memory import Memoryfrom letta.schemas.message import Message, MessageCreate-from letta.schemas.passage import Passage as PydanticPassagefrom letta.schemas.tool_rule import ToolRulefrom letta.schemas.user import Userfrom letta.system import get_initial_boot_messages, get_login_event, package_function_response@@ -176,7 +175,6 @@ def compile_memory_metadata_block(memory_edit_timestamp: datetime.datetime,previous_message_count: int = 0,archival_memory_size: int = 0,- recent_passages: List[PydanticPassage] = None,) -> str:# Put the timestamp in the local timezone (mimicking get_local_time())timestamp_str = memory_edit_timestamp.astimezone().strftime("%Y-%m-%d %I:%M:%S %p %Z%z").strip()@@ -186,19 +184,9 @@ def compile_memory_metadata_block(["<memory_metadata>",f"- The current time is: {get_local_time_fast()}",- f"- Memory blocks were last modified: {timestamp_str}]",+ f"- Memory blocks were last modified: {timestamp_str}",f"- {previous_message_count} previous messages between you and the user are stored in recall memory (use tools to access them)",f"- {archival_memory_size} total memories you created are stored in archival memory (use tools to access them)",- (- (- "<archival_preview>"- + f"\n{len(recent_passages)} most recent external memories from archival memory:"- + "".join([f"\n- {passage.text}" for passage in recent_passages])- + "\n</archival_preview>"- )- if recent_passages is not None- else ""- ),"</memory_metadata>",])@@ -235,7 +223,6 @@ def compile_system_message(template_format: Literal["f-string", "mustache", "jinja2"] = "f-string",previous_message_count: int = 0,archival_memory_size: int = 0,- recent_passages: Optional[List[PydanticPassage]] = None,) -> str:"""Prepare the final/full system message that will be fed into the LLM API@@ -260,7 +247,6 @@ def compile_system_message(memory_edit_timestamp=in_context_memory_last_edit,previous_message_count=previous_message_count,archival_memory_size=archival_memory_size,- recent_passages=recent_passages,)full_memory_string = in_context_memory.compile() + "\n\n" + memory_metadata_string