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.

feat: add pagination to run messages endpoint (#5082)

cthomasaf23e6cda196
diff --git a/fern/openapi.json b/fern/openapi.json
index af2f31dc8..8d6db7429 100644
--- a/fern/openapi.json
+++ b/fern/openapi.json
@@ -10207,6 +10207,19 @@
"title": "Order"
},
"description": "Sort order for messages by creation time. 'asc' for oldest first, 'desc' for newest first"
+ },
+ {
+ "name": "order_by",
+ "in": "query",
+ "required": false,
+ "schema": {
+ "const": "created_at",
+ "type": "string",
+ "description": "Field to sort by",
+ "default": "created_at",
+ "title": "Order By"
+ },
+ "description": "Field to sort by"
}
],
"responses": {
diff --git a/letta/server/rest_api/routers/v1/runs.py b/letta/server/rest_api/routers/v1/runs.py
index b8bab7dbd..0577eba99 100644
--- a/letta/server/rest_api/routers/v1/runs.py
+++ b/letta/server/rest_api/routers/v1/runs.py
@@ -187,6 +187,7 @@ async def list_run_messages(
order: Literal["asc", "desc"] = Query(
"asc", description="Sort order for messages by creation time. 'asc' for oldest first, 'desc' for newest first"
),
+ order_by: Literal["created_at"] = Query("created_at", description="Field to sort by"),
):
"""Get response messages associated with a run."""
actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id)