Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: add pagination to run steps endpoint (#5083)
cthomas0794a6db6943
diff --git a/fern/openapi.json b/fern/openapi.jsonindex 8d6db7429..9f454efb6 100644--- a/fern/openapi.json+++ b/fern/openapi.json@@ -10295,7 +10295,7 @@"get": {"tags": ["runs"],"summary": "List Run Steps",- "description": "Get messages associated with a run with filtering options.\n\nArgs:\n run_id: ID of the run\n before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n limit: Maximum number of steps to return\n order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.\n\nReturns:\n A list of steps associated with the run.",+ "description": "Get steps associated with a run with filtering options.\n\nArgs:\n run_id: ID of the run\n before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.\n after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.\n limit: Maximum number of steps to return\n order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.\n\nReturns:\n A list of steps associated with the run.","operationId": "list_run_steps","parameters": [{@@ -10367,12 +10367,26 @@"in": "query","required": false,"schema": {+ "enum": ["asc", "desc"],"type": "string",- "description": "Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.",+ "description": "Sort order for steps by creation time. 'asc' for oldest first, 'desc' for newest first","default": "desc","title": "Order"},- "description": "Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order."+ "description": "Sort order for steps 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.pyindex 0577eba99..cb4874f01 100644--- a/letta/server/rest_api/routers/v1/runs.py+++ b/letta/server/rest_api/routers/v1/runs.py@@ -225,12 +225,13 @@ async def list_run_steps(before: Optional[str] = Query(None, description="Cursor for pagination"),after: Optional[str] = Query(None, description="Cursor for pagination"),limit: Optional[int] = Query(100, description="Maximum number of messages to return"),- order: str = Query(- "desc", description="Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order."+ order: Literal["asc", "desc"] = Query(+ "desc", description="Sort order for steps 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 messages associated with a run with filtering options.+ Get steps associated with a run with filtering options.Args:run_id: ID of the run@@ -242,9 +243,6 @@ async def list_run_steps(Returns:A list of steps associated with the run."""- if order not in ["asc", "desc"]:- raise HTTPException(status_code=400, detail="Order must be 'asc' or 'desc'")-actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id)runs_manager = RunManager()