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.

feat: move file name to property (#3091)

Kevin Lin3540bda0502f
diff --git a/letta/schemas/agent.py b/letta/schemas/agent.py
index dc38eead9..b7efb4e3c 100644
--- a/letta/schemas/agent.py
+++ b/letta/schemas/agent.py
@@ -321,8 +321,7 @@ def get_prompt_template_for_agent_type(agent_type: Optional[AgentType] = None):
return (
f"<files>\n{{% if file_blocks %}}{FILE_MEMORY_EXISTS_MESSAGE}\n{{% else %}}{FILE_MEMORY_EMPTY_MESSAGE}{{% endif %}}"
"{% for block in file_blocks %}"
- f"<file status=\"{{{{ '{FileStatus.open.value}' if block.value else '{FileStatus.closed.value}' }}}}\">\n"
- "<{{ block.label }}>\n"
+ f"<file status=\"{{{{ '{FileStatus.open.value}' if block.value else '{FileStatus.closed.value}' }}}}\" name=\"{{{{ block.label }}}}\">\n"
"<description>\n"
"{{ block.description }}\n"
"</description>\n"
@@ -334,7 +333,6 @@ def get_prompt_template_for_agent_type(agent_type: Optional[AgentType] = None):
"<value>\n"
"{{ block.value }}\n"
"</value>\n"
- "</{{ block.label }}>\n"
"</file>\n"
"{% if not loop.last %}\n{% endif %}"
"{% endfor %}"
@@ -374,8 +372,7 @@ def get_prompt_template_for_agent_type(agent_type: Optional[AgentType] = None):
"{% endif %}"
f"\n\n<files>\n{{% if file_blocks %}}{FILE_MEMORY_EXISTS_MESSAGE}\n{{% else %}}{FILE_MEMORY_EMPTY_MESSAGE}{{% endif %}}"
"{% for block in file_blocks %}"
- f"<file status=\"{{{{ '{FileStatus.open.value}' if block.value else '{FileStatus.closed.value}' }}}}\">\n"
- "<{{ block.label }}>\n"
+ f"<file status=\"{{{{ '{FileStatus.open.value}' if block.value else '{FileStatus.closed.value}' }}}}\" name=\"{{{{ block.label }}}}\">\n"
"{% if block.description %}"
"<description>\n"
"{{ block.description }}\n"
@@ -391,7 +388,6 @@ def get_prompt_template_for_agent_type(agent_type: Optional[AgentType] = None):
"{{ block.value }}\n"
"</value>\n"
"{% endif %}"
- "</{{ block.label }}>\n"
"</file>\n"
"{% if not loop.last %}\n{% endif %}"
"{% endfor %}"
@@ -427,13 +423,7 @@ def get_prompt_template_for_agent_type(agent_type: Optional[AgentType] = None):
"{% endif %}"
f"\n\n<files>\n{{% if file_blocks %}}{FILE_MEMORY_EXISTS_MESSAGE}\n{{% else %}}{FILE_MEMORY_EMPTY_MESSAGE}{{% endif %}}"
"{% for block in file_blocks %}"
- f"<file status=\"{{{{ '{FileStatus.open.value}' if block.value else '{FileStatus.closed.value}' }}}}\">\n"
- "<{{ block.label }}>\n"
- "{% if block.description %}"
- "<description>\n"
- "{{ block.description }}\n"
- "</description>\n"
- "{% endif %}"
+ f"<file status=\"{{{{ '{FileStatus.open.value}' if block.value else '{FileStatus.closed.value}' }}}}\" name=\"{{{{ block.label }}}}\">\n"
"<metadata>"
"{% if block.read_only %}\n- read_only=true{% endif %}\n"
"- chars_current={{ block.value|length }}\n"
@@ -444,7 +434,6 @@ def get_prompt_template_for_agent_type(agent_type: Optional[AgentType] = None):
"{{ block.value }}\n"
"</value>\n"
"{% endif %}"
- "</{{ block.label }}>\n"
"</file>\n"
"{% if not loop.last %}\n{% endif %}"
"{% endfor %}"
diff --git a/tests/helpers/utils.py b/tests/helpers/utils.py
index 2a7ec2297..82abb3a73 100644
--- a/tests/helpers/utils.py
+++ b/tests/helpers/utils.py
@@ -238,7 +238,7 @@ def validate_context_window_overview(
# 16. Check attached file is visible
if attached_file:
assert attached_file.visible_content in overview.core_memory
- assert '<file status="open">' in overview.core_memory
+ assert '<file status="open"' in overview.core_memory
assert "</file>" in overview.core_memory
# Check for tools