Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: don't include archival memory metadata summary unless something is in it (#3179)

Charles Packer252dff6cd752
diff --git a/letta/services/helpers/agent_manager_helper.py b/letta/services/helpers/agent_manager_helper.py
index 7c46219d8..eff7ff589 100644
--- a/letta/services/helpers/agent_manager_helper.py
+++ b/letta/services/helpers/agent_manager_helper.py
@@ -207,16 +207,21 @@ def compile_memory_metadata_block(
timestamp_str = format_datetime(memory_edit_timestamp, timezone)
# Create a metadata block of info so the agent knows about the metadata of out-of-context memories
- memory_metadata_block = "\n".join(
- [
- "<memory_metadata>",
- f"- The current time is: {get_local_time_fast(timezone)}",
- 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)",
- "</memory_metadata>",
- ]
- )
+ metadata_lines = [
+ "<memory_metadata>",
+ f"- The current time is: {get_local_time_fast(timezone)}",
+ 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)",
+ ]
+
+ # Only include archival memory line if there are archival memories
+ if archival_memory_size > 0:
+ metadata_lines.append(
+ f"- {archival_memory_size} total memories you created are stored in archival memory (use tools to access them)"
+ )
+
+ metadata_lines.append("</memory_metadata>")
+ memory_metadata_block = "\n".join(metadata_lines)
return memory_metadata_block