Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: tune file tools prompting (#2652)
Kevin Lin5b83c96af4a3
diff --git a/letta/constants.py b/letta/constants.pyindex 412c5e195..aab388bfe 100644--- a/letta/constants.py+++ b/letta/constants.py@@ -292,9 +292,6 @@ MESSAGE_SUMMARY_WARNING_STR = " ".join(# "Remember to pass request_heartbeat = true if you would like to send a message immediately after.",])-DATA_SOURCE_ATTACH_ALERT = (- "[ALERT] New data was just uploaded to archival memory. You can view this data by calling the archival_memory_search tool."-)# Throw an error message when a read-only block is editedREAD_ONLY_BLOCK_EDIT_ERROR = f"{ERROR_MESSAGE_PREFIX} This block is read-only and cannot be edited."diff --git a/letta/functions/function_sets/files.py b/letta/functions/function_sets/files.pyindex cf7bd2291..f3a2ea724 100644--- a/letta/functions/function_sets/files.py+++ b/letta/functions/function_sets/files.py@@ -7,10 +7,10 @@ if TYPE_CHECKING:async def open_file(agent_state: "AgentState", file_name: str, view_range: Optional[Tuple[int, int]]) -> str:"""- Open up a file in core memory.+ Open the file with name `file_name` and load the contents into files section in core memory.Args:- file_name (str): Name of the file to view.+ file_name (str): Name of the file to view. Required.view_range (Optional[Tuple[int, int]]): Optional tuple indicating range to view.Returns:@@ -21,7 +21,7 @@ async def open_file(agent_state: "AgentState", file_name: str, view_range: Optioasync def close_file(agent_state: "AgentState", file_name: str) -> str:"""- Close a file in core memory.+ Close file with name `file_name` in files section in core memory.Args:file_name (str): Name of the file to close.@@ -48,7 +48,7 @@ async def grep(agent_state: "AgentState", pattern: str, include: Optional[str] =async def search_files(agent_state: "AgentState", query: str) -> List["FileMetadata"]:"""- Get list of most relevant files across all data sources.+ Get list of most relevant files across all data sources using embedding search.Args:query (str): The search query.diff --git a/letta/services/agent_manager.py b/letta/services/agent_manager.pyindex dc292d1fa..c7f8628d5 100644--- a/letta/services/agent_manager.py+++ b/letta/services/agent_manager.py@@ -15,7 +15,6 @@ from letta.constants import (BASE_TOOLS,BASE_VOICE_SLEEPTIME_CHAT_TOOLS,BASE_VOICE_SLEEPTIME_TOOLS,- DATA_SOURCE_ATTACH_ALERT,FILES_TOOLS,MULTI_AGENT_TOOLS,)@@ -1717,13 +1716,7 @@ class AgentManager:await agent.update_async(session, actor=actor)# Force rebuild of system prompt so that the agent is updated with passage count- # and recent passages and add system message alert to agentpydantic_agent = await self.rebuild_system_prompt_async(agent_id=agent_id, actor=actor, force=True)- await self.append_system_message_async(- agent_id=agent_id,- content=DATA_SOURCE_ATTACH_ALERT,- actor=actor,- )return pydantic_agentdiff --git a/letta/services/tool_executor/files_tool_executor.py b/letta/services/tool_executor/files_tool_executor.pyindex 539793123..df0b60cf6 100644--- a/letta/services/tool_executor/files_tool_executor.py+++ b/letta/services/tool_executor/files_tool_executor.py@@ -126,15 +126,14 @@ class LettaFileToolExecutor(ToolExecutor):await self.files_agents_manager.update_file_agent_by_id(agent_id=agent_state.id, file_id=file_id, actor=self.actor, is_open=True, visible_content=visible_content)-- return "Success"+ return f"Successfully opened file {file_name}, lines {start} to {end} are now visible in memory block <{file_name}>"async def close_file(self, agent_state: AgentState, file_name: str) -> str:"""Stub for close_file tool."""await self.files_agents_manager.update_file_agent_by_name(agent_id=agent_state.id, file_name=file_name, actor=self.actor, is_open=False)- return "Success"+ return f"Successfully closed file {file_name}, use function calls to re-open file"def _validate_regex_pattern(self, pattern: str) -> None:"""Validate regex pattern to prevent catastrophic backtracking."""