From 1997c0bcf81b90d07252c413a66b043144d1bbd5 Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Thu, 24 Jul 2025 10:14:28 -0700 Subject: [PATCH] fix: update test sources with file limits (#3521) --- letta/services/agent_manager.py | 8 ++++++++ tests/test_sources.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/letta/services/agent_manager.py b/letta/services/agent_manager.py index 6302f645..be12684f 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 bfbf6a14..cb956f6c 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 = """ + +- current_files_open=1 +- max_files_open=5 + @@ -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 = """ + +- current_files_open=1 +- max_files_open=5 +