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.

chore: fix archival memories (#1366)

Shubham Naik48f2da9453f9
diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.py
index 189985da9..80b4c2605 100644
--- a/letta/server/rest_api/routers/v1/agents.py
+++ b/letta/server/rest_api/routers/v1/agents.py
@@ -437,9 +437,13 @@ def detach_block(
def list_passages(
agent_id: str,
server: "SyncServer" = Depends(get_letta_server),
- after: Optional[int] = Query(None, description="Unique ID of the memory to start the query range at."),
- before: Optional[int] = Query(None, description="Unique ID of the memory to end the query range at."),
+ after: Optional[str] = Query(None, description="Unique ID of the memory to start the query range at."),
+ before: Optional[str] = Query(None, description="Unique ID of the memory to end the query range at."),
limit: Optional[int] = Query(None, description="How many results to include in the response."),
+ search: Optional[str] = Query(None, description="Search passages by text"),
+ ascending: Optional[bool] = Query(
+ True, description="Whether to sort passages oldest to newest (True, default) or newest to oldest (False)"
+ ),
actor_id: Optional[str] = Header(None, alias="user_id"), # Extract user_id from header, default to None if not present
):
"""
@@ -452,7 +456,9 @@ def list_passages(
agent_id=agent_id,
after=after,
before=before,
+ query_text=search,
limit=limit,
+ ascending=ascending,
)
diff --git a/letta/server/server.py b/letta/server/server.py
index 7f6e59ec7..713393b7b 100644
--- a/letta/server/server.py
+++ b/letta/server/server.py
@@ -784,6 +784,8 @@ class SyncServer(Server):
limit: Optional[int] = 100,
order_by: Optional[str] = "created_at",
reverse: Optional[bool] = False,
+ query_text: Optional[str] = None,
+ ascending: Optional[bool] = True,
) -> List[Passage]:
# TODO: Thread actor directly through this function, since the top level caller most likely already retrieved the user
actor = self.user_manager.get_user_or_default(user_id=user_id)
@@ -793,9 +795,10 @@ class SyncServer(Server):
actor=actor,
agent_id=agent_id,
after=after,
+ query_text=query_text,
before=before,
+ ascending=ascending,
limit=limit,
- ascending=not reverse,
)
return records