feat: tune file tools prompting (#2652)
This commit is contained in:
@@ -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 edited
|
||||
READ_ONLY_BLOCK_EDIT_ERROR = f"{ERROR_MESSAGE_PREFIX} This block is read-only and cannot be edited."
|
||||
|
||||
@@ -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: Optio
|
||||
|
||||
async 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.
|
||||
|
||||
@@ -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 agent
|
||||
pydantic_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_agent
|
||||
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user