Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat(core): sort agents by updated_at [LET-7771] (#9730)
Christina Tongc8ae02a1fb69
diff --git a/fern/openapi.json b/fern/openapi.jsonindex fa71b15a6..6837c527b 100644--- a/fern/openapi.json+++ b/fern/openapi.json@@ -4274,7 +4274,7 @@"in": "query","required": false,"schema": {- "enum": ["created_at", "last_run_completion"],+ "enum": ["created_at", "updated_at", "last_run_completion"],"type": "string","description": "Field to sort by","default": "created_at",diff --git a/letta/server/rest_api/routers/v1/agents.py b/letta/server/rest_api/routers/v1/agents.pyindex d170c4238..bf25f259e 100644--- a/letta/server/rest_api/routers/v1/agents.py+++ b/letta/server/rest_api/routers/v1/agents.py@@ -156,7 +156,7 @@ async def list_agents(order: Literal["asc", "desc"] = Query("desc", description="Sort order for agents by creation time. 'asc' for oldest first, 'desc' for newest first"),- order_by: Literal["created_at", "last_run_completion"] = Query("created_at", description="Field to sort by"),+ order_by: Literal["created_at", "updated_at", "last_run_completion"] = Query("created_at", description="Field to sort by"),ascending: bool = Query(False,description="Whether to sort agents oldest to newest (True) or newest to oldest (False, default)",diff --git a/letta/services/helpers/agent_manager_helper.py b/letta/services/helpers/agent_manager_helper.pyindex eb313905c..e4ba18fec 100644--- a/letta/services/helpers/agent_manager_helper.py+++ b/letta/services/helpers/agent_manager_helper.py@@ -604,6 +604,9 @@ def _apply_pagination(if sort_by == "last_run_completion":sort_column = AgentModel.last_run_completionsort_nulls_last = True # TODO: handle this as a query param eventually+ elif sort_by == "updated_at":+ sort_column = AgentModel.updated_at+ sort_nulls_last = Falseelse:sort_column = AgentModel.created_atsort_nulls_last = False@@ -637,6 +640,9 @@ async def _apply_pagination_async(if sort_by == "last_run_completion":sort_column = AgentModel.last_run_completionsort_nulls_last = True # TODO: handle this as a query param eventually+ elif sort_by == "updated_at":+ sort_column = AgentModel.updated_at+ sort_nulls_last = Falseelse:sort_column = AgentModel.created_atsort_nulls_last = False