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: update test sources with file limits (#3521)

Kevin Lin1997c0bcf81b
diff --git a/letta/services/agent_manager.py b/letta/services/agent_manager.py
index 6302f6453..be12684f8 100644
--- a/letta/services/agent_manager.py
+++ b/letta/services/agent_manager.py
@@ -15,6 +15,8 @@ from letta.constants import (
BASE_TOOLS,
BASE_VOICE_SLEEPTIME_CHAT_TOOLS,
BASE_VOICE_SLEEPTIME_TOOLS,
+ DEFAULT_CORE_MEMORY_SOURCE_CHAR_LIMIT,
+ DEFAULT_MAX_FILES_OPEN,
DEFAULT_TIMEZONE,
DEPRECATED_LETTA_TOOLS,
FILES_TOOLS,
@@ -3169,6 +3171,12 @@ class AgentManager:
if max_files is None:
max_files = default_max_files
+ # FINAL fallback: ensure neither is None (should never happen, but just in case)
+ if per_file_limit is None:
+ per_file_limit = DEFAULT_CORE_MEMORY_SOURCE_CHAR_LIMIT
+ if max_files is None:
+ max_files = DEFAULT_MAX_FILES_OPEN
+
return per_file_limit, max_files
@enforce_types
diff --git a/tests/test_sources.py b/tests/test_sources.py
index bfbf6a146..cb956f6c7 100644
--- a/tests/test_sources.py
+++ b/tests/test_sources.py
@@ -277,6 +277,10 @@ def test_attach_existing_files_creates_source_blocks_correctly(disable_pinecone,
# Assert that the expected chunk is in the raw system message
expected_chunk = """<directories>
+<file_limits>
+- current_files_open=1
+- max_files_open=5
+</file_limits>
<directory name="test_source">
<file status="open" name="test_source/test.txt">
<metadata>
@@ -334,6 +338,10 @@ def test_delete_source_removes_source_blocks_correctly(disable_pinecone, client:
raw_system_message = get_raw_system_message(client, agent_state.id)
# Assert that the expected chunk is in the raw system message
expected_chunk = """<directories>
+<file_limits>
+- current_files_open=1
+- max_files_open=5
+</file_limits>
<directory name="test_source">
<file status="open" name="test_source/test.txt">
<metadata>